Object Records
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
orexternal_ids
withtype
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 |
Code Samples
curl
# Returns object records by object type key
curl "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}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records?external_ids=%5B1%2C3%2C4%5D&ids=%5B%2214c6c4be-cb64-4678-ba73-296e3d2c32cf%22%5D&order=desc&per_page=1&type=product"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records")
.newBuilder()
.addQueryParameter("external_ids", "[1,3,4]")
.addQueryParameter("ids", "["14c6c4be-cb64-4678-ba73-296e3d2c32cf"]")
.addQueryParameter("order", "desc")
.addQueryParameter("per_page", "1")
.addQueryParameter("type", "product");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://support.zendesk.com/api/sunshine/objects/records',
headers: {
'Content-Type': 'application/json',
},
params: {
'external_ids': '%5B1%2C3%2C4%5D',
'ids': '%5B%2214c6c4be-cb64-4678-ba73-296e3d2c32cf%22%5D',
'order': 'desc',
'per_page': '1',
'type': 'product',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records?external_ids=%5B1%2C3%2C4%5D&ids=%5B%2214c6c4be-cb64-4678-ba73-296e3d2c32cf%22%5D&order=desc&per_page=1&type=product"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"GET",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records")
uri.query = URI.encode_www_form("external_ids": "[1,3,4]", "ids": "["14c6c4be-cb64-4678-ba73-296e3d2c32cf"]", "order": "desc", "per_page": "1", "type": "product")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// 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
}
}
List Related Object Records
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 |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id}/related/{relationship_type} \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf/related/suppliers?order=desc&per_page=1"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf/related/suppliers")
.newBuilder()
.addQueryParameter("order", "desc")
.addQueryParameter("per_page", "1");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf/related/suppliers',
headers: {
'Content-Type': 'application/json',
},
params: {
'order': 'desc',
'per_page': '1',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf/related/suppliers?order=desc&per_page=1"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"GET",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf/related/suppliers")
uri.query = URI.encode_www_form("order": "desc", "per_page": "1")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// 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 |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id} \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf")
.newBuilder();
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf',
headers: {
'Content-Type': 'application/json',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"GET",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// 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
Code Samples
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}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records"
method := "POST"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records")
.newBuilder();
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
"""
""");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'POST',
url: 'https://support.zendesk.com/api/sunshine/objects/records',
headers: {
'Content-Type': 'application/json',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"POST",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records")
request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
201 Created
// 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 |
Code Samples
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}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf"
method := "PATCH"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf")
.newBuilder();
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
"""
""");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("PATCH", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'PATCH',
url: 'https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf',
headers: {
'Content-Type': 'application/json',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"PATCH",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf")
request = Net::HTTP::Patch.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// 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.
Some frameworks (such as .NET) automatically add the UTF-8 character set to the content-type header. For example:
Content-Type: application/merge-patch+json; charset=utf-8
This results in a 400 Bad Request response. Remove charset=utf-8
to fix the error.
Allowed for
- Everyone
Code Samples
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}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records"
method := "PATCH"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records")
.newBuilder();
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
"""
""");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("PATCH", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'PATCH',
url: 'https://support.zendesk.com/api/sunshine/objects/records',
headers: {
'Content-Type': 'application/json',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"PATCH",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records")
request = Net::HTTP::Patch.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// 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 |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/sunshine/objects/records/{id} \
-X DELETE \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf"
method := "DELETE"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf")
.newBuilder();
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("DELETE", null)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'DELETE',
url: 'https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf',
headers: {
'Content-Type': 'application/json',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"DELETE",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records/14c6c4be-cb64-4678-ba73-296e3d2c32cf")
request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
204 No Content
// Status 204 No Content
null
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 |
Code Samples
curl
curl "https://{subdomain}.zendesk.com/api/sunshine/objects/records?type=product&external_id=1" \
-X DELETE \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/sunshine/objects/records?external_id=4&type=product"
method := "DELETE"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/sunshine/objects/records")
.newBuilder()
.addQueryParameter("external_id", "4")
.addQueryParameter("type", "product");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("DELETE", null)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'DELETE',
url: 'https://support.zendesk.com/api/sunshine/objects/records',
headers: {
'Content-Type': 'application/json',
},
params: {
'external_id': '4',
'type': 'product',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/sunshine/objects/records?external_id=4&type=product"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"DELETE",
url,
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/sunshine/objects/records")
uri.query = URI.encode_www_form("external_id": "4", "type": "product")
request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
204 No Content
// Status 204 No Content
null