API keys
Every request to https://api.mesend.co carries Authorization: Bearer <key>. A key belongs to one project and sees only that project's data.
Permissions
| Permission | Can do |
|---|---|
full_access | Everything the API offers. This is the default for a new key. |
sending_access | Only POST /emails and POST /emails/batch. Any other call answers 401 restricted_api_key. |
support | Read-only: list and read emails, received emails and domains. It cannot send. Support keys are issued by the project operator, not over the API. |
Use a sending-only key in the application that sends mail, so a leaked key cannot read your email log or change your configuration.
Create a key
curl https://api.mesend.co/api-keys \
-H "Authorization: Bearer $ME_SEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Production sender","permission":"sending_access"}'
The response is { "id": "...", "token": "re_..." }. The token is shown once: only a SHA-256 hash is stored, so a lost key cannot be recovered, only replaced. name is required and at most 50 characters.
Restrict a key to one domain
A sending_access key can carry a domain_id. It may then send only from that domain; a send from any other domain answers 403 validation_error.
{ "name": "Billing mailer", "permission": "sending_access", "domain_id": "<domain id>" }
domain_id is refused on a full_access key and must be a domain of this project.
Manage keys
GET /api-keyslists keys withid,name,permission,domain_id,created_atandlast_used_at(never the token).PATCH /api-keys/:idwith{ "name": "..." }renames a key.DELETE /api-keys/:idrevokes it at once.
Managing keys needs a full_access key. An OAuth access token cannot create or delete keys or domains.
What an invalid key returns
| Situation | Response |
|---|---|
No Authorization header | 401 missing_api_key |
| Unknown key on a send endpoint | 401 validation_error |
| Unknown key anywhere else | 400 validation_error |
| Sending-only key on a non-send endpoint | 401 restricted_api_key |
OAuth for apps
An app can act on one project without being given a key. See CLI, MCP server and SMTP.