# Request paths

> A send, a bounce and an inbound message, step by step.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://mail.docs.sypnia.com/architecture/request-paths/

For agents: Mail request paths: send — POST /v1/emails checks key/scope/domain/suppression/size/limits in one transaction, stores queued + rendered body, 202; sender polls queue FOR UPDATE SKIP LOCKED per project token bucket, builds MIME, tracking, SendRawEmail with configuration set, stores SES id, status sent; throttles retried with backoff, rejected after 24 h. Bounce — SES → SNS → SQS → event receiver finds e-mail by SES id, records bounced, hard bounce suppressed, webhook dispatcher. Inbound — SES receipt rule stores raw in S3, notifies engine, parser checks verdicts, matches rule, stores attachments, calls webhook/Run/forward.

## A send

1. `POST /v1/emails` reaches the engine; it checks the key and its scope, the `from` domain, the suppression list, the size, and the project's rate and daily limits in one transaction.
2. It stores the e-mail with status `queued` and its rendered body (or renders it now if the template's data is given), and answers `202`.
3. The sender takes e-mails from the queue with `FOR UPDATE SKIP LOCKED`, per project and at the pace the project's token bucket allows.
4. It builds the MIME message, adds tracking if on, and calls `SendRawEmail` with the domain's configuration set. The SES message id is stored; status `sent`.
5. If SES answers with a throttle or a temporary error, the e-mail goes back to the queue with backoff; after 24 hours it becomes `rejected`.

## A bounce

1. The recipient's server refuses the message; SES publishes a bounce to an SNS topic, which writes it to an SQS queue.
2. The event receiver reads the queue, finds the e-mail by the SES message id, records `bounced` with the reason, and for a hard bounce adds the address to the project's suppression list.
3. The webhook dispatcher sends the event to every webhook subscribed to `bounced`.

## An inbound message

1. SES receives the message for an address whose `MX` points to it, stores the raw message in S3 and notifies the engine.
2. The inbound parser reads it, checks spam and virus verdicts, finds the matching rule, stores attachments and calls the webhook or Run function, or forwards it.
