Brew API Overview
Brew’s REST API gives you secure, programmatic access to core email marketing features. Use the API to:- Send transactional emails using your published email templates
- Trigger automations with custom events and payloads
- Import contacts in bulk with custom fields
- Update and delete contacts by email address
Quick Start
Get up and running in under 5 minutes:Get your API key
In Brew, go to Settings → API and click Create API Key. Give it a descriptive name like “Production App”.
All API requests require authentication. You can use either header format:
Base URL and Authentication
Base URL:https://brew.new/api
All requests must include your API key via one of these headers:
- GET - Retrieve data
- POST - Create new resources
- PATCH - Update existing resources
- DELETE - Remove resources
API Endpoints
The Brew API provides the following endpoints:Automations
| Method | Endpoint | Description |
|---|---|---|
| POST | /automations/{automationId}/trigger | Trigger an automation with a payload |
| GET | /automations/{automationId}/trigger | Get automation trigger info and schema |
{automationId} parameter accepts two formats:
- Event ID (recommended): User-defined string like
lead_generated,user_signup - Automation ID (legacy): Internal Convex document ID
Transactional Emails
| Method | Endpoint | Description |
|---|---|---|
| POST | /send/transactional | Send a transactional email |
| GET | /send/transactional | Get API documentation |
Contacts
| Method | Endpoint | Description |
|---|---|---|
| POST | /contacts/import | Bulk import contacts (up to 10,000 per request) |
| GET | /contacts/import | Get import status or list recent imports |
| PATCH | /contacts | Update a contact by email |
| DELETE | /contacts | Delete a contact or custom fields |
Common Use Cases
- Transactional Emails
- Trigger Automations
- Import Contacts
- Update Contact
- Delete Contact
Send password resets, order confirmations, and other triggered emails:Response:Send to multiple recipients (up to 1,000):
Custom Fields
Brew supports custom contact fields to store additional data for segmentation and personalization. Custom fields are passed in thecustomFields object when importing or updating contacts.
Supported Data Types
| Type | Description | Example |
|---|---|---|
string | Text values | "Enterprise", "Product Manager" |
number | Numeric values | 50, 99.99, -10 |
boolean | True/false values | true, false |
Using Custom Fields
Include custom fields when importing or updating contacts:Deleting Custom Fields
Use the DELETE endpoint withdeleteFields to remove specific custom fields:
Reserved Field Names
The following field names are reserved and cannot be used as custom fields:email,firstName,lastName,subscribed,createdAt,updatedAt,tags
Rate Limits
Brew enforces the following rate limits:| Endpoint | Limit |
|---|---|
Contact endpoints (/contacts, /contacts/import) | 100 requests per minute |
| Contact import batch size | 10,000 contacts per request |
| Transactional email recipients | 1,000 per request |
Error Handling
Brew uses standard HTTP status codes with consistent error responses:| Status | Description |
|---|---|
| 200 | Success |
| 400 | Bad request |
| 401 | Invalid API key |
| 404 | Resource not found |
| 409 | Conflict (duplicate) |
| 429 | Rate limit exceeded |
| 500 | Server error |
INVALID_API_KEY- API key is invalid or expiredPERMISSION_DENIED- API key doesn’t have required permissionINVALID_REQUEST_BODY- Request body is malformedMISSING_REQUIRED_FIELD- Required field is missingCONTACT_NOT_FOUND- Contact with specified email not foundRATE_LIMITED- Rate limit exceededALL_RECIPIENTS_BLOCKED- All transactional recipients were suppressed
Common Error Solutions
Common Error Solutions
401 Unauthorized:
- Check your API key is correct and active
- Ensure you’re using
Bearer YOUR_API_KEYformat - Generate a new key from Settings → API if needed
- Verify all required fields are included
- Check data types match the API specification
- Ensure email addresses are properly formatted
- Implement exponential backoff in your retry logic
- Consider batching requests where possible
- Monitor rate limit headers in responses
CORS and Client-Side Issues
CORS and Client-Side Issues
Brew’s API does not support cross-origin requests from browsers. Always make API calls from your backend server.
Idempotency
Idempotency ensures that operations (like sending emails) are only performed once, even if you make the same API request multiple times. This is particularly useful for:- Preventing duplicate emails when network issues cause retries
- Safely retrying failed API calls without worrying about side effects
- Maintaining data consistency during system outages or timeouts
Idempotency-Key header with a unique value:
How Idempotency Works
- When you include an idempotency key with a request, Brew checks if it’s seen this key before
- If this is the first time seeing the key, Brew processes the request normally
- If the key was used in the last 24 hours, Brew returns the same response as the original request without performing the operation again
Best Practices
- Use a unique identifier for each distinct operation (UUID is recommended)
- Reuse the same key when retrying the exact same request
- Keys can be up to 100 characters in length
- Consider structuring keys that relate to your business logic (e.g.,
welcome-email/user-123) - Keys expire after 24 hours, after which they can be reused
OpenAPI Specification
Get started quickly with the Brew API using our OpenAPI documents. Import these into API clients like Postman or Insomnia to explore all endpoints with example requests and responses.Need Help?
Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:- Self-Service Tools
- Talk to Our Team
Search Documentation
Type in the “Ask any question” search bar at the top left to instantly find relevant documentation pages.
ChatGPT/Claude Integration
Click “Open in ChatGPT” at the top right of any page to analyze documentation with ChatGPT or Claude for deeper insights.