Skip to content
SendPier

Developers

Your first email in one request

Pick HTTPS or SMTP, put your key in a settings file on your server and send. This page has the full example in four languages, with the answer you get back.

The addresses

  • Send API

    POST to api.sendpier.com/v1/messages. You get a 202 back.

  • SMTP

    smtp.sendpier.com on port 587, with STARTTLS.

  • Status page

    status.sendpier.com is public and asks for no key.

Sending one message

Four languages, the same request. These come from the example files in the knowledge base, trimmed to what you put in your own code.

cURL

#!/usr/bin/env bash
set -euo pipefail

antwoord=$(curl -sS -X POST "https://api.sendpier.com/v1/messages" \
  -H "Authorization: Bearer ${SENDPIER_API_KEY}" \
  -H "X-Domain-Name: yourdomain.com" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -w '\n%{http_code}' \
  -d '{
    "from": { "email": "noreply@yourdomain.com" },
    "to": [{ "email": "recipient@example.org" }],
    "subject": "Hello from the Send API",
    "text": "This works.",
    "html": "<p>This works.</p>"
  }')

status=$(printf '%s' "$antwoord" | tail -n1)
body=$(printf '%s' "$antwoord" | sed '$d')

echo "$body"
[ "$status" = '202' ] || { echo "HTTP $status" >&2; exit 1; }

PHP

<?php

$body = json_encode([
    'from'    => ['email' => 'noreply@yourdomain.com'],
    'to'      => [['email' => 'recipient@example.org']],
    'subject' => 'Hello from the Send API',
    'text'    => 'This works.',
], JSON_THROW_ON_ERROR);

$ch = curl_init('https://api.sendpier.com/v1/messages');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => $body,
    CURLOPT_TIMEOUT        => 30,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer '.getenv('SENDPIER_API_KEY'),
        'X-Domain-Name: yourdomain.com',
        'Content-Type: application/json',
        'Accept: application/json',
    ],
]);

$raw    = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if ($status !== 202) {
    // Log altijd allebei: de code zegt wát, de body zegt waaróm.
    throw new RuntimeException("SendPier HTTP {$status}: {$raw}");
}

foreach (json_decode($raw, true)['data'] as $bericht) {
    echo $bericht['id'], ' -> ', $bericht['to'], PHP_EOL;
}

Node.js

const antwoord = await fetch('https://api.sendpier.com/v1/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SENDPIER_API_KEY}`,
    'X-Domain-Name': 'yourdomain.com',
    'Content-Type': 'application/json',
    Accept: 'application/json',
  },
  body: JSON.stringify({
    from: { email: 'noreply@yourdomain.com' },
    to: [{ email: 'recipient@example.org' }],
    subject: 'Hello from the Send API',
    text: 'This works.',
  }),
  signal: AbortSignal.timeout(30_000),
});

const raw = await antwoord.text();

if (antwoord.status !== 202) {
  // 429 en 503 mag je opnieuw proberen, met oplopende wachttijd.
  throw new Error(`SendPier HTTP ${antwoord.status}: ${raw}`);
}

for (const bericht of JSON.parse(raw).data) {
  console.log(bericht.id, '->', bericht.to);
}

Python

import json, os, urllib.error, urllib.request

payload = json.dumps({
    "from": {"email": "noreply@yourdomain.com"},
    "to": [{"email": "recipient@example.org"}],
    "subject": "Hello from the Send API",
    "text": "This works.",
}).encode()

verzoek = urllib.request.Request(
    "https://api.sendpier.com/v1/messages",
    data=payload,
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["SENDPIER_API_KEY"],
        "X-Domain-Name": "yourdomain.com",
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
)

try:
    with urllib.request.urlopen(verzoek, timeout=30) as antwoord:
        status, raw = antwoord.status, antwoord.read().decode()
except urllib.error.HTTPError as fout:
    # Een 4xx of 5xx is een antwoord, geen crash: de body zegt waarom.
    status, raw = fout.code, fout.read().decode("utf-8", "replace")

if status != 202:
    raise RuntimeError(f"SendPier HTTP {status}: {raw}")

for bericht in json.loads(raw)["data"]:
    print(bericht["id"], "->", bericht["to"])

The key above is an example value. Put your real key in a settings file on your server, such as .env, and never in the code you commit to version control.

Any sender address on a verified domain name can be used to send email

This page makes no request to the API itself. Nothing leaves your browser: you copy the code and run it on your own server.

All example files in the knowledge base

The answer

HTTP/1.1 202 Accepted

{
  "object": "list",
  "data": [
    {
      "object": "message",
      "id": "msg_5f1c9a0b7e2d43c8a1b6f0d9e4c73a25",
      "to": "recipient@example.org",
      "status": "queued"
    }
  ]
}

