Skip to content

Create or update a contact

PUT
/workspaces/{workspace}/contacts/{contact}
curl --request PUT \
--url https://api.sendtruss.com/v1/workspaces/example/contacts/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "email": "hello@example.com", "attributes": { "additionalProperty": "example" }, "tags": [ "example" ], "locale": "example", "marketing": { "state": "subscribed", "at": "example" }, "pixel_consent_at": "2026-04-15T12:00:00Z" }'

Address the contact as ref: plus your own id for the person: it is created if the reference is new (201) and updated if not (200). By our id it only updates, and an unknown id is a 404. A field you leave out is left as it is, so a sync can send only what changed.

workspace
required
string
/^(?:[0-9A-Za-z]{26}|ref:[A-Za-z0-9._-]{1,128})$/

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.

contact
required
string
/^(?:[0-9A-Za-z]{26}|ref:[A-Za-z0-9._-]{1,128})$/

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.

Media typeapplication/json
object
email

The contact’s email address, unique in the workspace. Required when the contact is created.

string format: email
attributes

Values by attribute definition key. Only the keys you send change, null clears one, and a key with no definition is refused. A required attribute must be set when the contact is created and can’t be cleared.

object
key
additional properties
string | number | boolean | null
tags

The contact’s whole set of tags by name, at most 50. It replaces the tags the contact had; leave it out to keep them.

Array<string>
locale

A language tag such as en or pt-BR, which picks the translation a template sends.

string | null
marketing

Marketing consent: subscribed or unsubscribed, and at, the time the person gave or withdrew it, no later than now. A contact you never send it for gets no marketing email. A subscribed older than the contact’s latest opt-out is refused.

object
state
required
string
Allowed values: subscribed unsubscribed
at
required
string
pixel_consent_at

When the person agreed to open tracking, or null to withdraw it.

string | null format: date-time
Media typeapplication/json
string
Examplegenerated
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.

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.

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: not_found
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": "not_found"
}
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
Any of:
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: email_taken
contact
required

The contact in this workspace that already has the address: ref: plus its reference, or its id when it has none.

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": "email_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.