# Let the dimmi agent call your API

Configure your API endpoints or MCP server for dimmi agent actions: auth, request headers, status codes, timeouts, and retries.

Every [agent action](/ai/actions/) sends one HTTPS request from dimmi to your backend using the connection configured in **Settings → Actions**.

Your endpoint must sit on a public address. dimmi blocks private, loopback, and link-local IPs.

## Authentication methods

Pick how dimmi authenticates on your connection:

| Connection setting | What dimmi sends |
| --- | --- |
| **No auth** | No credentials. |
| **Bearer token** | `Authorization: Bearer <token>` |
| **API key in a header** | Your key in the header name you specify. |
| **API key in the query** | Your key in the query parameter you specify. |
| **Username and password** | `Authorization: Basic <base64(username:password)>` |

## Headers dimmi sends

| Header | Value |
| --- | --- |
| `Dimmi-Action` | Tool name, such as `refund_invoice`. |
| `Dimmi-Action-Call` | Unique call ID (`aax_...`). |
| `Dimmi-Workspace` | Workspace ID (`ws_...`). |
| `Idempotency-Key` | Same call ID, included on actions set to **Changes data**. |
| `User-Agent` | `Dimmi-Actions/1 (+https://trydimmi.com/docs/ai/actions/)` |
| `Content-Type` | `application/json`, or `application/x-www-form-urlencoded` for form encoding. |

dimmi fills `{input.*}` from the agent and `{contact.*}` from the customer's [verified identity](/developers/messenger/identity-verification/). Because the AI model cannot alter `{contact.*}` values, your backend can trust them as the caller's identity.

```js title="server.js"

const app = express();
app.use(express.json());

const invoices = new Map([["inv_1042", { customer: "cus_812", refunded: false }]]);
const answers = new Map(); // Use your database in production.

app.post("/v1/invoices/:id/refunds", (req, res) => {
  if (req.get("Authorization") !== `Bearer ${process.env.DIMMI_ACTIONS_TOKEN}`) {
    return res.status(401).end();
  }

  const key = req.get("Idempotency-Key");
  if (answers.has(key)) {
    return res.json(answers.get(key));
  }

  const invoice = invoices.get(req.params.id);
  if (!invoice || invoice.customer !== req.body.customer_id) {
    return res.status(404).json({ error: { message: "No such invoice." } });
  }
  if (invoice.refunded) {
    return res.status(409).json({ error: { message: "This invoice is already refunded." } });
  }

  invoice.refunded = true;
  const answer = { refund_id: "re_301", status: "pending" };
  answers.set(key, answer);
  res.json(answer);
});

app.listen(3000);
```

Set `DIMMI_ACTIONS_TOKEN` to your connection's bearer token, and configure the action body as `{"customer_id": "{contact.external_id}"}`.

## How dimmi handles your HTTP status

| Status code | Behavior |
| --- | --- |
| `2xx` | Passes the fields listed in **Fields to keep** (or the full body) to the agent. Non-JSON bodies pass as text. |
| `400`, `409`, `422` | Tells the agent the call was declined, including up to 300 characters from your error message (configure `error_message_path`, like `error.message`, via the [REST API](/api-reference/)). |
| `404` | Tells the agent nothing was found, with the same message. |
| `401`, `403` | Fails the call. Three consecutive auth failures pause the connection until **Test connection** succeeds. |
| `429` | Fails the call as rate limited. |
| `3xx` | Fails the call (dimmi never follows redirects). |
| `502`, `503`, `504`, timeout, or connection error | Retries once for **Only reads data** actions. Never retries **Changes data** actions. |
| Any other status | Fails the call. |

## Limits and timeouts

| Limit | Value |
| --- | --- |
| Request timeout | 8 seconds default (configurable 2 to 15 seconds on the connection). |
| Max response body | 65,536 bytes default (`response_max_bytes` configurable 1,024 to 262,144 via API). |
| Result given to the agent | Up to 8 KB after field mapping (lists capped at 20 items, plain text at 4,000 chars). |
| Default headers per connection | Up to 10 headers (256 characters per value). |

Actions requiring customer confirmation or teammate approval send the exact same request once approved, up to 7 days after the agent proposed it.

## Connect an MCP server instead

Create an **MCP server** connection to call a remote Streamable HTTP MCP server, turning each synced tool into an action.

- **Auth:** supports **No auth**, **Bearer token**, or **API key in a header**.
- **Headers:** sends `Dimmi-Action`, `Dimmi-Action-Call`, `Dimmi-Workspace`, and `Idempotency-Key` (on **Changes data** tools).
- **Sessions:** opens and closes a fresh session per tool call.
- **Responses:** maps `structuredContent` like JSON (falling back to text). Tools returning `isError` pass up to 300 characters as a refusal to the agent.
- **Tool sync limit:** **Sync tools** imports up to 200 tools per server.

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
