Authentication
SendDock has two auth schemes for two audiences:
- API key (
Authorization: Bearer sk_...) — the primary way to integrate. Project-scoped. Use for backend code, transactional sends, CI scripts. - Cookie session (HttpOnly JWT) — used by the bundled dashboard SPA. Documented here in case you build your own UI on top of the same API.
Two more public endpoints have their own credentials (no Bearer header, no cookie):
- Webhook delivery signatures — outbound HTTP POSTs to your URL carry
X-SendDock-Signature: t=...,v1=.... Verify with HMAC-SHA256. See Webhooks guide → Verifying the signature. - Bounce webhook ingest —
POST /webhooks/bounces/{projectId}?token=...uses a per-project URL token. See Bounces API → Public ingest endpoint.
API key auth (recommended)
Pass the key in the Authorization header:
Authorization: Bearer sk_your_api_keyKeys are project-scoped — the key identifies the project, so the URL {id} segment is ignored when API-key auth is used. Create and revoke keys in Project → Settings → API Keys or via the API Keys API.
Endpoints that accept API keys
| Endpoint | What it does |
|---|---|
POST /api/v1/projects/{id}/send | Single transactional send (template or raw HTML). |
POST /api/v1/projects/{id}/send/batch | Same template, many recipients with per-recipient data. |
POST /api/v1/projects/{id}/broadcast | Send to every active subscriber. |
POST /api/v1/projects/{id}/subscribers/import | JSON array import with email validation. |
GET /api/v1/projects/{id}/stats | Read-only summary counts (total, sent, failed, bounced, suppressed, opened). |
Every other endpoint requires cookie auth — see the next section. As a rule of thumb: anything that mutates project, workspace, template, subscriber, webhook or audit-log state is cookie-only, because role-based capabilities key off the user identity that an API key doesn't carry. A key can exercise only a fixed allowlist of capabilities — send.transactional, broadcast and subscribers.write — so a capability outside it is refused even on an endpoint mounted for both auth schemes.
Errors
| Status | Body | Meaning |
|---|---|---|
401 | {"error":"missing or invalid api key"} | Header missing or malformed, or a key that doesn't match one in the database. |
401 | {"error":"invalid api key"} | Key revoked. |
403 | {"error":"this action is not permitted with an API key"} | The endpoint requires a capability outside the API key allowlist. |
403 | {"error":"your role does not allow this action"} | Cookie auth, and your role lacks the capability for this endpoint. |
Cookie session (dashboard SPA)
The bundled web dashboard uses HttpOnly JWT cookies. If you're building your own frontend against the same backend, you can use the same flow.
Login
POST /api/v1/auth/login{
"email": "[email protected]",
"password": "yourpassword"
}Sets an access_token (15 min lifetime) and refresh_token (2 hours) cookie, both HttpOnly and SameSite=Lax. Secure is set when the deployment's origin is https.
Refresh
POST /api/v1/auth/refreshNo body. The browser sends refresh_token automatically. Returns rotated cookies. The dashboard SPA calls this transparently when a 401 fires from an expired access token.
Logout
POST /api/v1/auth/logoutInvalidates the refresh token server-side and clears both cookies.
Get current user
GET /api/v1/me{
"user_id": "01H...",
"email": "[email protected]",
"name": "Your Name",
"plan": "pro",
"created_at": "2026-01-01T00:00:00Z"
}plan is "free", "pro" or "team" for self-host (from the license activated under Instance → License); on cloud it's "free", "starter", "growth" or "scale".
Change password
POST /api/v1/me/password{
"current_password": "...",
"new_password": "..."
}Verifies current_password with bcrypt, then validates new_password against the registration rules: min 8 chars, at least one uppercase, one digit, one special character. Returns 200 on success, 400 on weak new password, 401 on bad current password.
Changing the password revokes every outstanding refresh token, so all other sessions are logged out and their refresh attempts fail. The current access token keeps working until it expires (up to 15 minutes).
Two-factor authentication
TOTP with single-use recovery codes. See the dashboard-side flow in Your account & security → 2FA.
Begin setup
POST /api/v1/me/2fa/setupNo body. Response:
{
"otpauth_url": "otpauth://totp/SendDock:[email protected]?secret=...&issuer=SendDock",
"secret": "BASE32SECRET",
"recovery_codes": ["...", "...", "..."]
}Recovery codes are returned here and on Regenerate recovery codes — the dashboard stores them client-side, so persist them yourself or regenerate a fresh set later.
Confirm setup
POST /api/v1/me/2fa/verify{ "code": "123456" }Validates the 6-digit TOTP code against the secret from /setup. On success, 2FA is enabled on the account; subsequent logins require the second step. Returns 400 on wrong code.
Disable 2FA
POST /api/v1/me/2fa/disable{ "password": "...", "code": "123456" }code is either a valid TOTP code or a single-use recovery code. Both fields are required — no password, no code, no disable, and there is no admin override.
Regenerate recovery codes
POST /api/v1/me/2fa/recovery-codes{ "code": "123456" }Requires a valid TOTP code. Invalidates the existing set and returns ten fresh ones:
{ "recovery_codes": ["...", "...", "..."] }Login second step
When /api/v1/auth/login succeeds against an account with 2FA enabled, it returns 200 with requires_2fa: true and a two-factor token instead of setting session cookies:
{ "requires_2fa": true, "two_factor_token": "..." }Complete the login by posting to:
POST /api/v1/auth/2fa{ "two_factor_token": "...", "code": "123456" }code is a TOTP code or a recovery code. On success, session cookies are set the same way as a regular login. The two-factor token is short-lived (5 minutes) and only valid for this exchange.
Email-verified signup (Cloud)
On the managed cloud, accounts are created through a public signup endpoint and must verify their email before they can log in.
Sign up
POST /api/v1/auth/signup{ "email": "[email protected]", "password": "yourpassword", "name": "Your Name" }Creates the account as inactive and emails a verification link. Returns 201 with {"message":"Check your email to activate your account."}. The account cannot log in until the link is used. Rate-limited per IP and per email.
Verify email
POST /api/v1/auth/verify{ "token": "..." }The token comes from the emailed link (/auth/verify?token=...), valid for 24 h and single-use. On success the email is marked verified and, for signup, the session is started — login cookies are set in the same response.
Resend verification
POST /api/v1/auth/resend-verification{ "email": "[email protected]" }Re-sends the link to an unverified account. Returns 200 whether or not the account exists/needs activation, so you can't probe which emails are registered.
Self-hosted instances use the setup screen + admin Create user instead — there is no public signup endpoint in that mode.
Device confirmation (Cloud, login)
Logging in from a new device with no 2FA sends an email confirmation instead of a normal login.
Login (new device)
When POST /api/v1/auth/login succeeds but the device isn't trusted, it returns:
{ "requires_device_confirmation": true }and emails a confirmation link. Trusted devices (a device_id cookie already verified) skip this and log in normally.
The link (/auth/verify?token=...) only approves the pending login — it never starts a session on the device that opens it. The device that started the login polls and completes:
GET /api/v1/auth/pending-login/statusReads the pending_login cookie and returns { "approved": true } once the link has been opened (and { "approved": false } until then, or if the attempt is missing or expired).
POST /api/v1/auth/pending-login/completeCompletes the login on the device that started it — login cookies are set here, and the pending_login cookie is cleared. This is what lets you open the emailed link on your phone and still sign in on your computer.
First-boot setup
These two endpoints exist only until the first user is created — after that POST /api/v1/setup fails while GET /api/v1/setup/status keeps answering. Self-hosted instances run them via the Setup screen the first time you open the dashboard; you almost never need to call them by hand.
Status
GET /api/v1/setup/status{ "setup_required": true, "deployment_mode": "self-hosted" }setup_required flips to false once at least one user exists.
Complete setup
POST /api/v1/setup{
"name": "Admin",
"email": "[email protected]",
"password": "yourpassword"
}Returns 201 Created with {"message":"setup complete"} and sets login cookies in the same response. Calling this when users already exist returns 403 Forbidden with {"error":"setup already completed"}.