About Automation Triggers
Brew automations are triggered via API, giving you complete control over when workflows run and what data is passed to them. Each automation has a unique ID and a typed payload schema that defines the data structure expected when triggering.For information about building automation workflows (nodes, timing, branching), see the Automations page.
Triggering Automations
Trigger a specific automation by ID with a validated payload:Contact Upsert on Trigger
When you trigger an automation via API, Brew automatically:- Looks up the contact by the
emailfield in your payload - Creates a new contact if none exists, or updates the existing contact with payload data
- Returns the action taken in the response (
"action": "created"or"action": "updated")
firstName, custom fields) is automatically saved to the contact record.
The
email field is always required at the root level of your payload. Brew uses this to identify the contact.Configuring Event Triggers
When creating an automation in Brew, you define the event trigger with:- Event ID - A unique identifier (e.g.,
order_placed,user_signup) - Event Name - A human-readable display name
- Payload Schema - The expected data structure with field types
Payload Schema
Define the data your automation expects. Each field has:- Type: string, number, boolean, object, or array
- Required: Whether the field must be present
- Description: Documentation for the field
Payload Validation
When you trigger an automation, Brew validates the payload against the schema:- Required fields must be present
- Field types must match (string, number, boolean, etc.)
- Nested objects and arrays are recursively validated
Using Payload Data in Emails
Access trigger payload data in your email templates using the@trigger:output.payload variable prefix:
| Payload Field | Template Variable |
|---|---|
email | {{@trigger:output.payload.email}} |
firstName | {{@trigger:output.payload.firstName}} |
orderId | {{@trigger:output.payload.orderId}} |
orderTotal | {{@trigger:output.payload.orderTotal}} |
items[0].name | {{@trigger:output.payload.items.0.name}} |
SDK Examples
- TypeScript
- Python
- cURL
Getting Automation Info
Retrieve an automation’s trigger configuration:Common Use Cases
Below are real-world examples showing how to integrate automation triggers into your application. For complete SDK documentation with error handling and advanced patterns, see:Welcome Email on Signup
Trigger a welcome sequence when a user creates an account:- TypeScript
- Python
Order Confirmation
Send order details after a purchase:- TypeScript
- Python
Payment Failed Recovery
Prompt users to update payment info:- TypeScript
- Python
Trial Ending Reminder
Notify users before their trial expires:- TypeScript
- Python
Common Event Types
| Event ID | Description | Common Payload Fields |
|---|---|---|
user_signup | New user registration | email, firstName, plan, signupSource |
order_placed | E-commerce purchase | email, firstName, orderId, orderTotal |
subscription_started | New subscription | email, firstName, plan, billingCycle |
payment_failed | Payment retry needed | email, firstName, amount, retryUrl |
trial_ending | Trial expiration notice | email, firstName, daysRemaining, upgradeUrl |
milestone_reached | User achievement | email, firstName, milestone, achievedAt |
Best Practices
Use descriptive event IDs
Use descriptive event IDs
Choose clear, specific event IDs that describe the action:Good:
order_placed, user_signup, subscription_renewedAvoid: event1, trigger, actionDefine schema before triggering
Define schema before triggering
Always configure your payload schema in the automation builder before triggering via API. This ensures:
- Payload validation catches errors early
- Template variables are available in the email editor
- API documentation is accurate in the publish dialog
Email at root level is required
Email at root level is required
The
email field must ALWAYS be at the root level of your payload (never nested). Brew uses this to:- Automatically create or update the contact
- Send emails to the right recipient
- Enable tracking and analytics
- Look up contact data for personalization
Keep payloads flat and minimal
Keep payloads flat and minimal
Avoid nested objects in your payload when possible:Good (flat):Avoid (nested):Flat payloads are easier to map to contact fields and use in email templates.
Handle API errors gracefully
Handle API errors gracefully
Implement error handling for common scenarios:
400 INVALID_PAYLOAD- Fix payload data and retry400 AUTOMATION_NOT_ACTIVE- Check automation status in Brew401 UNAUTHORIZED- Verify API key404 AUTOMATION_NOT_FOUND- Check automation ID
Use idempotency for critical triggers
Use idempotency for critical triggers
For important automations (like order confirmations), include an idempotency key:This prevents duplicate emails if your request is retried.
Testing Automations
Preview in Brew
Use the publish dialog to preview API code snippets with your actual automation ID and payload schema.
Test with example.com
Send test triggers with
@example.com or @test.com email addresses - no real emails will be sent.Build Automations
Learn how to create automation workflows
API Reference
View the full API documentation
TypeScript SDK
Trigger automations with TypeScript
Python SDK
Trigger automations with Python
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.