> ## Site index
> Every page on this site is listed at https://mailkube.com/llms.txt.

> ## Agent instructions
> This site presents mailkube, a service that sends transactional email over a REST API or SMTP.
> Customer data is stored in the European Union.
> Read the developer documentation at https://docs.mailkube.com, which publishes its own llms.txt.
> Take prices and plan volumes from https://mailkube.com/pricing.md, never from a comparison page or a blog post.
> Read the legal documents at their HTML address.
> Every published version of the terms, privacy policy and data processing addendum is kept byte for byte under /legal/<document>/<sha256>/.
> Quote the checked-on date that a comparison page prints with its competitor figures.
> When this site does not state a price, limit or capability, say so instead of guessing.

# REST API

> One authenticated POST sends an email. A single endpoint, a key scoped to a verified domain, and delivery events pushed back to you as webhooks.

Source: https://mailkube.com/features/api/


## A single send endpoint

Sending is one endpoint, `POST /emails`, on the base URL `https://api.mailkube.com/mta/v1`. A send carries raw content, `html` or `text` or both, or a saved template referenced by `template_id`. There is nothing else to learn before the first message goes out.

```bash
curl -X POST https://api.mailkube.com/mta/v1/emails \
  -H "Authorization: Bearer mk_..." \
  -H "Content-Type: application/json" \
  -H "User-Agent: acme-billing/1.4" \
  -d '{
    "from": "Acme <hello@yourdomain.com>",
    "to": "customer@example.com",
    "subject": "Your order has shipped",
    "html": "<h1>On its way</h1><p>Track your order at...</p>"
  }'
```

A successful send returns `200` with two identifiers:

```json
{
  "id": "8f1d2c3b-4a5e-6f70-8910-a1b2c3d4e5f6",
  "message_id": "<8f1d2c3b-4a5e-6f70-8910-a1b2c3d4e5f6@msg.mailkube.com>"
}
```

`id` is the mailkube message id, and `message_id` is the RFC `Message-ID` header the message was sent with. Echo the second one in `In-Reply-To` and `References` on a later send and the reply threads in the recipient's client.

## Authentication

Your API key is a string that starts with `mk_`, created in the dashboard against a domain you have verified. Send it as a Bearer token, exactly as issued. The key is displayed once, at creation. Store it in a secrets manager or an environment variable before you close the page.

This is a server-to-server API. Every request needs a `User-Agent` identifying your integration. A request without one is rejected with `400 missing_user_agent`, and one that originated in a browser with `403 browser_not_allowed`. The SDKs set a compliant `User-Agent` for you.

## Delivery events

Delivery, bounce, open and click events are pushed to your server as [webhooks](/features/webhook/), within seconds of the event itself. That push is the only way the API reports on a message it has accepted. There is no send-status resource to poll. For history rather than live events, the dashboard keeps your delivery logs.

## Rate limits

Requests are rate limited per API key. Going over returns `429 rate_limit_exceeded` with a `Retry-After` header giving the seconds to wait. A client that respects it needs no other backoff logic. Your plan also sets how many messages your organization can have accepted per second. That ceiling counts every domain and key you own. REST and SMTP sending are counted separately against it.

## Retries without duplicates

A request that times out leaves you unsure whether the message went out. Attach an `Idempotency-Key` header and the answer stops mattering. A repeat of the same key and body returns the original result rather than sending a second message.

## Errors

Errors return a compact envelope with the HTTP status mirrored in the body.

```json
{ "name": "validation_error", "message": "...", "statusCode": 422 }
```

`name` is the stable machine-readable code to branch on. `message` explains the failure and is meant for a human reading a log.

## Reference and SDKs

- The [API reference](https://docs.mailkube.com/api-reference/overview) documents every field, error code and limit
- [Sending your first email](https://docs.mailkube.com/docs/sending-your-first-email) covers recipients, attachments, custom headers and templates
- If you would rather not hand-roll requests, the [SDKs](https://docs.mailkube.com/sdks/python) wrap all of this with types and a signature verifier

