Create an attribute definition
const url = 'https://api.sendtruss.com/v1/attribute-definitions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"key":"example","name":"example","type":"string","required":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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> }}.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
How the API and templates name the attribute: lowercase letters, digits and _, up to 64 characters.
A label for people.
What its values are. A contact’s value is checked and stored as this type.
Whether a contact must have a value for it when it is created. Defaults to false.
Responses
Section titled “Responses”AttributeDefinitionResource
object
object
Examplegenerated
{ "data": { "key": "example", "name": "example", "type": "example", "required": true, "created_at": "example" }}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
The API key is missing, malformed, revoked or expired.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "unauthenticated"}Headers
Section titled “Headers”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.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "key_taken"}Headers
Section titled “Headers”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.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
Each field that failed validation, by its path in the request, with its messages.
object
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "validation_failed"}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
Too many requests. Wait for the seconds in Retry-After.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "rate_limited"}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
Seconds to wait before trying again.