Docs / Using API

Sending email over the API

Postwing exposes a small REST API over HTTPS. Send a single POST request to api.postwing.app and the message goes out — no SDK or SMTP client required. There are two endpoints: send a ready-made message (raw), or render and send one of your saved templates.

You can get them on the token management page. For security reasons, a token is shown only once — at the moment it is created.

Authentication uses the same domain token as the SMTP relay — pass it in the auth object on every request (username and password). Set an idempotency_key to make retries safe: repeating a request with the same key never sends a duplicate. The endpoints respond with ok: true on success, or error_code and error describing what went wrong.

This credential is for sending only. The domain token authenticates one domain on the /external/ endpoints and the SMTP relay, and is passed in the request body. The account API under /api/ — domains, templates, webhooks, logs, inbound messages and their attachments — is a different scheme: an Authorization header carrying your account token, which lives on Dashboard → Profile.

Postwing assigns each message its own Message-ID (<uuid@yourdomain.com>) and returns it — that is the id every delivery webhook reports. You cannot set your own: the accepted extra headers are In-Reply-To, References, Reply-To and any X- header, and anything else is refused.

Send Raw Email

Sending email without processing on the API side. Use it to send HTML emails to your customers

POST/external/send_email_simple/
Request Payload
json
{
    "recipient": "email@test.com",
    "subject": "Subject",
    "body": "Email Content",
    "sender": "from me <email@test.com>",
    "idempotency_key": "xxxxxx",
    "auth": {
        "username": "Username",
        "password": "Password"
    }
}
Response Payload
json
{
    "ok": true,
    "error_code": "error code",
    "error": "error details"
}

Send Template Email

Sending generated email from specific template. You will need to provide used placeholders in template and specify the language.

POST/external/send_email_tpl/
Request Payload
json
{
    "recipient": "email@test.com",
    "tpl": "tpl slug",
    "lang": "en",
    "sender": "from me <email@test.com>",
    "idempotency_key": "xxxxxx",
    "params": {
        "prop1": "value"
    },
    "auth": {
        "username": "Username",
        "password": "Password"
    }
}
Response Payload
json
{
    "ok": true,
    "error_code": "error code",
    "error": "error details"
}
Attention!
When using BCC, CC - a separate email will be created for each recipient in the system and your limits will be used.