Events & Workflows
Register event definitions
Connect your app once to automate emails from the data it already has.
Connect once
The connection tells Sendery which events your app sends and what data to expect. Set it up once, then add new events or stop sending ones you no longer need as your application changes.
Walkthrough: an order event
Say your application has this order JSON. We’ll use it to send a confirmation to the buyer and a notification to the seller.
{
"id": "1042",
"buyer": {
"name": "Steven",
"email": "[email protected]"
},
"seller": {
"name": "Sam",
"email": "[email protected]"
},
"price": 49
}1. Identify the object
The object is the record the event is about. Here, that is the order, not the buyer or seller.
Register its type as order. When sending an event, set object.id to the order’s ID, "1042". Related events, such as order.created and order.shipped, use the same object type and ID for that order.
{
"object": {
"type": "order",
"label": "Order"
}
}2. Map data to template variables
Fields connect your application’s data to emails and conditions. Include at least one field with type: "email"; your team can choose any email field as the recipient. For example:
buyer_nameis the field key. A template can use{{ buyer_name }}.path: "buyer.name"reads the value fromdata.buyer.namewhen an event arrives. Paths always start insidedata.labelis the readable name your team sees;typedescribes the value.
With this order, Hi {{ buyer_name }}, your order total is {{ price }}. becomes Hi Steven, your order total is 49.
Optional example values supply sample data for previews and test flows. Use made-up values, such as Steven or 49. These are not defaults for real events; your app supplies the actual data.
Matching template variables connect automatically. If a template uses a different name, you can link it to the corresponding event field when creating a workflow.
{
"fields": {
"buyer_name": {"label": "Buyer name", "path": "buyer.name", "type": "text", "example": "Steven"},
"buyer_email": {"label": "Buyer email", "path": "buyer.email", "type": "email", "required": true, "example": "[email protected]"},
"seller_name": {"label": "Seller name", "path": "seller.name", "type": "text", "example": "Sam"},
"seller_email": {"label": "Seller email", "path": "seller.email", "type": "email", "required": true, "example": "[email protected]"},
"price": {"label": "Order price", "path": "price", "type": "number", "example": 49}
}
}3. Register the event
Put the object and fields together and send them to PUT /api/v1/event-types/order.created. This saves the setup for future orders; it does not send an order or an email.
Use label for a readable event name and description for when it fires (optional, up to 150 characters). The event key, such as order.created, stays the same in your application.
Choose cURL or your configured SDK below. verified: false means the definition is saved, but your application has not sent a matching event yet.
curl --request PUT 'https://sendery.co/api/v1/event-types/order.created' \
--header "Authorization: Bearer $SENDERY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"label": "Order created",
"description": "When a buyer successfully places an order.",
"object": {"type": "order", "label": "Order"},
"fields": {
"buyer_name": {"label": "Buyer name", "path": "buyer.name", "type": "text", "example": "Steven"},
"buyer_email": {"label": "Buyer email", "path": "buyer.email", "type": "email", "required": true, "example": "[email protected]"},
"seller_name": {"label": "Seller name", "path": "seller.name", "type": "text", "example": "Sam"},
"seller_email": {"label": "Seller email", "path": "seller.email", "type": "email", "required": true, "example": "[email protected]"},
"price": {"label": "Order price", "path": "price", "type": "number", "example": 49}
}
}'$sendery->defineEvent('order.created', [
'label' => 'Order created',
'description' => 'When a buyer successfully places an order.',
'object' => ['type' => 'order', 'label' => 'Order'],
'fields' => [
'buyer_name' => ['label' => 'Buyer name', 'path' => 'buyer.name', 'type' => 'text', 'example' => 'Steven'],
'buyer_email' => ['label' => 'Buyer email', 'path' => 'buyer.email', 'type' => 'email', 'required' => true, 'example' => '[email protected]'],
'seller_name' => ['label' => 'Seller name', 'path' => 'seller.name', 'type' => 'text', 'example' => 'Sam'],
'seller_email' => ['label' => 'Seller email', 'path' => 'seller.email', 'type' => 'email', 'required' => true, 'example' => '[email protected]'],
'price' => ['label' => 'Order price', 'path' => 'price', 'type' => 'number', 'example' => 49],
]
]);app(\Sendery\Laravel\Client::class)->defineEvent('order.created', [
'label' => 'Order created',
'description' => 'When a buyer successfully places an order.',
'object' => ['type' => 'order', 'label' => 'Order'],
'fields' => [
'buyer_name' => ['label' => 'Buyer name', 'path' => 'buyer.name', 'type' => 'text', 'example' => 'Steven'],
'buyer_email' => ['label' => 'Buyer email', 'path' => 'buyer.email', 'type' => 'email', 'required' => true, 'example' => '[email protected]'],
'seller_name' => ['label' => 'Seller name', 'path' => 'seller.name', 'type' => 'text', 'example' => 'Sam'],
'seller_email' => ['label' => 'Seller email', 'path' => 'seller.email', 'type' => 'email', 'required' => true, 'example' => '[email protected]'],
'price' => ['label' => 'Order price', 'path' => 'price', 'type' => 'number', 'example' => 49],
]
]);$sendery->defineEvent('order.created', [
'label' => 'Order created',
'description' => 'When a buyer successfully places an order.',
'object' => ['type' => 'order', 'label' => 'Order'],
'fields' => [
'buyer_name' => ['label' => 'Buyer name', 'path' => 'buyer.name', 'type' => 'text', 'example' => 'Steven'],
'buyer_email' => ['label' => 'Buyer email', 'path' => 'buyer.email', 'type' => 'email', 'required' => true, 'example' => '[email protected]'],
'seller_name' => ['label' => 'Seller name', 'path' => 'seller.name', 'type' => 'text', 'example' => 'Sam'],
'seller_email' => ['label' => 'Seller email', 'path' => 'seller.email', 'type' => 'email', 'required' => true, 'example' => '[email protected]'],
'price' => ['label' => 'Order price', 'path' => 'price', 'type' => 'number', 'example' => 49],
]
]);await sendery.defineEvent("order.created", {
label: "Order created",
description: "When a buyer successfully places an order.",
object: {type: "order", label: "Order"},
fields: {
buyer_name: {label: "Buyer name", path: "buyer.name", type: "text", example: "Steven"},
buyer_email: {label: "Buyer email", path: "buyer.email", type: "email", required: true, example: "[email protected]"},
seller_name: {label: "Seller name", path: "seller.name", type: "text", example: "Sam"},
seller_email: {label: "Seller email", path: "seller.email", type: "email", required: true, example: "[email protected]"},
price: {label: "Order price", path: "price", type: "number", example: 49},
}
});definition := sendery.EventDefinition{
Label: "Order created",
Description: "When a buyer successfully places an order.",
Object: sendery.EventRecordType{Type: "order", Label: "Order"},
Fields: map[string]sendery.EventField{
"buyer_name": {Label: "Buyer name", Path: "buyer.name", Type: "text", Example: "Steven"},
"buyer_email": {Label: "Buyer email", Path: "buyer.email", Type: "email", Required: true, Example: "[email protected]"},
"seller_name": {Label: "Seller name", Path: "seller.name", Type: "text", Example: "Sam"},
"seller_email": {Label: "Seller email", Path: "seller.email", Type: "email", Required: true, Example: "[email protected]"},
"price": {Label: "Order price", Path: "price", Type: "number", Example: 49},
}
}
_, err := client.DefineEvent(ctx, "order.created", definition)
if err != nil {
return err
}await sendery.defineEvent("order.created", {
label: "Order created",
description: "When a buyer successfully places an order.",
object: {type: "order", label: "Order"},
fields: {
buyer_name: {label: "Buyer name", path: "buyer.name", type: "text", example: "Steven"},
buyer_email: {label: "Buyer email", path: "buyer.email", type: "email", required: true, example: "[email protected]"},
seller_name: {label: "Seller name", path: "seller.name", type: "text", example: "Sam"},
seller_email: {label: "Seller email", path: "seller.email", type: "email", required: true, example: "[email protected]"},
price: {label: "Order price", path: "price", type: "number", example: 49},
}
});await sendery.defineEvent("order.created", {
label: "Order created",
description: "When a buyer successfully places an order.",
object: {type: "order", label: "Order"},
fields: {
buyer_name: {label: "Buyer name", path: "buyer.name", type: "text", example: "Steven"},
buyer_email: {label: "Buyer email", path: "buyer.email", type: "email", required: true, example: "[email protected]"},
seller_name: {label: "Seller name", path: "seller.name", type: "text", example: "Sam"},
seller_email: {label: "Seller email", path: "seller.email", type: "email", required: true, example: "[email protected]"},
price: {label: "Order price", path: "price", type: "number", example: 49},
}
});sendery.define_event("order.created", {
"label": "Order created",
"description": "When a buyer successfully places an order.",
"object": {"type": "order", "label": "Order"},
"fields": {
"buyer_name": {"label": "Buyer name", "path": "buyer.name", "type": "text", "example": "Steven"},
"buyer_email": {"label": "Buyer email", "path": "buyer.email", "type": "email", "required": True, "example": "[email protected]"},
"seller_name": {"label": "Seller name", "path": "seller.name", "type": "text", "example": "Sam"},
"seller_email": {"label": "Seller email", "path": "seller.email", "type": "email", "required": True, "example": "[email protected]"},
"price": {"label": "Order price", "path": "price", "type": "number", "example": 49},
}
})from sendery_django import define_event
define_event("order.created", {
"label": "Order created",
"description": "When a buyer successfully places an order.",
"object": {"type": "order", "label": "Order"},
"fields": {
"buyer_name": {"label": "Buyer name", "path": "buyer.name", "type": "text", "example": "Steven"},
"buyer_email": {"label": "Buyer email", "path": "buyer.email", "type": "email", "required": True, "example": "[email protected]"},
"seller_name": {"label": "Seller name", "path": "seller.name", "type": "text", "example": "Sam"},
"seller_email": {"label": "Seller email", "path": "seller.email", "type": "email", "required": True, "example": "[email protected]"},
"price": {"label": "Order price", "path": "price", "type": "number", "example": 49},
}
})sendery.defineEvent("order.created", Map.of(
"label", "Order created",
"description", "When a buyer successfully places an order.",
"object", Map.of("type", "order", "label", "Order"),
"fields", Map.of(
"buyer_name", Map.of("label", "Buyer name", "path", "buyer.name", "type", "text", "example", "Steven"),
"buyer_email", Map.of("label", "Buyer email", "path", "buyer.email", "type", "email", "required", true, "example", "[email protected]"),
"seller_name", Map.of("label", "Seller name", "path", "seller.name", "type", "text", "example", "Sam"),
"seller_email", Map.of("label", "Seller email", "path", "seller.email", "type", "email", "required", true, "example", "[email protected]"),
"price", Map.of("label", "Order price", "path", "price", "type", "number", "example", 49)
)
));sendery.defineEvent("order.created", mapOf(
"label" to "Order created",
"description" to "When a buyer successfully places an order.",
"object" to mapOf("type" to "order", "label" to "Order"),
"fields" to mapOf(
"buyer_name" to mapOf("label" to "Buyer name", "path" to "buyer.name", "type" to "text", "example" to "Steven"),
"buyer_email" to mapOf("label" to "Buyer email", "path" to "buyer.email", "type" to "email", "required" to true, "example" to "[email protected]"),
"seller_name" to mapOf("label" to "Seller name", "path" to "seller.name", "type" to "text", "example" to "Sam"),
"seller_email" to mapOf("label" to "Seller email", "path" to "seller.email", "type" to "email", "required" to true, "example" to "[email protected]"),
"price" to mapOf("label" to "Order price", "path" to "price", "type" to "number", "example" to 49)
)
))sendery.defineEvent("order.created", Map.of(
"label", "Order created",
"description", "When a buyer successfully places an order.",
"object", Map.of("type", "order", "label", "Order"),
"fields", Map.of(
"buyer_name", Map.of("label", "Buyer name", "path", "buyer.name", "type", "text", "example", "Steven"),
"buyer_email", Map.of("label", "Buyer email", "path", "buyer.email", "type", "email", "required", true, "example", "[email protected]"),
"seller_name", Map.of("label", "Seller name", "path", "seller.name", "type", "text", "example", "Sam"),
"seller_email", Map.of("label", "Seller email", "path", "seller.email", "type", "email", "required", true, "example", "[email protected]"),
"price", Map.of("label", "Order price", "path", "price", "type", "number", "example", 49)
)
));{
"name": "order.created",
"verified": false
}4. Check what you saved
Call GET /api/v1/event-types to see your project’s saved event definitions, including the field paths and types. If this is your first event type, the response will look like this.
After your app sends its first valid event, verified becomes true and last_received_at shows when it arrived.
curl --request GET 'https://sendery.co/api/v1/event-types' \
--header "Authorization: Bearer $SENDERY_API_KEY"{
"events": [
{
"name": "order.created",
"label": "Order created",
"object": {
"type": "order",
"label": "Order"
},
"fields": {
"buyer_name": {
"label": "Buyer name",
"path": "buyer.name",
"type": "text",
"example": "Steven",
"required": false
},
"buyer_email": {
"label": "Buyer email",
"path": "buyer.email",
"type": "email",
"required": true,
"example": "[email protected]"
},
"seller_name": {
"label": "Seller name",
"path": "seller.name",
"type": "text",
"example": "Sam",
"required": false
},
"seller_email": {
"label": "Seller email",
"path": "seller.email",
"type": "email",
"required": true,
"example": "[email protected]"
},
"price": {
"label": "Order price",
"path": "price",
"type": "number",
"example": 49,
"required": false
}
},
"verified": false,
"last_received_at": null,
"description": "When a buyer successfully places an order."
}
]
}Update the name or description
PATCH /api/v1/event-types/{name}
Replace {name} with the event key. Send a JSON body containing either or both fields:
| Field | Type | Description |
|---|---|---|
label |
string | Display name, up to 100 characters. |
description |
string or null | When the event fires, up to 150 characters. Use null to clear it. |
Omitted fields stay unchanged. Returns 200 with name, label, description, and verified.
Remove an event definition
DELETE /api/v1/event-types/{name}
Replace {name} with the event key. No request body is needed.
| Status | Response |
|---|---|
200 |
The event key in name and deleted: true. |
404 |
The event definition was not found. |
409 |
event_type_in_use: remove the event from workflows before deleting its definition. |
Next: start sending events
Your event definition is saved. Next, send events from your application whenever an order is created. That guide continues with the same order example.