202 means accepted, not delivered. You get one identifier back per message, which you can use later to look up the status of that message.

Two identifiers, two purposes

msg_… is yours
It sits in the 202 answer. You look a message up with it, and you recognise it again in a webhook.
spid_… is ours
It travels along as X-SendPier-ID inside the email itself and appears in every webhook. This is the one support asks for.

Authentication in short

There are two kinds of key, each for a different API.

The domain key — for sending

Authorization: Bearer sp_live_YOUR_KEY
X-Domain-Name: yourdomain.com
  • The shape is sp_live_ plus 32 characters, and it belongs to one domain.
  • X-Domain-Name has to name that exact domain. If it does not match, you get a 403.
  • from.email lives on that same domain. If it does not, you get a 422 with param from.email.
  • Make one per integration. You revoke a key in the panel; a revoked key can still work for about a minute.

Never put a domain key in code a visitor can read. Whoever finds it there sends email in your name.

The account token — for management

You manage suppressed addresses and webhooks on cp.sendpier.com, with a token that belongs to your account rather than to a domain. A domain key does not work there, and the other way around either.

The status API — no key at all

status.sendpier.com is public.

Authentication and the two key types

Limits

If your integration goes too fast, a 429 follows. If your allowance is spent, the same.

120 requests per minute
Per key and per clock minute, not per IP address and not per account. Every request counts, a GET included.
10 recipients per request
That is the maximum, not a recommendation. With one recipient per request you know the status of every single message.
25 MB per message
Message plus attachments, measured as the real file size and so not as the longer base64 text, with at most 20 attachments. Anything bigger goes out as a download link.
500 messages per month per domain
The same on every plan; the plan itself covers your whole account. The first hundred accounts keep 1,000 permanently. Clipper and Fleet give bonus credits every month for your whole account: Clipper 1,000, Fleet 5,000. Above that you top up with credits.
A daily limit per domain that grows
Every domain name starts at 100 emails a day. That daily limit grows as long as your email arrives well. The day runs in UTC, universal time. Credits do not raise it. Go past it and you get a temporary refusal, not a bounce.
Ten failed sign-in attempts
Within five minutes from the same IP address you get a temporary 429 too_many_attempts. So stop your integration on a 401.

Rate limits in the knowledge base Reading your usage

Error codes: what you fix and what we fix

You fix a 4xx, we fix a 5xx. The only 4xx where waiting helps is 429.

202

What it means
Accepted and queued
Retry?
—

401

What it means
Key missing, wrong or revoked
Retry?
No

403

What it means
The key is valid, but not allowed to do this
Retry?
No

413

What it means
Your message is too large
Retry?
No

422

What it means
Something in your request is wrong
Retry?
No

429

What it means
Too many requests, or your allowance is spent
Retry?
Yes, after a wait

503

What it means
Something broke on our side
Retry?
Yes, after a wait

Two rules for a stable integration

  • Log the status code and the response body on every error. Without both, a problem cannot be traced afterwards.
  • Branch on code, not on message.

All status and error codes

SMTP if you prefer

The same infrastructure, the same limits and the same suppression list. Only the way you hand the message over is different.

Server
smtp.sendpier.com
Port
587
Encryption
STARTTLS
Login method
AUTH LOGIN
Username
sp_<number>_<characters>, per domain
  • Only port 587 works, other ports do not
  • Every domain has one active login. The password is readable once in the panel; after that you create a new one.
  • If your login belongs to a main domain, you may also send from its subdomains. The Send API does not allow that: there, X-Domain-Name has to be exactly the domain you verified.

See the SMTP page The SMTP connection in the knowledge base

Let statuses come to you

Do not ask for a status over and over in a loop: if you hit the request limit often, a webhook is probably handier than asking again and again. Fourteen events come to you: delivered, bounced, deferred, suppressed, opened, clicked and reported as spam, plus seven about your domain name: verified, a DNS problem and its recovery, a monthly limit almost or fully used, many bounces and a daily limit reached. Every notification is HMAC-signed, carries a fixed id so you recognise a duplicate, and is offered again with growing intervals when something fails.

See the webhooks page

Where to look next

  • API documentation

    The full reference: fields, endpoints, error codes.

    Open the API section

  • Example files

    Working scripts in cURL, PHP, Node.js and Python, ready to download.

    See the examples

  • Knowledge base

    Guides, error codes and examples, in Dutch and English.

    Open the knowledge base

  • Status page

    Availability per component, with a public JSON API and RSS.

    View the status

Send your first email

An account is free and stays free. You verify your domain, create a key and send.