Email delivery
Get the files immediately by secure download, with a copy by email.
InterfacesAPI SpecSections
API Spec Designed
Base address: https://01scale.com/api/delivery/v1. Open an endpoint for its inputs, constraints, errors and samples.
POST/messagesSend a templated email to a user
An app's server asks Delivery to email one of its users, acting for that user. Delivery looks up the address, fills the template, sends it through Resend and retries if needed. Only a delegated token is accepted, so a browser can never send email in 01scale's name. Service
Scope: delivery:write, on a delegated token only
Inputs
Authorizationheaderstringrequired- Who receives it is the token's
sub. Delivery looks up their verified email from Identity at send time; apps never pass addresses. Bearer <delegated token>withdelivery:writeandact.templatebodystringrequired- Which email. Each template has fixed wording, a plain-text and an HTML version.
- In version 1,
order_paid. databodyobjectrequired- What fills the template. Links are paths, so an email can only point at 01scale.com.
- The template's fields only. For
order_paid:document_name(1 to 255 characters),amountandcurrency(minor units and code),link_path(a path on 01scale.com). referencebodystringrequired- The app's own label, for finding the message later.
- 1 to 200 characters.
Idempotency-Keyheaderstringrequired- The same key never sends a second email.
- 1 to 255 characters. DocFlow uses the Payment event's ID.
What it does
- Validates the template's data and records the message as
queued; answers202at once. - In the background: looks up the user's email through Identity
GET /api/identity/v1/users/{userId}with Delivery's own service token (identity:users.read), renders the template, and sends it through Resend fromreceipts@01scale.com. - On a failure Resend says is temporary, retries 3 times, after 1, 5 and 25 seconds. Then the message is
failedwith the reason, and Delivery announcesdelivery.message.failed. - On success the message is
sentwith Resend's message ID, anddelivery.message.sentis recorded in the audit log.
Responses
- 202Accepted.
message(statusqueued). - 422
unknown_templatetemplateis not one Delivery has. - 422
validation_faileddatais missing a field or has one the template does not use. - 422
idempotency_key_reusedSame key, different body. - 403
service_onlyThe token is not a delegated token: a browser session, an API key or a service acting as itself.
Sample request
POST /api/delivery/v1/messages HTTP/1.1
Authorization: Bearer <delegated token: the user, act service:docflow>
Idempotency-Key: evt_order_paid_0193b120
Content-Type: application/json
{
"template": "order_paid",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"data": {
"document_name": "acme-invoice-0042.pdf",
"amount": 500,
"currency": "USD",
"link_path": "/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/success"
}
}Sample response
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"message": {
"id": "0193b140-2b3c-7d4e-8f50-6172839a0b1c",
"app": "docflow",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"channel": "email",
"template": "order_paid",
"status": "queued",
"attempts": 0,
"last_error": null,
"sent_at": null,
"created_at": "2026-11-17T09:17:04Z"
}
}GET/messagesMy messages and their status
The signed-in person's messages, newest first. The success page uses it to show 'Email couldn't be sent' when a send failed. Signed in
Scope: delivery:read
Inputs
referencequerystringoptional- Only messages about this reference.
- Exact match.
cursor, limitquerystring, integeroptional- Paging.
limit1 to 100, default 20.
What it does
- Read only. Never returns the email address or the email's content: only template, status and times.
Responses
- 200Always, even when empty.
data[]of messages andnext_cursor. - 422
validation_failedA filter is not valid. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/delivery/v1/messages?reference=docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"data": [
{
"id": "0193b140-2b3c-7d4e-8f50-6172839a0b1c",
"app": "docflow",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"channel": "email",
"template": "order_paid",
"status": "sent",
"attempts": 1,
"last_error": null,
"sent_at": "2026-11-17T09:17:09Z",
"created_at": "2026-11-17T09:17:04Z"
}
],
"next_cursor": null
}POST/eventsReceive platform events
Where other services' signed events arrive. In version 1 Delivery acts on one: a user's account was deleted. Service
Scope: None: HMAC signature
Inputs
X-01scale-Signatureheaderstringrequired- Proves the event came from the platform.
- HMAC-SHA256 of the raw body, compared in constant time.
event_id, type, databodyuuid, string, objectrequired- The event.
- Processed once per
event_id; acts onidentity.user.deletedwith{user_id}.
What it does
- Cancels that user's queued messages and deletes their message records.
Responses
- 200Accepted, including a repeat or an ignored type. No body.
- 401
invalid_signatureThe signature is missing or wrong.
Sample request
POST /api/delivery/v1/events HTTP/1.1
X-01scale-Signature: sha256=8c1f...
Content-Type: application/json
{
"event_id": "0193b2aa-6f01-7c2d-9e3f-4a5b6c7d8e9f",
"type": "identity.user.deleted",
"occurred_at": "2026-11-17T10:00:00Z",
"data": {
"user_id": "0193a5b2-7c1e-7a3f-9b2d-4e6f8a1c2d3e"
}
}Sample response
HTTP/1.1 200 OKErrors
Every error has the same shape and a stable code to branch on.
{
"type": "https://01scale.com/errors/unknown_template",
"title": "Unknown template",
"status": 422,
"detail": "There is no template called order_shipped.",
"code": "unknown_template",
"request_id": "req_0193a61f9c2e"
}Handled without an endpoint
- The success page (DOCFLOW-V1-E7-01)
- DocFlow's page polls the Payment order for up to 30 seconds, then says 'We'll email you when it's ready'. It reads the email's status from
GET /messages. Designed with the DocFlow app shell. - Secure downloads (DOCFLOW-V1-E7-02)
- DocFlow's download endpoint checks ownership and the paid order, then redirects to a 5-minute Upload link and records
delivery.downloaded. Designed with the DocFlow app shell. - Events Delivery announces
delivery.message.sentanddelivery.message.failed, with{message_id, app, reference}.- Sending domain (DELIVERY-V1-E7-03 AC3)
- 01scale.com is verified in Resend with its SPF and DKIM DNS records. Setup steps belong in
docs/infra/when the service is built. - AI agents
GET /messagesis a tool on Delivery's MCP server. Sending is never offered to agents.- Health and contract
GET /healthandGET /openapi.jsonfrom the service template (SERVICEKIT-V1-E0-05).
Constraints at the API level
- Only an app's server can send; an idempotency key is required.
- Templates are fixed;
datamay hold only the template's fields; links are paths on 01scale.com. - A person sees only their own messages, without addresses or content.