Skip to the page

Authentication

Every request carries an API key. The key decides what the request may do.

Put the key in the Authorization header of every request.

HTTP
Authorization: Bearer os_...

Without a key, or with one that is wrong or revoked, the answer is 401 with the code unauthorized. To see who a key is and what it may do, ask for the account.

curl "$OPENSEND_API_URL/v1/account" \  -H "Authorization: Bearer $OPENSEND_API_KEY"
account.get
{  "object": "account",  "kind": "key",  "user": null,  "workspaces": [    {      "id": "ws_demo",      "name": "Acme Mail",      "role": null,      "current": true    }  ]}

What a key may do

A key has one of two levels of access. You choose it when you make the key.

  • full: every method of the API.
  • sending: sending email, and nothing else. It can also read the method catalog and its own account.

A sending key can be limited to one domain with domainId. It then sends from that domain only, and an email from another domain is refused with key_domain. Use one for each app that sends, so a leaked key can do little.

curl -X POST "$OPENSEND_API_URL/v1/api-keys" \  -H "Authorization: Bearer $OPENSEND_API_KEY" \  -H "Content-Type: application/json" \  -d '{  "name": "Marketing site",  "access": "sending"}'

Scopes

Every method needs one scope, named on its page in the reference. A request without it gets 403 with the code forbidden. The table lists each scope, whether a sending key has it, and which roles do.

Scope
emails:send
What it opens
Send an email or a batch, and move or cancel a scheduled email.
Sending key
Yes
Roles
owner, admin, member
Scope
emails:read
What it opens
Read sent emails and received emails.
Sending key
No
Roles
owner, admin, member, viewer
Scope
broadcasts:read
What it opens
Read broadcasts.
Sending key
No
Roles
owner, admin, member, viewer
Scope
broadcasts:write
What it opens
Write, send and delete broadcasts.
Sending key
No
Roles
owner, admin, member
Scope
audiences:read
What it opens
Read audiences and their contacts.
Sending key
No
Roles
owner, admin, member, viewer
Scope
audiences:write
What it opens
Add and delete audiences, and add, change and delete their contacts.
Sending key
No
Roles
owner, admin, member
Scope
templates:read
What it opens
Read templates.
Sending key
No
Roles
owner, admin, member, viewer
Scope
templates:write
What it opens
Write, publish and delete templates.
Sending key
No
Roles
owner, admin, member
Scope
automations:read
What it opens
Read automations and their runs.
Sending key
No
Roles
owner, admin, member, viewer
Scope
automations:write
What it opens
Write, publish, test, pause, resume and delete automations, enrol people and cancel runs.
Sending key
No
Roles
owner, admin, member
Scope
metrics:read
What it opens
Read the metrics.
Sending key
No
Roles
owner, admin, member, viewer
Scope
domains:read
What it opens
Read domains and their DNS records.
Sending key
No
Roles
owner, admin, member, viewer
Scope
domains:write
What it opens
Add, verify, change and delete domains.
Sending key
No
Roles
owner, admin
Scope
api_keys:read
What it opens
List the API keys. A key itself is never shown again.
Sending key
No
Roles
owner, admin, member, viewer
Scope
api_keys:write
What it opens
Make and revoke API keys.
Sending key
No
Roles
owner, admin
Scope
webhooks:read
What it opens
Read webhooks and their deliveries.
Sending key
No
Roles
owner, admin, member, viewer
Scope
webhooks:write
What it opens
Add, change, test and delete webhooks.
Sending key
No
Roles
owner, admin
Scope
logs:read
What it opens
Read the request logs.
Sending key
No
Roles
owner, admin, member, viewer
Scope
workspace:read
What it opens
Read the workspace, its members, the plans and the invoices, and ask the assistant.
Sending key
No
Roles
owner, admin, member, viewer
Scope
workspace:write
What it opens
Change the workspace, its members and its plan.
Sending key
No
Roles
owner, admin
Scope
methods:read
What it opens
Read the method catalog.
Sending key
Yes
Roles
owner, admin, member, viewer
Scope
account:read
What it opens
Read who the caller is.
Sending key
Yes
Roles
owner, admin, member, viewer
Scope
suppressions:read
What it opens
Read the suppression list.
Sending key
No
Roles
owner, admin, member, viewer
Scope
suppressions:write
What it opens
Put an address on the suppression list, or take one off.
Sending key
No
Roles
owner, admin
Scope
events:read
What it opens
Read the events and the latest times each was sent.
Sending key
No
Roles
owner, admin, member, viewer
Scope
events:write
What it opens
Send events, and define, change and delete them.
Sending key
No
Roles
owner, admin, member
Scope
imports:read
What it opens
Read the imports and their reports.
Sending key
No
Roles
owner, admin, member, viewer
Scope
imports:write
What it opens
Look into another account, start an import from it and cancel one.
Sending key
No
Roles
owner, admin
Scope
images:read
What it opens
Read the images that were copied or uploaded and where each is served.
Sending key
No
Roles
owner, admin, member, viewer
Scope
images:write
What it opens
Copy an image from its address, upload one, and delete one.
Sending key
No
Roles
owner, admin, member

People and roles

A person signed in to the dashboard calls the same methods with the scopes of their role.

  • owner and admin: everything.
  • member: reads everything, and writes emails, broadcasts, audiences, templates, automations and events.
  • viewer: reads everything and changes nothing.

A few methods answer a signed-in person only, and refuse every key: closing the workspace, and the kept chats of the assistant. Their pages in the reference say so.

Keeping a key safe

  • A key is shown once, when it is made. Only a hash of it is stored, so it cannot be read again.
  • Keep it on a server. A key in a browser or an app can be read by anyone who has the app.
  • Revoke a key the moment it may have leaked. It stops working at once.
  • The logs list every request a key made, so you can see what a key was used for.
curl -X DELETE "$OPENSEND_API_URL/v1/api-keys/key_03" \  -H "Authorization: Bearer $OPENSEND_API_KEY"