Add tags to a contact
const url = 'https://api.sendtruss.com/v1/workspaces/example/contacts/example/tags';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"tags":["example"]}'};
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/workspaces/example/contacts/example/tags \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "tags": [ "example" ] }'By name. Tags the contact already has stay, and adding one twice changes nothing. A name new to the workspace creates the tag.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The workspace: our id, or ref: plus your reference for it, such as ref:cust_4821. A reference is letters, digits, ., _ and -, up to 128 characters, and needs no URL encoding.
The contact: our id, or ref: plus your reference for the person, such as ref:guest_998. A reference is letters, digits, ., _ and -, up to 128 characters, and needs no URL encoding.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Tag names, at most 50.
Examplegenerated
{ "tags": [ "example" ]}Responses
Section titled “Responses”ContactResource
object
object
The marketing state: pending until you send consent, then subscribed or unsubscribed.
Marketing consent and when it was given or withdrawn, with who gave it: consented_by_key is the id of the API key that sent the latest accepted subscribed. Null until you send consent.
object
When the person agreed to open tracking, or null.
Values by attribute definition key; {} when the contact has none.
object
object
Examplegenerated
{ "data": { "id": "example", "reference": "example", "email": "example", "status": "example", "locale": "example", "marketing": { "state": "example", "at": "example", "consented_at": "example", "consented_by_key": "example" }, "pixel_consent_at": "example", "attributes": {}, "tags": [ { "id": "example", "key": "example", "name": "example", "color_code": "example" } ], "created_at": "example", "updated_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.
Nothing is at this path for your key. Another platform’s or another workspace’s resource answers the same as one that doesn’t exist.
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": "not_found"}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.