Create a custom field definition
curl --request POST \
--url https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions"
payload = {}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "custom_field_definition",
"attributes": {
"entity_type": "Shipment",
"api_slug": "<string>",
"display_name": "<string>",
"data_type": "short_text",
"description": "<string>",
"reference_type": "<string>",
"validation": {},
"default_format": "<string>",
"default_value": "<string>",
"reference_number": true,
"sensitive": true,
"inline_option_creation": true,
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"has_data": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"discarded_at": "2023-11-07T05:31:56Z"
},
"relationships": {
"account": {
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "account"
}
},
"created_by": {
"data": {
"type": "user",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
},
"options": {
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "custom_field_option"
}
]
}
}
},
"links": {
"self": "<string>"
}
}{
"errors": [
{
"status": "404",
"title": "Not Found"
}
]
}{
"errors": [
{
"status": "422",
"source": {
"pointer": "/data/attributes/label"
},
"title": "Unprocessable Entity",
"detail": "Label can't be blank",
"code": "blank"
}
]
}Custom Field Definitions
Create an account custom field definition
Create a custom field definition on your Terminal49 account to attach structured metadata, like reference codes or enums, to shipments and containers.
POST
/
accounts
/
{account_id}
/
custom_field_definitions
Create a custom field definition
curl --request POST \
--url https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions"
payload = {}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.terminal49.com/v2/accounts/{account_id}/custom_field_definitions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "custom_field_definition",
"attributes": {
"entity_type": "Shipment",
"api_slug": "<string>",
"display_name": "<string>",
"data_type": "short_text",
"description": "<string>",
"reference_type": "<string>",
"validation": {},
"default_format": "<string>",
"default_value": "<string>",
"reference_number": true,
"sensitive": true,
"inline_option_creation": true,
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"has_data": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"discarded_at": "2023-11-07T05:31:56Z"
},
"relationships": {
"account": {
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "account"
}
},
"created_by": {
"data": {
"type": "user",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
},
"options": {
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "custom_field_option"
}
]
}
}
},
"links": {
"self": "<string>"
}
}{
"errors": [
{
"status": "404",
"title": "Not Found"
}
]
}{
"errors": [
{
"status": "422",
"source": {
"pointer": "/data/attributes/label"
},
"title": "Unprocessable Entity",
"detail": "Label can't be blank",
"code": "blank"
}
]
}Creates a custom field definition on your account. The API always creates the definition on the authenticated user’s account, whatever
account_id you pass.
Request body
Sendtemplate_id, or all of entity_type, api_slug, display_name and data_type.
| Parameter | Required | Description |
|---|---|---|
entity_type | Without template_id | The entity type this field applies to: Shipment or Cargo (containers). Other values return 422. |
api_slug | Without template_id | Unique identifier for the field |
display_name | Without template_id | Human-readable name for the field |
data_type | Without template_id | Data type for values (for example: short_text, number, date, reference) |
template_id | No | ID of a Terminal49 template definition to copy. The template supplies entity_type, api_slug, display_name, data_type and the other attributes. Attributes you send override the template’s values. An unknown template_id returns 404. |
description | No | Optional description of the field’s purpose |
validation | No | Validation rules (for example: required, pattern, max_length) |
default_format | No | Default format string for numbers or dates |
default_value | No | Default value for new custom fields |
reference_type | No | Required when data_type is reference |
reference_number | No | Whether values are reference numbers. Terminal49 indexes reference-number values for global search and document matching. Defaults to false. |
sensitive | No | Whether the field is sensitive. Sensitive fields are hidden from recipients of externally shared container views. Defaults to false. |
inline_option_creation | No | Whether users can add a new option while entering an enum or enum_multi value in the Terminal49 app. Defaults to false. |
Authorizations
Use a Terminal49 API key in the Authorization header with the Token prefix.
Authorization: Token YOUR_API_KEY
Path Parameters
Your account ID. The API always uses the account of the authenticated user.
Body
application/json
Show child attributes
Show child attributes
Was this page helpful?