# HTTP request step

The HTTP request step calls your own API from an automation: add a lead to your CRM, post to Slack, start a job in your backend. Fill in the URL, headers and body with the contact's and the event's data, or paste a cURL command or an n8n HTTP Request node and send.io builds the step for you.

## Add the step

1. **Add the block.** In the automation builder, add **HTTP request** where the call should happen.
2. **Describe the call.** Pick one: fill in the method, URL, headers and body yourself; click **Import cURL** and paste a curl command (from your API's docs, Postman or a browser's "Copy as cURL"); or click **Import from n8n** and paste an HTTP Request node you copied in n8n. Importing fills the form and lists anything to check. Nothing is saved until you save.
3. **Add your data.** Replace fixed values with tokens such as `{{contact.email}}` or `{{event.plan}}` (click a variable chip to insert it).
4. **Test it.** **Send test request** makes one real call with a sample contact and shows the status, time and the start of the response.
5. **Publish.** An automation with an HTTP request step needs an admin to publish.

In the API the step type is `webhook`. **Create with AI** can add it too: say which URL to call and what to send, then fill in any secret header it leaves empty.

## Step settings

| Field | Values | Notes |
| --- | --- | --- |
| `url` | https URL | Required. May hold tokens; token values are URL-encoded. |
| `method` | POST, PUT, PATCH, GET, DELETE | Default POST. A body is sent only for POST, PUT and PATCH. |
| `headers` | [{name, value, secret?}] | At most 10. Values may hold tokens. |
| `body_type` | json, form, text, none | Default json. |
| `body` | depends on `body_type` | json: any JSON value. form: [{name, value}], sent as application/x-www-form-urlencoded. text: a string, sent as text/plain unless you set Content-Type. |
| `continue_on_failure` | true or false | Default false: a failed call stops the run. true: the run goes on to the next step. |
| `timeout_seconds` | 1 to 30 | Default 10. |

A step in the graph:

```json
{
  "key": "sync_crm",
  "type": "webhook",
  "config": {
    "url": "https://api.example.com/leads?source={{event.source}}",
    "method": "POST",
    "headers": [
      { "name": "Authorization", "value": "Bearer sk_live_...", "secret": true }
    ],
    "body_type": "json",
    "body": {
      "email": "{{contact.email}}",
      "first_name": "{{contact.first_name}}",
      "plan": "{{event.plan}}",
      "seats": "{{event.seats}}"
    },
    "continue_on_failure": false,
    "timeout_seconds": 10
  }
}
```

## Variables

