Custom object records are created from an object type that you define. Your object records are stored in the Zendesk infrastructure. For more information, see Object Records in the Custom objects handbook.

Object records are validated against the object type schema.

You can define associations between different object records with relationship records.

JSON Format

Object Records are represented as JSON objects with the following properties:

Name Type Read-only Mandatory Description
attributes object false true The data for the object record, up to a maximum of 32 KB. The object properties are defined in the schema of the type
created_at string true false The time the object record was created
external_id string false false A unique, case-insensitive identifier for the object record, usually from another system. Writable on create only
id string true false Automatically assigned when the object record is created
type string false true The object type key. Writable on create only
type_version integer false false The version of the record's object type
updated_at string true false The time of the last update of the object record

The created_at and updated_at properties may not match exactly due to rounding of the updated_at timestamp.

Example

{  "attributes": {    "id": "3b0ff066-e8ec-11e6-bf01-fe55135034f3",    "name": "Standing Desk"  },  "created_at": "2020-04-24T23:47:19.000Z",  "type": "product",  "updated_at": "2020-04-24T23:47:19.000Z"}

List Object Records

  • GET /api/sunshine/objects/records

You must use at least one query parameter to filter the returned collection. For instance, you can:

  • Use type to list object records by object type key. Example: /api/sunshine/objects/records?type={object_type}
  • Use ids to list object records by id. Example: /api/sunshine/objects/records?ids={id, id, ...}
  • Use external_id or external_ids with type to return an array containing one or more records for a given object record external id and object type key. Example: /api/sunshine/objects/records?type={object_type}&external_ids={id, id, ...}

If you don't provide at least one filtering parameter, a 400 error will be returned.

Also, when using ids filter, the response may include an errors array if some of the IDs were not valid. Example:

{  "data": [    {      "id": "14c6c4be-cb64-4678-ba73-296e3d2c32cf",      "type": "product",      "type_version": 1,      "external_id": "3",      "attributes": {        "id": "3",        "name": "Strawberry Chewing Gum"      },      "created_at": "2017-01-03T12:35:45Z",      "updated_at": "2017-01-03T12:35:45Z"    }  ],  "errors": [    {      "code": "BadRequest",      "status": "400",      "title": "Bad Request",      "detail": "id 4 is not a valid type 1 UUID"    }  ]}

Allowed For

  • Everyone

Parameters

Name Type In Required Description
external_ids array Query false Returns object records by object record external ids
ids array Query false Returns object records by object record ids
order string Query false Order of the items (by creation time). Default is ascending. Allowed values are "asc", or "desc".
per_page string Query false Number of items returned per page from 1 to 1000
type string Query false See object type key
object_record_id string Path true The ID of the object record

Using curl

# Returns object records by object type keycurl "https://{subdomain}.zendesk.com/api/sunshine/objects/records?type=product" \  -v -u {email_address}:{password}
# Returns object records by object record ids.curl "https://{subdomain}.zendesk.com/api/sunshine/objects/records?ids=14c6c4be-cb64-4678-ba73-296e3d2c32cf,4" \  -v -u {email_address}:{password}
# Returns an array of records that matches both `type` and `external_id` .curl "https://{subdomain}.zendesk.com/api/sunshine/objects/records?type=product&external_id=18" \  -v -u {email_address}:{password}

Example Response

Status 200 OK
{  "data": [    {      "attributes": {        "id": "3",        "name": "Strawberry Chewing Gum"      },      "created_at": "2017-01-03T12:35:45Z",      "external_id": "3",      "id": "14c6c4be-cb64-4678-ba73-296e3d2c32cf",      "type": "product",      "type_version": 1,      "updated_at": "2017-01-03T12:35:45Z"    },    {      "attributes": {        "id": "4",        "name": "Coffee Chewing Gum"      },      "created_at": "2017-01-03T12:35:45Z",      "external_id": "4",      "id": "d07b6206-1ea1-43c4-ae68-ef743aa36169",      "type": "product",      "type_version": 1,      "updated_at": "2017-01-03T12:35:45Z"    }  ],  "links": {    "next": null,    "previous": null  }}
  • GET /api/sunshine/objects/records/{object_record_id}/related/{relationship_type_key}

Returns all the object records that the specified object record has relationship records with for the specified relationship type. For the relationship type, specify a relationship type key. For the specified object record, specify a custom object record id or a Zendesk object record id.

For example, the following request returns all object records related to the object record with the id of 1edf74c1-8000-4d01-b75e-e14bf2c85442 in the relationship type with a key named "suppliers":

GET /api/sunshine/objects/records/1edf74c1-8000-4d01-b75e-e14bf2c85442/related/suppliers

See the Example Response section below. The custom object record with the id 1edf74c1-8000-4d01-b75e-e14bf2c85442 has relationship records to these object records, but they don't have a relationship record back to the original object record.

You can specify a Zendesk object record as follows:

GET /api/sunshine/objects/records/zen:user:123456/related/suppliers

Allowed For

  • Everyone

Parameters

Name Type In Required Description
order string Query false Order of the items (by creation time). Default is ascending. Allowed values are "asc", or "desc".
per_page string Query false Number of items returned per page from 1 to 1000
object_record_id string Path true The ID of the object record
relationship_type_key string Path true The key of the relationship type

Using curl

curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id}/related/{relationship_type} \  -v -u {email_address}:{password}

Example Response

