Cakemail API
The Cakemail API is a RESTful API that provides programmatic access to Cakemail's email marketing and transactional email platform.
Authentication
The API supports two authentication mechanisms. Choose the one that matches your use case:
Standard Tokens (JWT)
Short-lived JSON Web Tokens obtained via POST /token using the OAuth 2.0 Resource Owner Password Credentials grant. The response includes an access token (valid for a limited period) and a refresh token used to obtain a new access token when the current one expires. Use standard tokens for interactive sessions and first-party UI integrations where a human user logs in and the token lifetime matches the session.
Personal Access Tokens (PATs)
Long-lived, scoped bearer tokens prefixed with ck_pat_, created via POST /users/self/pats. PATs are tied to a specific user, carry an explicit scope list, and can optionally be restricted to a subset of account IDs. Use PATs for programmatic, automated, or agentic integrations — scripts, CI pipelines, third-party tools, and AI agents — where storing a username/password is undesirable and the principle of least privilege matters. PATs can be revoked individually without affecting the user's ability to log in.
Both token types are passed as Authorization: Bearer <token> on every request.
Core Concepts
- Accounts & Users: An account represents an organization. Each account has one or more users. Partner accounts can manage sub-accounts.
- Lists & Contacts: Lists are collections of contacts (email subscribers). Contacts belong to lists and can have custom attributes, tags, and interests.
- Campaigns: Email campaigns are created from templates, targeted to lists or segments, and scheduled for delivery.
- Transactional Email: The Email API allows sending individual transactional emails (receipts, notifications, password resets) with full tracking.
- Templates: Reusable email designs that can be shared across campaigns and transactional emails.
- Webhooks: Receive real-time notifications for events like bounces, opens, clicks, and unsubscribes.
Rate Limiting
API requests are rate-limited per account. When a rate limit is exceeded, the response body includes a detail array with limits containing limit, window, and retry_in fields.
ck_pat_<40 hex chars>) intended for programmatic integrations, automation scripts, CI pipelines, and agentic workflows. Unlike standard JWTs they carry an explicit scope list and can optionally be restricted to a subset of account IDs (allowed_account_ids), enabling the principle of least privilege. Lifecycle: create a PAT via POST /users/self/pats — the full token is returned once and must be stored securely. Use it as Authorization: Bearer ck_pat_... on any supported endpoint. Revoke it via DELETE /users/self/pats/{id} when it is no longer needed. Security best practices: request only the scopes your integration actually needs; set an expires_at for tokens used in ephemeral environments; store the plaintext token in a secret manager, not in source code; rotate PATs periodically and revoke any that may have been exposed.