Asset Types
When managing assets in Zendesk, an admin must first define the asset type, which becomes an object in Zendesk. The asset type definition consists of standard and custom fields that describe the data you need to store for this type of asset. After an asset type is created, records of individual assets of that type can be added to Zendesk.
Asset types are defined in a hierarchical structure with a maximum depth of 3. Each child asset type inherits the parent asset types' fields. This eliminates the need to recreate the same field repeatedly for different asset types. Including the pre-defined asset types Zendesk provides, you can have a total of 50 asset types.
JSON format
ITAM Asset Types are represented as JSON objects with the following properties:
| Name | Type | Read-only | Mandatory | Description |
|---|---|---|---|---|
| created_by_user_id | integer | true | false | The id of the user who created the asset type |
| description | string | false | false | A description of the asset type |
| display_icon_url | string | true | false | Direct link to the icon used to represent this asset type, inherited from the nearest ancestor asset type that has one set if this asset type has none |
| external_id | string | false | false | An id you can use to link asset types to external data |
| field_keys | array | true | false | Custom field keys associated with the asset type |
| hierarchy_depth | integer | true | false | The depth within the hierarchy tree. Valid values: 1, 2, and 3 |
| icon_url | string | true | false | Direct link to the asset type's own icon, if one is set |
| id | string | true | false | Automatically assigned upon creation |
| is_standard | boolean | true | false | Whether this asset type is a standard asset type. Standard asset types cannot be modified. |
| name | string | false | true | A unique display name for the asset type |
| parent_id | string | false | false | The id of the parent asset type within the hierarchy tree. If omitted on create, defaults to the base asset type. Cannot be changed after the asset type is created. |
| photo | object | false | false | Sets or removes the asset type's icon. Setting an icon requires a multipart/form-data request with a file field named asset_type[photo][uploaded_data] — see the "Adding a photo" code sample. Pass null to remove the existing icon via a normal JSON request. |
| updated_by_user_id | integer | true | false | The id of the user who last updated the asset type |
| url | string | true | false | Direct link to the specific asset type |
List Asset Types
GET /api/v2/it_asset_management/asset_types
Lists all asset types.
Allowed For
- Agents
Code Samples
Curl
curl --request GET https://example.zendesk.com/api/v2/it_asset_management/asset_types \--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/it_asset_management/asset_types"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/it_asset_management/asset_types").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/it_asset_management/asset_types',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/it_asset_management/asset_types"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/it_asset_management/asset_types")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 - Get asset types
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types \-H "Authorization: Bearer {access_token}"
Example response(s)
200 OK
// Status 200 OK{"asset_types": [{"created_by_user_id": 19837362232,"description": null,"display_icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","external_id": null,"field_keys": ["imei","phone_number"],"hierarchy_depth": 2,"icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","id": "01K9BT5X539BKC8SEF430HAJHJ","is_standard": false,"name": "Mobile","parent_id": "01K9BT5SXPR60963HJVPWTZQHD","updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5X539BKC8SEF430HAJHJ"},{"created_by_user_id": 19837362232,"description": null,"display_icon_url": null,"external_id": null,"field_keys": [],"hierarchy_depth": 2,"icon_url": null,"id": "01K9BT5X2VZQH191VYA3GQN7NY","is_standard": false,"name": "Desktop","parent_id": "01K9BT5SXPR60963HJVPWTZQHD","updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5X2VZQH191VYA3GQN7NY"},{"created_by_user_id": 19837362232,"description": null,"display_icon_url": null,"external_id": null,"field_keys": [],"hierarchy_depth": 2,"icon_url": null,"id": "01K9BT5X0115ZVH1X6T37WYMTE","is_standard": false,"name": "Laptop","parent_id": "01K9BT5SXPR60963HJVPWTZQHD","updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5X0115ZVH1X6T37WYMTE"},{"created_by_user_id": 19837362232,"description": null,"display_icon_url": null,"external_id": "hardware","field_keys": ["last_sync_timestamp","operating_system","os_version","ip_address","mac_address","storage_capacity","free_storage","enrollment_status","udid","encryption_status","device_ownership_type","managed","compliance_state","cpu_type","ram_total","firmware_version","last_sign_in_timestamp"],"hierarchy_depth": 1,"icon_url": null,"id": "01K9BT5SXPR60963HJVPWTZQHD","is_standard": true,"name": "Hardware","parent_id": null,"updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5SXPR60963HJVPWTZQHD"}]}
Show Asset Type
GET /api/v2/it_asset_management/asset_types/{asset_type_id}
Returns an asset type with the specified id.
Allowed For
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| asset_type_id | string | Path | true | The id of the asset type |
Code Samples
Curl
curl --request GET https://example.zendesk.com/api/v2/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1 \--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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1"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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1").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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1',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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1"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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1")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 - Get asset type by id
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/{asset_type_id} \-H "Authorization: Bearer {access_token}"
Example response(s)
200 OK
// Status 200 OK{"asset_type": {"created_by_user_id": 19837362232,"description": null,"display_icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","external_id": null,"field_keys": ["imei","phone_number"],"hierarchy_depth": 2,"icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","id": "01K9BT5X539BKC8SEF430HAJHJ","is_standard": false,"name": "Mobile","parent_id": "01K9BT5SXPR60963HJVPWTZQHD","updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5X539BKC8SEF430HAJHJ"}}
Create Asset Type
POST /api/v2/it_asset_management/asset_types
Creates an asset type. To set an icon at the same time, send a
multipart/form-data request instead of JSON — see the "Create asset
type with a photo" code sample.
Allowed For
- Admins
Example body
{"asset_type": {"name": "Tablet","parent_id": "01K9BX5R6EAV3CH1J560S8SKHR"}}
Code Samples
Curl
curl --request POST https://example.zendesk.com/api/v2/it_asset_management/asset_types \--header "Content-Type: application/json" \-u {email_address}/token:{api_token} \--data-raw '{"asset_type": {"name": "Tablet","parent_id": "01K9BX5R6EAV3CH1J560S8SKHR"}}'
Go
import ("fmt""io""net/http""strings")func main() {url := "https://example.zendesk.com/api/v2/it_asset_management/asset_types"method := "POST"payload := strings.NewReader(`{"asset_type": {"name": "Tablet","parent_id": "01K9BX5R6EAV3CH1J560S8SKHR"}}`)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/it_asset_management/asset_types").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""{\"asset_type\": {\"name\": \"Tablet\",\"parent_id\": \"01K9BX5R6EAV3CH1J560S8SKHR\"}}""");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 data = JSON.stringify({"asset_type": {"name": "Tablet","parent_id": "01K9BX5R6EAV3CH1J560S8SKHR"}});var config = {method: 'POST',url: 'https://example.zendesk.com/api/v2/it_asset_management/asset_types',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/it_asset_management/asset_types"payload = json.loads("""{"asset_type": {"name": "Tablet","parent_id": "01K9BX5R6EAV3CH1J560S8SKHR"}}""")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,json=payload)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/it_asset_management/asset_types")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")request.body = %q({"asset_type": {"name": "Tablet","parent_id": "01K9BX5R6EAV3CH1J560S8SKHR"}})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 - Create asset type
For clarity, the example places the JSON in a separate file and imports it into the cURL statement. parent_id is optional — omit it to attach the new asset type directly to the base asset type.
my_asset_type.json
{"asset_type": {"name": "Tablet","parent_id": "01K9BXE24BP175Y9ZDJW2FV0KQ"}}
curl - Create asset type snippet
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types \-d @my_asset_type.json \-H "Content-Type: application/json" -H "Authorization: Bearer {access_token}" -X POST
curl - Create asset type with a photo
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types \-F "asset_type[name]=Tablet" \-F "asset_type[photo][uploaded_data]=@/path/to/image.jpg" \-H "Content-Type: multipart/form-data" -X POST \-H "Authorization: Bearer {access_token}"
Example response(s)
201 Created
// Status 201 Created{"asset_type": {"created_by_user_id": 19837362232,"description": null,"display_icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","external_id": null,"field_keys": ["imei","phone_number"],"hierarchy_depth": 2,"icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","id": "01K9BT5X539BKC8SEF430HAJHJ","is_standard": false,"name": "Mobile","parent_id": "01K9BT5SXPR60963HJVPWTZQHD","updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5X539BKC8SEF430HAJHJ"}}
422 Unprocessable Entity
// Status 422 Unprocessable Entity{"description": "Record validation errors","details": {"base": [{"description": "Duplicate ItamAssetType name detected: 'Tablet'. Names must be unique."}]},"error": "RecordInvalid"}
Update Asset Type
PATCH /api/v2/it_asset_management/asset_types/{asset_type_id}
Updates an existing asset type. All fields are optional. Your request should include only the properties you want to change.
The update will fail if you attempt to change the asset type's parent_id, the asset type's name isn't unique, the hierarchy depth limit would be exceeded, the asset type is one of the predefined standard asset types.
To set an icon, send a multipart/form-data request
instead of JSON — see the "Adding a photo to an asset type" code sample.
To remove an existing icon, send "photo": null in a normal JSON
request.
Allowed For
- Admins
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| asset_type_id | string | Path | true | The id of the asset type |
Example body
{"asset_type": {"name": "Tablet"}}
Code Samples
Curl
curl --request PATCH https://example.zendesk.com/api/v2/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1 \--header "Content-Type: application/json" \-u {email_address}/token:{api_token} \--data-raw '{"asset_type": {"name": "Tablet"}}'
Go
import ("fmt""io""net/http""strings")func main() {url := "https://example.zendesk.com/api/v2/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1"method := "PATCH"payload := strings.NewReader(`{"asset_type": {"name": "Tablet"}}`)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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""{\"asset_type\": {\"name\": \"Tablet\"}}""");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("PATCH", 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({"asset_type": {"name": "Tablet"}});var config = {method: 'PATCH',url: 'https://example.zendesk.com/api/v2/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1',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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1"payload = json.loads("""{"asset_type": {"name": "Tablet"}}""")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("PATCH",url,auth=auth,headers=headers,json=payload)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1")request = Net::HTTP::Patch.new(uri, "Content-Type": "application/json")request.body = %q({"asset_type": {"name": "Tablet"}})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 - Update asset type by id
For clarity, the example places the JSON in a separate file and imports it into the cURL statement
updated_asset_type.json
{"asset_type": {"name": "Tablet"}}
curl - Update asset type by id snippet
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/{asset_type_id} \-d @updated_asset_type.json \-H "Content-Type: application/json" -X PATCH \-H "Authorization: Bearer {access_token}"
curl - Adding a photo to an asset type
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/{asset_type_id} \-F "asset_type[photo][uploaded_data]=@/path/to/image.jpg" \-H "Content-Type: multipart/form-data" -X PATCH \-H "Authorization: Bearer {access_token}"
Example response(s)
200 OK
// Status 200 OK{"asset_type": {"created_by_user_id": 19837362232,"description": null,"display_icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","external_id": null,"field_keys": ["imei","phone_number"],"hierarchy_depth": 2,"icon_url": "https://{subdomain}.zendesk.com/system/record_photos/9812637451/large_1.png","id": "01K9BT5X539BKC8SEF430HAJHJ","is_standard": false,"name": "Mobile","parent_id": "01K9BT5SXPR60963HJVPWTZQHD","updated_by_user_id": 19837362232,"url": "https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/01K9BT5X539BKC8SEF430HAJHJ"}}
422 Unprocessable Entity
// Status 422 Unprocessable Entity{"description": "Record validation errors","details": {"base": [{"description": "Parent ITAM AssetType may not be updated after creation."}]},"error": "RecordInvalid"}
Delete Asset Type
DELETE /api/v2/it_asset_management/asset_types/{asset_type_id}
Deletes an asset type with the specified id. The deletion will fail if the asset type is one of the predefined standard asset types, is a base asset type, has child asset types, has asset records, or still has custom field keys assigned to it.
Allowed For
- Admins
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| asset_type_id | string | Path | true | The id of the asset type |
Code Samples
Curl
curl --request DELETE https://example.zendesk.com/api/v2/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1 \--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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1"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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1").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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1',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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1"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/it_asset_management/asset_types/01K9AMAY0ST7VTVSG7SDAMR4P1")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
curl - Delete asset type by id
curl https://{subdomain}.zendesk.com/api/v2/it_asset_management/asset_types/{asset_type_id} \-X DELETE \-H "Authorization: Bearer {access_token}"
Example response(s)
204 No Content
// Status 204 No Contentnull
422 Unprocessable Entity
// Status 422 Unprocessable Entity{"description": "Record validation errors","details": {"base": [{"description": "Base Asset Type cannot be deleted."}]},"error": "RecordInvalid"}