Custom Object Record Attachments
You can upload a file and attach it to a custom object record. The attachment appears in their own tab of the record on the Custom object records page in Zendesk Support. Admins configure whether or not attachments are allowed for a custom object. When they are allowed, you can use the Custom Object Record Attachment API to upload attachments to the record.
Custom object record attachment limitations
- Each record can have a maximum of five attachments.
- Each attachment must be less than or equal to 10MB in size.
List Custom Object Record Attachments
GET /api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments
Lists all attachments associated with a custom object record.
Allowed For
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| custom_object_key | string | Path | true | The key of a custom object |
| record_id | string | Path | true | The id of a custom object record |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments.json \-v -u {email_address}/token:{api_token}
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"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://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments").newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("GET",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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{"custom_object_record_attachments": [{"content_type": "application/pdf","content_url": "https://company.zendesk.com/api/v2/custom_objects/apartment/records/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download","created_at": "2024-01-15T14:30:00Z","created_by": "John Doe","custom_object_record_id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","filename": "contract.pdf","id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","malware_access_override": false,"malware_scan_completed_at": "2024-01-15T14:31:00Z","malware_scan_status": "malware_not_found","size": 245760},{"content_type": "image/jpeg","content_url": "https://company.zendesk.com/api/v2/custom_objects/apartment/records/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E3/download","created_at": "2024-01-15T14:31:00Z","created_by": "Jane Smith","custom_object_record_id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","filename": "floorplan.jpg","id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E3","malware_access_override": false,"malware_scan_completed_at": "2024-01-15T14:32:00Z","malware_scan_status": "malware_not_found","size": 512000}]}
400 Bad Request
// Status 400 Bad Request{"error": "Invalid URI endpoint"}
Create Custom Object Record Attachment
POST /api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments
Creates a new attachment associated with a custom object record. The custom object must have the "allows_attachments" setting enabled.
Allowed For
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| custom_object_key | string | Path | true | The key of a custom object |
| record_id | string | Path | true | The id of a custom object record |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments.json \-F "uploaded_data=@/path/to/file.txt" \-v -u {email_address}/token:{api_token} -X POST
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments"method := "POST"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"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://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("POST", body).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'POST',url: 'https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("POST",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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{"custom_object_record_attachment": {"content_type": "application/pdf","content_url": "https://company.zendesk.com/api/v2/custom_objects/apartment/records/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download","created_at": "2024-01-15T14:30:00Z","created_by": "John Doe","custom_object_record_id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","filename": "contract.pdf","id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","malware_access_override": false,"malware_scan_completed_at": null,"malware_scan_status": "not_scanned","size": 245760}}
400 Bad Request
// Status 400 Bad Request{"error": "Invalid URI endpoint"}
Update Custom Object Record Attachment for Malware
PUT /api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}
Updates malware access settings for the specified attachment. This is typically used to allow access to attachments that were flagged as containing malware.
Allowed For
- Admins
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| custom_object_key | string | Path | true | The key of a custom object |
| id | string | Path | true | The id of a custom object record attachment |
| record_id | string | Path | true | The id of a custom object record |
Example body
{"custom_object_record_attachment": {"malware_access_override": true}}
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}.json \-H "Content-Type: application/json" \-d '{"custom_object_record_attachment": {"malware_access_override": true}}' \-v -u {email_address}/token:{api_token} -X PUT
Go
import ("fmt""io""net/http""strings")func main() {url := "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2"method := "PUT"payload := strings.NewReader(`{"custom_object_record_attachment": {"malware_access_override": true}}`)req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"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://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""{\"custom_object_record_attachment\": {\"malware_access_override\": true}}""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("PUT", body).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var data = JSON.stringify({"custom_object_record_attachment": {"malware_access_override": true}});var config = {method: 'PUT',url: 'https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},data : data,};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsimport jsonfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2"payload = json.loads("""{"custom_object_record_attachment": {"malware_access_override": true}}""")headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("PUT",url,auth=auth,headers=headers,json=payload)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")request.body = %q({"custom_object_record_attachment": {"malware_access_override": true}})email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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{"custom_object_record_attachment": {"content_type": "application/octet-stream","content_url": "https://company.zendesk.com/api/v2/custom_objects/apartment/records/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download","created_at": "2024-01-15T14:30:00Z","created_by": "John Doe","custom_object_record_id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","filename": "potentially_malicious_file.exe","id": "01HQ2Z3X4Y5T6R7S8P9Q0W1E2","malware_access_override": true,"malware_scan_completed_at": "2024-01-15T14:31:00Z","malware_scan_status": "malware_found","size": 1024000}}
400 Bad Request
// Status 400 Bad Request{"error": "Invalid URI endpoint"}
Delete Custom Object Record Attachment
DELETE /api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}
Deletes the specified attachment associated with a custom object record.
Allowed For
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| custom_object_key | string | Path | true | The key of a custom object |
| id | string | Path | true | The id of a custom object record attachment |
| record_id | string | Path | true | The id of a custom object record |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}.json \-X DELETE \-v -u {email_address}/token:{api_token}
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2"method := "DELETE"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"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://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2").newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("DELETE", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'DELETE',url: 'https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("DELETE",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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 Contentnull
400 Bad Request
// Status 400 Bad Request{"error": "Invalid URI endpoint"}
Download Custom Object Record Attachment
GET /api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}/download
Downloads the specified attachment content. Returns a redirect to the attachment's content URL.
Access to malicious attachments is controlled by the malware_access_override setting.
Allowed For
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| inline | boolean | Query | false | If true, the attachment content is displayed inline in the browser. If false or omitted, the attachment is downloaded as a file. |
| custom_object_key | string | Path | true | The key of a custom object |
| id | string | Path | true | The id of a custom object record attachment |
| record_id | string | Path | true | The id of a custom object record |
Code Samples
Curl
curl --request GET https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download?inline= \--header "Content-Type: application/json" \-u {email_address}/token:{api_token}
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download?inline="method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"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://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download").newBuilder().addQueryParameter("inline", "");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},params: {'inline': '',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download?inline="headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("GET",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/custom_objects/car/records/01GCSJW391QVSC80GYDH7E93Q6/attachments/01HQ2Z3X4Y5T6R7S8P9Q0W1E2/download")uri.query = URI.encode_www_form("inline": "")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
curl - Download attachment
curl https://{subdomain}.zendesk.com/api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}/download \-v -u {email_address}/token:{api_token}
curl - Display attachment inline
curl https://{subdomain}.zendesk.com/api/v2/custom_objects/{custom_object_key}/records/{record_id}/attachments/{id}/download?inline=true \-v -u {email_address}/token:{api_token}
Example response(s)
200 OK
// Status 200 OKnull
400 Bad Request
// Status 400 Bad Request{"error": "Invalid URI endpoint"}