Skip to content

Emit an event

POST
/workspaces/{workspace}/events
curl --request POST \
--url https://api.sendtruss.com/v1/workspaces/example/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "type": "example", "idempotency_key": "example", "recipient": { "contact": "example", "email": "example" }, "payload": { "additionalProperty": "example" }, "attachments": [ { "filename": "example", "content": "example" } ] }'

Tell us something happened for one recipient. When the event type has a default template, we render it with the payload and send it from your domain; either way the event is recorded. The answer says what became of the email: queued, or suppressed when the address is suppressed.

The idempotency key makes a retry safe: the same key with the same body answers with the first response and the Idempotent-Replayed header, without sending again. A refused emit records nothing, its key included, so you can fix it and send it with the same key.

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.

Media typeapplication/json
object
type
required

The event type’s name, as you registered it.

string
idempotency_key
required

Your unique key for this event, up to 255 printable ASCII characters, no spaces.

string
recipient
required

Who the event is for: a contact in the workspace, by our id or as ref: plus your reference, or an email address. Exactly one of the two.

object
contact
string
email
string
payload
required

The event’s fields, checked against its type’s schema. Send {} for a type with no fields.

object
key
additional properties
attachments

Files to attach to the email, at most 10 and 10,000,000 bytes in all once decoded. Each content is base64. PDF, PNG, JPEG, GIF, WebP and iCalendar files are accepted, and the file name’s extension must match its content.

Array<object>
object
filename
required
string
content
required
string
Examplegenerated
{
"type": "example",
"idempotency_key": "example",
"recipient": {
"contact": "example",
"email": "example"
},
"payload": {
"additionalProperty": "example"
},
"attachments": [
{
"filename": "example",
"content": "example"
}
]
}

The recorded event, and the email it sent, or null in message when the type has no default template.

Media typeapplication/json
object
data
required
object
id
required
string
type
required
string
idempotency_key
required
string
contact
required
object
id
required
string
reference
required
string | null
message
required
object
id
required
string
state
required
string
Allowed values: queued suppressed
template_version_id
required
string
fell_back
required
Array<string>
simulated
required
boolean
created_at
required
string
Example
{
"data": {
"message": {
"state": "queued"
}
}
}
Idempotent-Replayed
string

Present, as true, when this is the stored answer to an earlier emit with the same key.

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
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: idempotency_key_reused workspace_suspended domain_not_sendable
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": "idempotency_key_reused"
}
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 recipient_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.