Sendery
Sendery

Events & Workflows

Connecting your application

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": "Alex",
    "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. Choose the recipients

Give each possible recipient a role, such as Buyer or Seller, so your team can choose who receives each email.

The email and name values below refer to field keys, such as buyer_email. The next step connects those keys to your JSON. The same event can be used to send different emails to the buyer and seller.

JSON
{
  "recipients": {
    "buyer": {
      "label": "Buyer",
      "email": "buyer_email",
      "name": "buyer_name"
    },
    "seller": {
      "label": "Seller",
      "email": "seller_email",
      "name": "seller_name"
    }
  }
}

3. Map data to template variables

Fields connect your application’s data to the values your team can use in emails and conditions. 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 Alex, your order total is 49.

Optional example values supply sample data for previews and test flows. Use made-up values, such as Alex 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": "Alex"},
    "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}
  }
}

4. Register the event

Put the object, fields, and recipients 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.

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",
  "object": {"type": "order", "label": "Order"},
  "fields": {
    "buyer_name": {"label": "Buyer name", "path": "buyer.name", "type": "text", "example": "Alex"},
    "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}
  },
  "recipients": {
    "buyer": {"label": "Buyer", "email": "buyer_email", "name": "buyer_name"},
    "seller": {"label": "Seller", "email": "seller_email", "name": "seller_name"}
  }
}'
200 · application/json
{
  "name": "order.created",
  "verified": false
}

5. Check what you saved

Call GET /api/v1/event-types to see your project’s saved event definitions, including the field paths and recipient roles. 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": "Alex",
          "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
        }
      },
      "recipients": {
        "buyer": {
          "label": "Buyer",
          "email": "buyer_email",
          "name": "buyer_name"
        },
        "seller": {
          "label": "Seller",
          "email": "seller_email",
          "name": "seller_name"
        }
      },
      "verified": false,
      "last_received_at": null
    }
  ]
}

Emails in different languages

To send in each recipient’s language, add a text field for their language code and reference its key in the recipient’s locale. For example, buyer_locale reads buyer.locale from your event data.

Merge the fields below into your definition and update the recipient mappings. The buyer and seller can each receive a different language. Publish those translations in the email template; omitting a recipient’s language uses the template’s default.

JSON
{
  "fields": {
    "buyer_locale": {"label": "Buyer language", "path": "buyer.locale", "type": "text", "example": "ja"},
    "seller_locale": {"label": "Seller language", "path": "seller.locale", "type": "text", "example": "en"}
  },
  "recipients": {
    "buyer": {"label": "Buyer", "email": "buyer_email", "name": "buyer_name", "locale": "buyer_locale"},
    "seller": {"label": "Seller", "email": "seller_email", "name": "seller_name", "locale": "seller_locale"}
  }
}

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.