Skip to content

Create an attribute definition

POST
/attribute-definitions
curl --request POST \
--url https://api.sendtruss.com/v1/attribute-definitions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "key": "example", "name": "example", "type": "string", "required": true }'

A contact can only carry attributes that have a definition. Every workspace shares the definition, and a template reads its value as {{ attributes.<key> }}.

Media typeapplication/json
object
key
required

How the API and templates name the attribute: lowercase letters, digits and _, up to 64 characters.

string
/^[a-z0-9_]{1,64}$/
name
required

A label for people.

string
<= 128 characters
type
required
AttributeType

What its values are. A contact’s value is checked and stored as this type.

string
Allowed values: string number boolean date
required

Whether a contact must have a value for it when it is created. Defaults to false.

boolean

AttributeDefinitionResource

Media typeapplication/json
object
data
required
AttributeDefinitionResource
object
key
required
string
name
required
string
type
required
string
required
required
boolean
created_at
required
string | null
Examplegenerated
{
"data": {
"key": "example",
"name": "example",
"type": "example",
"required": true,
"created_at": "example"
}
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

The API key is missing, malformed, revoked or expired.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: unauthenticated
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "unauthenticated"
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

Refused because of the resource’s current state. The code says why.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: key_taken
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "key_taken"
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

The request is invalid. The code says why, and errors names each field at fault.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: validation_failed
errors
required

Each field that failed validation, by its path in the request, with its messages.

object
key
additional properties
Array<string>
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "validation_failed"
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

Too many requests. Wait for the seconds in Retry-After.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: rate_limited
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "rate_limited"
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

Retry-After
integer

Seconds to wait before trying again.