API

Authenticationv1

Bearer tokens, scoped API keys, and best practices for securing your SendLib integration.

Bearer tokens

Every API request must include a bearer token in the Authorization header. Tokens are created in the SendLib dashboard and are tenant-scoped — each token belongs to exactly one account.

bash
curl -X POST https://api.sendlib.com/v1/transmissions \
  -H "Authorization: Bearer $SENDLIB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"recipients":[{"email":"user@example.com"}],"content":{"subject":"Test","text":"Hello"}}'

If the token is missing or invalid, the API returns 401 Unauthorized. If the token is valid but lacks the required scope for the endpoint, you'll receive 403 Forbidden.

Never expose keys client-side

API keys should only be used in server-side code. If you need client-side behavior (e.g. a contact form), build a backend endpoint that proxies the minimal action to SendLib.

Scoped keys

SendLib supports fine-grained permission scopes on API keys. In production, always prefer scoped keys so each service only gets the privileges it needs.

ScopeGrants access to
send:transmissionsCreate and send transmissions
read:eventsQuery message and transmission events
manage:webhooksCreate, update, delete, and test webhooks
manage:sending-domainsDomain verification and DNS management
manage:templatesCreate and update stored templates
manage:suppressionsAdd/remove suppression rules
manage:api-keysCreate additional API keys
manage:smtp-credentialsCreate SMTP credentials
manage:ip-poolsManage IP pool assignments
manage:pacingConfigure pacing and warmup policies

Creating a scoped key

bash
curl -X POST https://api.sendlib.com/v1/api-keys \
  -H "Authorization: Bearer $SENDLIB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"prod-sender","scopes":["send:transmissions","read:events"]}'

Keys are shown once

The raw API key value is only returned at creation time. Store it immediately in a secret manager (AWS Secrets Manager, Vault, 1Password, etc.). You cannot retrieve it again.

Key rotation

Rotate keys regularly — at minimum quarterly, or immediately if a key may have been exposed.

  1. Create a new key with the same scopes.
  2. Deploy the new key to your services.
  3. Verify traffic is flowing on the new key (check X-Request-ID headers in logs).
  4. Delete the old key from the dashboard.

Zero-downtime rotation

SendLib accepts any valid key for your tenant. Deploy the new key alongside the old one, then remove the old key after confirming the cutover. There's no invalidation window.

SMTP authentication

If you use SMTP instead of REST, authenticate with the SMTP credentials endpoint. SMTP credentials use standard AUTH LOGIN with the username and password returned at creation time.

bash
curl -X POST https://api.sendlib.com/v1/smtp-credentials \
  -H "Authorization: Bearer $SENDLIB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"prod-smtp"}'

Next