Sendery
Sendery

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.

JSON
{
  "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.

JSON
{
  "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_name is the field key. A template can use {{ buyer_name }}.
  • path: "buyer.name" reads the value from data.buyer.name when an event arrives. Paths always start inside data.
  • label is the readable name your team sees; type describes 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.

JSON
{
  "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
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}
  }
}'
200 · application/json
{
  "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
curl --request GET 'https://sendery.co/api/v1/event-types' \
  --header "Authorization: Bearer $SENDERY_API_KEY"
200 · application/json
{
  "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.