Overview
The Sendook API uses API keys for authentication. API keys are organization-scoped tokens that authenticate requests to the v1 API endpoints.All API requests must include an
Authorization header with your API key as a Bearer token.Authentication Methods
Sendook supports two authentication strategies:1. API Key Authentication (Recommended)
Used for all v1 API endpoints. API keys are associated with your organization and provide full access to organization resources.2. Bearer Token Authentication
Used for non-API endpoints (like/auth, /organizations). These are user-scoped access tokens obtained through the authentication flow.
Getting Your API Key
You can create and manage API keys through the Sendook dashboard or via the API itself.Via Dashboard
- Log in to your Sendook dashboard
- Navigate to Settings → API Keys
- Click Create API Key
- Give your key a descriptive name (e.g., “Production”, “Staging”)
- Copy and securely store your API key
Via API
You can also manage API keys programmatically:Making Authenticated Requests
Include your API key in theAuthorization header as a Bearer token:
Request Flow
When you make an authenticated request:- Your API key is extracted from the
Authorizationheader - Sendook validates the key using the
api_keyPassport strategy - The associated organization is loaded and attached to the request
- Your request proceeds with organization-scoped access
~/workspace/source/api/routes/v1/index.ts:13-18:
API Key Validation
API keys are validated using Passport.js with a custom bearer strategy. Here’s how it works under the hood:
From
~/workspace/source/api/controllers/PassportController.ts:29-48:
Managing API Keys
List API Keys
Retrieve all API keys for your organization:Get Specific API Key
Delete API Key
Revoke an API key when it’s no longer needed:Authentication Errors
401 Unauthorized
Returned when authentication fails:- Missing
Authorizationheader - Invalid or expired API key
- API key format is incorrect
- API key has been deleted or deactivated
Example Error Response
Security Best Practices
Store API keys securely
Store API keys securely
- Never commit API keys to version control
- Use environment variables or secret management services
- Rotate keys periodically for enhanced security
Use separate keys per environment
Use separate keys per environment
Create different API keys for development, staging, and production environments. This allows you to:
- Isolate environments
- Revoke keys without affecting other environments
- Track usage per environment
Minimize key exposure
Minimize key exposure
- Only share API keys with team members who need them
- Use service-specific keys when possible
- Delete unused or compromised keys immediately
Monitor API key usage
Monitor API key usage
- Regularly review API logs in your dashboard
- Set up alerts for unusual activity
- Track which keys are being used and where
Environment Variables
Store your API key as an environment variable:Rate Limiting and Authentication
Authenticated requests are subject to rate limiting. See the API Overview for details on rate limits. Rate limits are tracked per organization, not per API key. Multiple API keys for the same organization share the same rate limit pool.Testing Authentication
Test your API key with a simple health check:401 Unauthorized response.
Next Steps
Create an Inbox
Start by creating your first inbox
Send a Message
Send your first email via the API
Set Up Webhooks
Receive incoming email notifications
Node.js SDK
Use the official SDK for easier integration