Status 200 OK
{  "data": [    {      "attributes": {        "id": "3",        "name": "Strawberry Chewing Gum"      },      "created_at": "2017-01-03T12:35:45Z",      "external_id": "3",      "id": "14c6c4be-cb64-4678-ba73-296e3d2c32cf",      "type": "product",      "type_version": 1,      "updated_at": "2017-01-03T12:35:45Z"    },    {      "attributes": {        "id": "4",        "name": "Coffee Chewing Gum"      },      "created_at": "2017-01-03T12:35:45Z",      "external_id": "4",      "id": "d07b6206-1ea1-43c4-ae68-ef743aa36169",      "type": "product",      "type_version": 1,      "updated_at": "2017-01-03T12:35:45Z"    }  ],  "links": {    "next": null,    "previous": null  }}

Show Object Record

  • GET /api/sunshine/objects/records/{object_record_id}

Returns the specified object record.

Allowed For

  • Everyone

Parameters

Name Type In Required Description
object_record_id string Path true The ID of the object record

Using curl

curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id} \  -v -u {email_address}:{password}

Example Response

Status 200 OK
{  "data": {    "attributes": {      "id": "3",      "name": "Strawberry Chewing Gum"    },    "created_at": "2017-01-03T12:35:45Z",    "external_id": "3",    "id": "14c6c4be-cb64-4678-ba73-296e3d2c32cf",    "type": "product",    "updated_at": "2017-01-03T12:35:45Z"  }}

Create Object Record

  • POST /api/sunshine/objects/records

Creates an object record.

Unless the object type's schema includes "additionalProperties": false, you can specify additional properties for the new record even if the name of the property is not included in the schema. Exceptions: You can't specify an additional property that uses an asterisk (*) as the name or an underscore (_) as a prefix for the name. These naming conventions are reserved for internal use. See schema property.

If you created records with properties that used an asterisk for a name or an underscore for a prefix, you should rename the properties to avoid any possible future conflicts.

Allowed For

  • Everyone

Using curl

curl https://{subdomain}.zendesk.com/api/sunshine/objects/records \  -d '{"data": {"type": "product", "external_id": "3", "attributes": {"id": "3", "name": "Strawberry Chewing Gum"}}}' \  -H "Content-Type: application/json" -X POST \  -v -u {email_address}:{password}

Example Response

Status 201 Created
{  "data": {    "attributes": {      "id": "3",      "name": "Strawberry Chewing Gum"    },    "created_at": "2017-01-03T12:35:45Z",    "external_id": "3",    "id": "14c6c4be-cb64-4678-ba73-296e3d2c32cf",    "type": "product",    "type_version": 1,    "updated_at": "2017-01-03T12:35:45Z"  }}

Update Object Record

  • PATCH /api/sunshine/objects/records/{object_record_id}

Updates the attributes object of the specified object record. It does not update any other record properties.

The attributes object patches the previously stored object. Therefore, the request should only contain the properties of the attributes object that need to be updated.

The request must include an "application/merge-patch+json" content-type header.

Parameters

Name Type In Required Description
object_record_id string Path true The ID of the object record

Using curl

curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id} \  -d '{"data": {"attributes": {"id": "4", "name": "Hotdog Chewing Gum"}}}' \  -H "Content-Type: application/merge-patch+json" -X PATCH \  -v -u {email_address}:{password}

Example Response

Status 200 OK
{  "data": {    "attributes": {      "id": "4",      "name": "Hotdog Chewing Gum"    },    "created_at": "2017-01-03T12:35:45Z",    "external_id": "4",    "id": "d07b6206-1ea1-43c4-ae68-ef743aa36169",    "type": "product",    "type_version": 1,    "updated_at": "2017-01-04T18:15:00Z"  }}

Set Object Record by External Id

  • PATCH /api/sunshine/objects/records

Creates a new object if an object with given external id does not exist and updates the attributes object of the specified object record if an object with the given external id does exist. This endpoint does not update any other record properties.

The request should contain:

  • Object type
  • External id
  • attributes of the object that needs to be updated

The request must include an "application/merge-patch+json" content-type header.

Allowed For

  • Everyone

Using curl

curl https://{subdomain}.zendesk.com/api/sunshine/objects/records \  -d '{"data": {"type": "product", "external_id": "4", "attributes": {"id": "4", "name": "Hotdog Chewing Gum"}}}' \  -H "Content-Type: application/merge-patch+json" -X PATCH \  -v -u {email_address}:{password}

Example Response

Status 200 OK
{  "data": {    "attributes": {      "id": "4",      "name": "Hotdog Chewing Gum"    },    "created_at": "2017-01-03T12:35:45Z",    "external_id": "4",    "id": "d07b6206-1ea1-43c4-ae68-ef743aa36169",    "type": "product",    "type_version": 1,    "updated_at": "2017-01-04T18:15:00Z"  }}

Delete Object Record

  • DELETE /api/sunshine/objects/records/{object_record_id}

Deletes the specified object record.

Before deleting an object record, you must delete any relationship record that specifies the object record. See Relationship Records.

Allowed For

  • Everyone

Parameters

Name Type In Required Description
object_record_id string Path true The ID of the object record

Using curl

curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id} \  -X DELETE \  -v -u {email_address}:{password}

Example Response

Status 204 No Content

Delete Object Record by External Id and Type

  • DELETE /api/sunshine/objects/records?external_id={external_id}?type={type}

Deletes the specified object record if it exists.

Before deleting an object record, you must delete any relationship record that specifies the object record. See Relationship Records.

Allowed For

  • Everyone

Parameters

Name Type In Required Description
external_id string Query true The external ID of the object record
type string Query true See object type key

Using curl

curl "https://{subdomain}.zendesk.com/api/sunshine/objects/records?type=product&external_id=1" \  -X DELETE \  -v -u {email_address}:{password}

Example Response

Status 204 No Content