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.

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 protected]",
    "subject": "Subject",
    "body": "Email Content",
    "sender": "from me <[email protected]>",
    "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 protected]",
    "tpl": "tpl slug",
    "lang": "en",
    "sender": "from me <[email protected]>",
    "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.