API v1 overview
The management API for coding agents and scripts - keys, errors, test sends, idempotency, pages.
API v1 manages one project's templates, triggers and automations under /api/v1/. It is what the Senlo MCP server and coding agents use; any script can call it too. Sending stays on /api/triggered and /api/events.
The full reference is generated from the code: /api/v1/openapi.json.
Building an agent or a script that writes content? Start with GET /api/v1/guide (public): the rules of the design document and the automation export in prose, their JSON Schemas, every block type with a valid starting value, every automation step type, and examples that pass the API's checks. It is the same text Senlo's own AI uses.
Keys
Every request needs an API key with the manage permission (see Authentication):
Authorization: Bearer snl_your_api_key
Senlo-Client: my-script/1.0Senlo-Client is optional: a label for your client that shows in the audit log and in template history. A key acts on its own project only. GET /api/v1/me shows which one, and is the quickest way to check a connection.
Responses
Success is { "data": ... }. A failure is:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "design.rows[0].columns[0].blocks[1].props.href: Invalid url",
"hint": "Fix the fields listed in issues and send the request again.",
"issues": [
{ "path": "design.rows[0].columns[0].blocks[1].props.href", "code": "invalid_string", "message": "Invalid url" }
],
"requestId": "req_7f3c..."
}
}hintsays what to do next; it is written so a coding agent can fix the request on its own.issueslists every invalid field with its full path (at most 20;issueCountcounts them all).requestIdis also in theX-Request-Idheader of every response. Quote it when asking for support.
| Status | code | When |
|---|---|---|
400 | VALIDATION_ERROR | The body or a parameter is invalid. |
400 | UNKNOWN_FIELD | The body has a field the operation does not take (often a typo). |
401 | UNAUTHORIZED | No key, or a wrong one. |
402 | QUOTA_EXCEEDED | Cloud: a plan limit is reached. |
403 | PERMISSION_REQUIRED | The key has no manage permission. |
403 | RECIPIENT_NOT_ALLOWED | A test send to an address outside the organization (below). |
404 | NOT_FOUND | No such record in the key's project. |
409 | IDEMPOTENCY_KEY_REUSED, IDEMPOTENCY_IN_PROGRESS | See Idempotency below. |
409 | NOT_PUBLISHABLE | An automation cannot run as it is; details.reasons lists why. |
429 | RATE_LIMITED | More than 300 requests a minute for this key; wait Retry-After seconds. |
502 | PROVIDER_ERROR | The email provider refused a test send; its reason is in the message. |
500 | INTERNAL_ERROR | Something failed on Senlo's side; retry with backoff. |
Checking without saving
Creating and changing operations take ?dryRun=true: the request is checked exactly as it would be, nothing is stored, and a valid one answers { "data": { "valid": true, "warnings": [] } }.
Test sends
Only to your organization
Test emails through the API go only to members of the project's organization. On a self-hosted instance that is the project owner's address. Any other address is refused with 403 RECIPIENT_NOT_ALLOWED, and details.allowed lists the addresses that work. An agent therefore cannot mail your customers or strangers. Test sends from the editor are not limited.
A test is a real send through the project's provider: it counts toward the plan like any email.
Idempotency
Creating operations take an Idempotency-Key header (any unique string up to 255 characters, such as a UUID):
- the same key with the same body within 24 hours answers with the first response, with
Idempotent-Replayed: true, and creates nothing twice; - the same key with another body is
409 IDEMPOTENCY_KEY_REUSED; - while the first request is still running, a retry gets
409 IDEMPOTENCY_IN_PROGRESSwithRetry-After: 1; - only successful answers are kept: after an error, fix the request and send it again with the same key.
Pages
Lists answer { "data": { "items": [...], "nextCursor": "..." } }, newest first. Pass ?cursor=<nextCursor> for the next page and ?limit= (1 to 100, default 50) for its size. nextCursor is null on the last page.