Skip to content
On this page

Contacts

Endpoints

GET /v1/contacts
GET /v1/contacts/:id
POST /v1/contacts
PATCH /v1/contacts/:id
DELETE /v1/contacts/:id

INFO

GET endpoints are available for all API users. However, POST, PATCH, and DELETE endpoints are only available if you are using the API as your sync source. If you are using a sync source other than the API to sync your employee data to Workshop, you can only use the GET endpoints.

List contacts

GET /v1/contacts

Returns a page of contacts.

Parameters

NameOptionalDefaultDescriptionOptions
Pagination parametersSee pagination for more information.

Returns

A page of contact summary objects.

Example response
json
{
  "object": "array",
  "has_more": true,
  "next": "/v1/contacts?cursor=eyJzb3J0IjoibmFtZSIsIm9yZGVyIjoiY...",
  "limit": 5,
  "size": 5,
  "data": [
    {
      "object": "contact",
      "id": "937ccbe2-4cb5-4c76-96bf-29510b514dfa",
      "external_id": "ABC-123",
      "first_name": "John",
      "last_name": "Doe",
      "email": "john@example.com",
      "phone_number": "+12345678910",
      "urls": {
        "details": "/v1/contacts/937ccbe2-4cb5-4c76-96bf-29510b514dfa",
      },
    },
    {...},
    {...},
    {...},
    {...},
  ],
}

Retrieve a contact

GET /v1/contacts/:id

Gets the details of a single contact.

Parameters

NameOptionalTypeDescription
idrequiredstringThe ID of the contact to retrieve.
externaloptionalbooleanIf lookup is done by external_id instead of id. Defaults to false (lookup by id).

INFO

You can only retrieve a contact by external_id that is synced through the API. If you are using a sync source other than the API, a request with the external parameter will return a 404 error.

If the external flag is set, the system searches for a contact whose external_id (instead of id) matches the id request parameter. You can supply the external parameter in the payload or as a query parameter like:

GET /v1/contacts/:id?external

Returns

A contact object.

Example responses

Success response (200)

json
{
  "object": "contact",
  "id": "937ccbe2-4cb5-4c76-96bf-29510b514dfa",
  "external_id": "ABC-123",
  "first_name": "John",
  "last_name": "Doe",
  "email": "john@example.com",
  "phone_number": "+12345678910",
  "attributes": {
    "department": "Sales",
    "office": "Austin"
  },
  "urls": {
    "details": "/v1/contacts/937ccbe2-4cb5-4c76-96bf-29510b514dfa"
  }
}

Error response (404)

json
{
  "error": "Contact with the given ID was not found."
}

Error response (422)

json
{
  "error": {
    "external": ["must be a boolean"]
  }
}

Errors

CodeDescription
404Contact with the given ID was not found.
422Invalid request, missing required parameters or supplied parameters are invalid

Create a contact

POST /v1/contacts

Creates a new contact.

Parameters

NameOptionalTypeDescription
external_idrequiredstringA unique identifier from your system for the contact.
first_namerequiredstringThe first name of the contact.
last_namerequiredstringThe last name of the contact.
emailrequiredstringThe email address of the contact.
phone_numberoptionalstringThe phone number of the contact.
attributesoptionalobjectA dictionary of attributes for the contact.
Example payload
json
{
  "external_id": "ABC-123",
  "first_name": "John",
  "last_name": "Doe",
  "email": "john@example.com",
  "phone_number": "+12345678910",
  "attributes": {
    "department": "Sales",
    "office": "Austin"
  }
}

Returns

A success message and a 201 status code if successful.

Example response
json
{
  "message": "Contact created successfully"
}

Errors

CodeDescription
409Contact with the same external_id already exists
422Invalid request, missing required parameters or supplied parameters are invalid

Update a contact

PATCH /v1/contacts/:id

Updates a contact.

Parameters

NameOptionalTypeDescription
idrequiredstringThe ID of the contact to update.
externaloptionalbooleanIf lookup is done by external_id instead of id. Defaults to false (lookup by id).
external_idoptionalstringA unique identifier from your system for the contact.
first_nameoptionalstringThe first name of the contact.
last_nameoptionalstringThe last name of the contact.
emailoptionalstringThe email address of the contact.
phone_numberoptionalstringThe phone number of the contact.
attributesoptionalobjectA dictionary of attributes for the contact.

If the external flag is set, the system searches for a contact whose external_id (instead of id) matches the id request parameter. This differs from the external_id request parameter, which is used to set the external_id of a contact.

If you do not supply a parameter, its value will remain unchanged. If you attempt to update a contact that does not currently have an external_id, you must supply an external_id value in your request.

Keys in the attributes object will overwrite existing attributes for the contact, but will not change other attributes not specified in the request. To remove a key from a contact's attributes, you must supply a null value for that key.

Example payload
json
{
  "first_name": "John",
  "last_name": "Doe",
  "attributes": {
    "department": "Sales",
    "office": null // Removes the office attribute from this contact
  }
}

Returns

A success message and a 200 status code if successful.

Example response
json
{
  "message": "Contact updated successfully"
}

Errors

CodeDescription
404Contact with the given ID was not found.
422Invalid request, supplied parameters did not pass validation.

Delete a contact

DELETE /v1/contacts/:id

Deletes a contact.

Parameters

NameOptionalTypeDescription
idrequiredstringThe ID of the contact to delete.
externaloptionalbooleanIf lookup is done by external_id instead of id. Defaults to false (lookup by id).

If the external flag is set, the system searches for a contact whose external_id (instead of id) matches the id request parameter.

Returns

A success message and a 200 status code if successful.

Example response
json
{
  "message": "Contact deleted successfully"
}

Errors

CodeDescription
404Contact with the given ID was not found.
422Invalid request, missing required parameters or supplied parameters are invalid