Appearance
Contacts
Endpoints
GET /v1/contacts
GET /v1/contacts/:id
POST /v1/contacts
PATCH /v1/contacts/:id
DELETE /v1/contacts/:idINFO
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/contactsReturns a page of contacts.
Parameters
| Name | Optional | Default | Description | Options |
|---|---|---|---|---|
| Pagination parameters | See 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/:idGets the details of a single contact.
Parameters
| Name | Optional | Type | Description |
|---|---|---|---|
| id | required | string | The ID of the contact to retrieve. |
| external | optional | boolean | If 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?externalReturns
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
| Code | Description |
|---|---|
| 404 | Contact with the given ID was not found. |
| 422 | Invalid request, missing required parameters or supplied parameters are invalid |
Create a contact
POST /v1/contactsCreates a new contact.
Parameters
| Name | Optional | Type | Description |
|---|---|---|---|
| external_id | required | string | A unique identifier from your system for the contact. |
| first_name | required | string | The first name of the contact. |
| last_name | required | string | The last name of the contact. |
| required | string | The email address of the contact. | |
| phone_number | optional | string | The phone number of the contact. |
| attributes | optional | object | A 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
| Code | Description |
|---|---|
| 409 | Contact with the same external_id already exists |
| 422 | Invalid request, missing required parameters or supplied parameters are invalid |
Update a contact
PATCH /v1/contacts/:idUpdates a contact.
Parameters
| Name | Optional | Type | Description |
|---|---|---|---|
| id | required | string | The ID of the contact to update. |
| external | optional | boolean | If lookup is done by external_id instead of id. Defaults to false (lookup by id). |
| external_id | optional | string | A unique identifier from your system for the contact. |
| first_name | optional | string | The first name of the contact. |
| last_name | optional | string | The last name of the contact. |
| optional | string | The email address of the contact. | |
| phone_number | optional | string | The phone number of the contact. |
| attributes | optional | object | A 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
| Code | Description |
|---|---|
| 404 | Contact with the given ID was not found. |
| 422 | Invalid request, supplied parameters did not pass validation. |
Delete a contact
DELETE /v1/contacts/:idDeletes a contact.
Parameters
| Name | Optional | Type | Description |
|---|---|---|---|
| id | required | string | The ID of the contact to delete. |
| external | optional | boolean | If 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
| Code | Description |
|---|---|
| 404 | Contact with the given ID was not found. |
| 422 | Invalid request, missing required parameters or supplied parameters are invalid |