# Receive requests from an Ody automation

> What an automation's Send data to another tool step sends to your server: the request, the body, how to authenticate it, how to answer, and how it differs from a webhook endpoint.

Source: https://dev.ody.co/guides/receive-automation-requests

Workspace owners and admins build **automations** in the Ody app, under [**Build → Automations**](https://app.ody.co/build/automations), with no code: *when* something happens (a missed call, an incoming text, a conversation marked done), *do* a list of steps. One of those steps, **Send data to another tool**, makes an HTTP request to a URL the admin types.

This page is for the developer on the receiving end of that request. How to build the automation itself is in the help center: [Send Ody data to another tool from an automation](https://help.ody.co/integrations/automation-send-data-to-another-tool).

> **Automations are managed in the app only:**
There are no REST endpoints, API scopes, MCP tools or SDK methods for creating, editing or running automations. The two places they show up in the API are [`message.sent`](https://dev.ody.co/webhooks/events#message-sent) (`sentBy: "automation"`) and the [`automationId`](https://dev.ody.co/api/conversations#the-activity-object) on a message an automation sent.

## Webhook endpoint or automation step?

Both send an HTTPS request to your server when something happens in Ody. They are built for different jobs.

| | [Webhook endpoint](https://dev.ody.co/webhooks/overview) | Automation step |
|---|---|---|
| Sends | Every event of the types the endpoint subscribes to | One request, when the automation's conditions are met and the run reaches the step (which can be after a wait of minutes or days) |
| Body | The event with **ids**; you fetch the details from the API | The event **plus** the contact, the conversation, the text or the call — or JSON the admin wrote |
| Signed | Yes, [Standard Webhooks](https://dev.ody.co/webhooks/signatures) | **No.** Authenticate with a header (see below) |
| Retried | Yes, see [Retries and delivery](https://dev.ody.co/webhooks/retries) | **No.** One attempt |
| Set up | In the app or with [`POST /webhooks`](https://dev.ody.co/api/webhook-endpoints) | In the app only |
| History | **Build → Webhooks → Deliveries**, 30 days, with **Resend** | The automation's **Runs** tab, 30 days |

Use a webhook endpoint when you need every event, a signature or retries. Use an automation step when a person in the workspace should decide, without a deploy, *which* calls or texts reach you and in *what* shape.

## The request

```http
POST /ody/automations HTTP/1.1
Host: your-app.example.com
User-Agent: Ody-Automations/1.0
Content-Type: application/json
X-Ody-Automation-Id: 9a3b6c1e-2f4d-4a7b-8c9d-0e1f2a3b4c5d
X-Ody-Run-Id: 5d1f0a7c-3b2e-4c6d-9e8f-7a6b5c4d3e2f
X-Ody-Event-Id: evt_8f3a1c0e5b7d4e2a9c6f1b0d3a5e7c9f
Authorization: Bearer <a token the admin typed into the step>
```

| | |
|---|---|
| Method | `POST` unless the admin chose `PUT`, `PATCH`, `GET` or `DELETE`. A `GET` has no body |
| `User-Agent` | `Ody-Automations/1.0` |
| `Content-Type` | `application/json`, whenever there is a body |
| `X-Ody-Automation-Id` | The automation that sent the request |
| `X-Ody-Run-Id` | This run of the automation. One run can contain several requests, one per step |
| `X-Ody-Event-Id` | The event that started the run. It is the same id a [webhook endpoint](https://dev.ody.co/webhooks/overview) receives as `webhook-id` and that **Build → Events** shows |
| Other headers | Up to 10 that the admin added to the step — this is where a token goes |
| Request body | At most 64 KB |
| URL | Must be `https://` on a public address. Redirects are not followed |

## The body

The admin picks one of three under **What to send**.

### The whole event

The default, and the one to ask for when you write the receiving code. It is the event exactly as a webhook endpoint receives it (`id`, `type`, `createdAt`, `data`), with the records it points at already attached:

```json
{
  "id": "evt_8f3a1c0e5b7d4e2a9c6f1b0d3a5e7c9f",
  "type": "message.received",
  "createdAt": "2026-11-24T18:02:11.412Z",
  "data": {
    "numberE164": "+15125550100",
    "conversationId": "c4f1a2b3-…",
    "inboxId": "1e2d3c4b-…",
    "activityId": "5e7f9a1b-…",
    "contactId": "7b8c9d0e-…"
  },
  "contact": {
    "id": "7b8c9d0e-…",
    "name": "Ada Lovelace",
    "firstName": "Ada",
    "lastName": "Lovelace",
    "company": "Analytical Engines",
    "phone": "+15125559999",
    "email": "ada@example.com",
    "tags": ["VIP"],
    "properties": { "Account number": "A-1042" }
  },
  "conversation": { "id": "c4f1a2b3-…", "status": "open", "assigneeId": "" },
  "message": { "body": "Please call me back", "direction": "inbound", "hasMedia": false },
  "line": { "number": "+15125550100", "name": "Main line" },
  "automation": { "id": "9a3b6c1e-…", "name": "Incoming text → your server", "runId": "5d1f0a7c-…" }
}
```

- `id`, `type`, `createdAt`, `data` — The event. `data` is documented per type in [Event types](https://dev.ody.co/webhooks/events).
- `contact` *object* — Always present. When the person is not a saved contact, `id` is an empty string and `name` and `phone` are their number. `properties` holds the contact's custom fields as strings.
- `conversation` *object* — `id`, `status` (`open` or `done`) and `assigneeId` (a member id, or an empty string). All three are empty strings when the event has no conversation, or when the conversation is in an inbox the member who turned the automation on cannot see.
- `message` *object* — Only when the event is about a text: `body`, `direction` (`inbound` or `outbound`) and `hasMedia`. `body` is an empty string for an incoming text while the workspace is on its free trial, when the app hides the content of incoming texts too.
- `call` *object* — Only when the event is about a call or a voicemail: `direction`, `status`, `durationSeconds`, `answeredBy`, `transcript` and `summary`. `transcript` and `summary` are empty strings until Ody has them — an automation that starts on `call.summary.completed` or `call.transcript.completed` is the reliable way to receive them.
- `line` *object* — The workspace number the event happened on: `number` (E.164) and `name` (the inbox's name, or the number when it has none).
- `automation` *object* — `id`, `name` and `runId`, the same values as the headers.

The records are read **when the step runs**, not when the event happened. After a **Wait** step the contact's tags or the conversation's status can differ from what they were at `createdAt`.

### My own JSON

The admin writes the body and drops values into it, for example `{ "text": "Missed call from {{contact.name}}" }` for a Slack incoming webhook. The shape is whatever they typed. Ody escapes quotes and line breaks inside every value, and a body that is not valid JSON once the values are filled in is never sent: the step fails instead.

### No body

The request is sent with no body and no `Content-Type`. The three `X-Ody-…` headers are still there.

## Authenticate the request

Automation requests are **not signed**. To know a request came from your workspace's automation:

1. Generate a long random token and store it on your server.
2. Ask the admin to add it to the step under **Headers**, for example the name `Authorization` and the value `Bearer <token>`.
3. Reject any request whose header does not match. Compare in constant time.

> **A header value is not hidden from other admins:**
The token is stored with the automation. Every owner and admin of the workspace can open the step and read it. It is left out of the run history, which keeps header names only. Use a token made for this one purpose, and rotate it by editing the step.

If you need a signature you can verify against a secret Ody shows only once, use a [webhook endpoint](https://dev.ody.co/webhooks/signatures) instead.

## Answer the request

- **Any `2xx` within 10 seconds** is a success. The run goes on to its next step.
- **Anything else fails the step** — a `3xx`, `4xx`, `5xx`, a timeout or a refused connection — and ends the run there: the steps after it do not run. The admin sees your status code and the first 2 KB of your answer in the run history.
- **Nothing is retried.** A request that failed is not sent again later.
- **Twenty failed runs in a row pause the automation.** An endpoint that is down for long enough switches the automation off; an admin has to turn it back on.

Answer fast and do slow work afterwards, as you would for a webhook.

### Hand a value back to the automation

Ody keeps the first 2 KB of your answer. If it is JSON (`Content-Type: application/json`) and fits, later steps of the same automation can use its fields: an answer of `{ "id": "rec_42" }` lets the admin write `{{steps.s1.body.id}}` in a later step, for example to note your record id on the contact. Keep the answer small — a JSON answer cut off at 2 KB cannot be read.

## Handle repeats and tests

- An automation runs **once per event**, and each step sends its request once. The pair `X-Ody-Automation-Id` + `X-Ody-Event-Id` identifies it; store it if a repeat would do harm.
- Two different automations can send you the same event. So can a webhook endpoint subscribed to the same type: the event id is the same in all three.
- **Test runs send real requests** when the admin ticks **Really send HTTP requests** under **Try it**. A test on sample data carries `X-Ody-Event-Id: evt_sample` and a made-up contact (Ada Lovelace, `+15125559999`). A test that replays a past event carries that event's real id with a new run id. Treat `evt_sample` as a test and do not store it.

## A minimal receiver

TypeScript:

```ts
import express from "express";
import { timingSafeEqual } from "node:crypto";

const app = express();
const expected = Buffer.from(`Bearer ${process.env.ODY_AUTOMATION_TOKEN}`);

app.post("/ody/automations", express.json({ limit: "100kb" }), async (req, res) => {
  const got = Buffer.from(req.get("authorization") ?? "");
  if (got.length !== expected.length || !timingSafeEqual(got, expected)) return res.sendStatus(401);

  const eventId = req.get("x-ody-event-id");
  if (eventId === "evt_sample") return res.json({ ok: true, test: true });

  const key = `${req.get("x-ody-automation-id")}:${eventId}`;
  if (await db.seen(key)) return res.json({ ok: true, duplicate: true });

  const { type, contact, message, call } = req.body;
  const record = await db.leads.create({
    key,
    type,
    name: contact.name,
    phone: contact.phone,
    text: message?.body ?? call?.summary ?? "",
  });

  // A small JSON answer: the automation can use {{steps.s1.body.id}} in a later step.
  res.json({ id: record.id });
});
```
Python:

```python
import hmac, os
from flask import Flask, request, jsonify

app = Flask(__name__)
EXPECTED = f"Bearer {os.environ['ODY_AUTOMATION_TOKEN']}"

@app.post("/ody/automations")
def ody_automation():
    if not hmac.compare_digest(request.headers.get("Authorization", ""), EXPECTED):
        return "", 401

    event_id = request.headers.get("X-Ody-Event-Id")
    if event_id == "evt_sample":
        return jsonify(ok=True, test=True)

    key = f"{request.headers.get('X-Ody-Automation-Id')}:{event_id}"
    if db.seen(key):
        return jsonify(ok=True, duplicate=True)

    body = request.get_json()
    contact = body["contact"]
    text = (body.get("message") or {}).get("body") or (body.get("call") or {}).get("summary") or ""
    record = db.leads.create(key=key, type=body["type"], name=contact["name"], phone=contact["phone"], text=text)

    # A small JSON answer: the automation can use {{steps.s1.body.id}} in a later step.
    return jsonify(id=record.id)
```

## Troubleshooting

- **Nothing arrives** — Ask the admin to open the automation's **Runs** tab. A run that is not there means the automation did not start (it is off, or its conditions were not met). A run that **Failed** on your step shows what your server answered.
- **The admin sees "blocked"** — The URL is not public `https://`, or its hostname resolves to a private, loopback or link-local address. Use a tunnel with a public address while you build.
- **The admin sees "timed out after 10 s"** — Answer first, work afterwards.
- **You get a request with no `message` and no `call`** — The automation starts on an event that is about neither, such as `contact.updated` or `conversation.status.changed`. `contact` and `data` are still there.
- **`message.body` is empty** — The workspace is on its free trial. The content of incoming texts is hidden there until the paid plan starts, in the app and in automations alike.

## Related

- [Webhooks overview](https://dev.ody.co/webhooks/overview) — signed, retried, every event
- [Event types](https://dev.ody.co/webhooks/events) — the `data` of each event
- [Automate follow-ups with Ody automations](https://help.ody.co/integrations/automations) — how admins build them