Write `{{scope.path}}` anywhere in the URL, a header value or the body. The scopes are the ones conditions and emails use: `event` (the trigger event's payload), `contact` (email, first_name, last_name and your contact properties), `trigger`, `wait_events`, `email`, `run` and `automation`.

- In a JSON body, a string that is exactly one token keeps the value's type: `"seats": "{{event.seats}}"` sends `5`, not `"5"`. A token inside longer text is replaced as text.
- A missing value becomes an empty string, or `null` for a whole-token JSON value.
- `{"var": "event.plan"}` works in a JSON body too, as in other steps.

## Headers and secrets

- Turn on **secret** for API keys and tokens. A secret value is stored encrypted and never shown again: the API returns `"value": ""` with `"has_value": true`. To keep it when you save, send the header with an empty value. A saved secret is kept only while the URL's host and the header name stay the same; change either and enter the value again.
- `Authorization` is allowed, so Bearer and Basic auth for your own API work.
- send.io sets `Host`, `Content-Length`, `Transfer-Encoding`, `Connection`, `User-Agent` and every `webhook-*` header; headers named `Host`, `Content-Length`, `Transfer-Encoding`, `Connection`, `webhook-*` or `svix-*` are refused.

## Import from cURL or n8n

Importing only reads what you paste. It never calls the URL and never runs anything. The builder's buttons and `POST /automations/http/import` do the same thing.

| From | What is read | Refused or flagged |
| --- | --- | --- |
| cURL | `-X`, `-H`, `-d` / `--data` / `--data-raw` / `--data-binary`, `--data-urlencode`, `--json`, `-u` (becomes a secret Basic `Authorization` header), `-G`, `--url`. Quotes, backslash escapes and backslash line breaks are fine. | Refused: `-F` (multipart), `-T`, `@file` data, cookie files, http:// URLs, a second URL. Dropped with a warning: `-A`, `-k`, `-L`. |
| n8n | HTTP Request nodes, version 1 to 4.x: method, URL, query parameters, headers, JSON / form / raw body, timeout. Paste the copied node (or the whole copied selection). | `={{ $json.field }}` becomes `{{event.field}}` with a warning to check it. Other expressions stay as text with a warning. Credentials are not in an n8n copy: add your auth header. Multipart bodies are refused. |

Headers that look like keys or tokens come back marked secret. With several HTTP Request nodes in one paste, pick one by name (`node`).

Import with the API:

```bash
curl -X POST https://api.send.io/automations/http/import \
  -H "Authorization: Bearer $SENDIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"curl": "curl https://hooks.zapier.com/hooks/catch/123/abc -d email=jane@acme.com"}'
```

## What your endpoint receives

```
POST /leads?source=pricing HTTP/1.1
Host: api.example.com
User-Agent: send.io-workflows/1.0
Content-Type: application/json
Authorization: Bearer sk_live_...
webhook-id: 9d2e4c1a-7b3f-4e6d-8a5c-1f0b2e3d4c5a:sync_crm
webhook-timestamp: 1793006400
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=

{"email":"jane@acme.com","first_name":"Jane","plan":"pro","seats":5}
```

- `webhook-id` is `<run id>:<step key>`, the same on every retry of that call. Store it and skip ids you have already handled.
- `webhook-timestamp` is Unix seconds; `webhook-signature` is `v1,<base64>` (Standard Webhooks).
- Redirects are not followed: a 3xx counts as a failure.

## Verify the signature

Every call is signed with your team's automation signing secret (`whsec_...`). Admins get and rotate it with `GET /automations/signing-secret` (the secret is created the first time it is read) and `POST /automations/signing-secret/rotate` (or the CLI: `sendio automations signing-secret get|rotate`). The signed content is `{webhook-id}.{webhook-timestamp}.{raw body}`, HMAC-SHA256 with the base64-decoded part of the secret after `whsec_`.

Node.js:

```javascript
import crypto from "node:crypto";

// rawBody: the request body exactly as received (a string), before any JSON parsing.
export function verifySendio(rawBody, headers, secret) {
  const id = headers["webhook-id"];
  const ts = headers["webhook-timestamp"];
  if (!id || !ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const expected = crypto.createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64");
  return String(headers["webhook-signature"] ?? "")
    .split(" ")
    .some((part) => {
      const [version, sig] = part.split(",");
      return version === "v1" && sig?.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
    });
}

import express from "express";

const app = express();

app.post("/sendio", express.text({ type: "*/*" }), (req, res) => {
  if (!verifySendio(req.body, req.headers, process.env.SENDIO_WORKFLOW_SECRET)) {
    return res.status(401).end();
  }
  const data = JSON.parse(req.body);
  // req.headers["webhook-id"] is the same on every retry: skip ids you have seen.
  res.status(204).end();
});
```

Python:

```python
import base64
import hashlib
import hmac
import time


# raw_body: the request body exactly as received (bytes), before any JSON parsing.
def verify_sendio(raw_body: bytes, headers, secret: str) -> bool:
    msg_id = headers.get("webhook-id")
    ts = headers.get("webhook-timestamp", "")
    if not msg_id or not ts.isdigit() or abs(time.time() - int(ts)) > 300:
        return False
    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{msg_id}.{ts}.".encode() + raw_body
    expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    for part in headers.get("webhook-signature", "").split(" "):
        version, _, sig = part.partition(",")
        if version == "v1" and hmac.compare_digest(sig, expected):
            return True
    return False


import os

from flask import Flask, abort, request

app = Flask(__name__)


@app.post("/sendio")
def sendio_workflow():
    if not verify_sendio(request.get_data(), request.headers, os.environ["SENDIO_WORKFLOW_SECRET"]):
        abort(401)
    data = request.get_json()
    # request.headers["webhook-id"] is the same on every retry: skip ids you have seen.
    return "", 204
```

> **Note:** Check the raw body, before any JSON parsing: re-serialized JSON does not match the signature. The `standardwebhooks` libraries for Node and Python verify these headers too.

## Success, retries and failures

- Any **2xx** is a success.
- A network error, a timeout, **408**, **425**, **429** or a **5xx** is retried 3 times: after 10 seconds, 1 minute and 5 minutes.
- Any other 4xx fails at once.
- After the last failure, the run stops with the reason, or goes on to the next step if **If the call fails** is set to **Continue anyway** (`continue_on_failure`).
- The run's step output shows `status_code`, `duration_ms`, `attempts`, the first 1 KB of the response (`response_excerpt`) and `error` when it failed, and the request as sent (`request`: method, URL and headers with the variables filled in, and the first 1 KB of the body). Secret headers, headers and URL parameters that look like credentials (a token, key, password or signature) and the signing headers are not shown.
- In the automation's metrics, a step that failed and went on with **Continue anyway** counts as completed and also in `failed_continued`.

The call happens outside the run, so a slow endpoint never holds up other contacts.

## Limits

- https only, to public addresses: private, internal and loopback addresses are refused when you save and again at send time.
- send.io's own API hosts are refused, so an automation cannot call itself in a loop. To start another automation, [send an event](https://app.send.io/docs/api#send-event) from your backend.
- Per team, at most 20 calls a second and 100,000 a day. Calls over the limit wait and go out later; they do not fail.
- Test requests: admins only, at most 10 a minute per team.

## API

- Steps are part of the graph: [create](https://app.send.io/docs/api#create-automation) or [update](https://app.send.io/docs/api#update-automation-draft) an automation with a `webhook` step.
- [Import an HTTP request](https://app.send.io/docs/api#import-automation-http-step): `POST /automations/http/import` with `curl` or `n8n`.
- [Send a test HTTP request](https://app.send.io/docs/api#test-http-step): `POST /automations/http/test`.
- [Retrieve](https://app.send.io/docs/api#get-automation-signing-secret) and [rotate](https://app.send.io/docs/api#rotate-automation-signing-secret) the signing secret.
