# Placements, numbers and conversions

> Look up the REST routes for placements, credentials, the conversion mapping and log, ad accounts and reported numbers, with their fields and who may call them.

The REST routes for placements, numbers and conversions, generated with `npm run openapi` from the schemas Handline validates every request with. Routes are under `https://app.handline.io/api/v1` and take `Authorization: Bearer <key or token>`; the ids in braces are path parameters. The OpenAPI document is at `https://app.handline.io/api/v1/openapi.json`.

A `GET` or `DELETE` takes its fields as query parameters: numbers and `true` or `false` are read as such, and a repeated key is a list. Other methods take a JSON body with `content-type: application/json`.

## `POST /products/{productId}/placements`

Record a placement: where a concept is live, with the outside tool’s ids, countries and budget. Call this after writing the ad or sequence into the outside tool. The concept must be approved, its copy and page the concept’s own (a page not retired), the countries allowed, the budget inside the cell’s allocation, and the outside ids new to this product. On a channel with strict country rules (outbound, email), name every country the placement targets: none is allowed until the ground rules allow it. On outbound, say in trigger why these recipients are being contacted now.

**Operation:** `placements.record`, MCP tool `placements_record`. **Who:** owners, admins and editors (`placements.record`); agent keys with `report`.

| Body | Type | Required | Rules |
| --- | --- | --- | --- |
| `conceptId` | string | Yes |  |
| `copyId` | string | No |  |
| `pageId` | string | No |  |
| `creativeIds` | string[] | No | At most 20 items. |
| `channelId` | string | Yes |  |
| `audienceId` | string | No |  |
| `outsideIds` | object | Yes | Any keys; each value string. |
| `countries` | string[] | No | At most 250 items. Each matches `^[A-Z]{2}$`. Default `[]`. |
| `budget` | object | No |  |
| `budget.daily` | number or null | No | At least 0. |
| `budget.monthly` | number or null | No | At least 0. |
| `status` | string | No | One of `planned`, `live`. Default `planned`. |
| `platformTest` | object | No |  |
| `platformTest.testId` | string | Yes |  |
| `platformTest.armId` | string | Yes |  |
| `aiLabel` | string | No | At most 200 characters. |
| `trigger` | string | No | 3 to 500 characters. |

## `PATCH /products/{productId}/placements/{placementId}`

Update a placement: its status, budget, countries, trigger or outside ids. Send only what changes. A new copy or page is checked as placements.record checks it, and an ended placement stays ended.

**Operation:** `placements.update`, MCP tool `placements_update`. **Who:** owners, admins and editors (`placements.record`); agent keys with `report`.

| Body | Type | Required | Rules |
| --- | --- | --- | --- |
| `status` | string | No | One of `planned`, `live`, `paused`, `ended`. |
| `budget` | object | No |  |
| `budget.daily` | number or null | No | At least 0. |
| `budget.monthly` | number or null | No | At least 0. |
| `countries` | string[] | No | At most 250 items. Each matches `^[A-Z]{2}$`. |
| `outsideIds` | object | No | Any keys; each value string. |
| `copyId` | string or null | No |  |
| `pageId` | string or null | No |  |
| `creativeIds` | string[] | No | At most 20 items. |
| `aiLabel` | string or null | No | At most 200 characters. |
| `trigger` | string or null | No | 3 to 500 characters. |

## `GET /products/{productId}/placements`

List placements, filtered by status, concept or channel. Status "live" lists what is live now.

**Operation:** `placements.list`, MCP tool `placements_list`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`.

| Query | Type | Required | Rules |
| --- | --- | --- | --- |
| `status` | string | No | One of `planned`, `live`, `paused`, `ended`. |
| `conceptId` | string | No |  |
| `channelId` | string | No |  |

## `GET /products/{productId}/credentials`

List the product’s platform credentials: that each exists, when it was set and when it last worked. Never the secret.

**Operation:** `credentials.list`, MCP tool `credentials_list`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`. **Outside text:** `credentials.[].lastError`.

No query parameters.

## `GET /products/{productId}/conversion-mapping`

Read which outcome stage becomes which conversion on each channel.

**Operation:** `conversions.mapping`, MCP tool `conversions_mapping`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`.

No query parameters.

## `PUT /products/{productId}/conversion-mapping/{channelId}`

Map outcome stages to a channel’s conversion actions: one primary, and whether to send a value. Start with the earliest stage that has steady volume, so the platform has enough to learn from. Move the primary to a later stage as weekly volume grows.

**Operation:** `conversions.setMapping`, MCP tool `conversions_setMapping`. **Who:** owners and admins (`products.settings`); not agent keys.

| Body | Type | Required | Rules |
| --- | --- | --- | --- |
| `destination` | object | Yes | Any keys; each value string. |
| `stages` | object[] | Yes | At most 12 items. |
| `stages[].stage` | string | Yes |  |
| `stages[].action` | string | Yes | 1 to 200 characters. |
| `stages[].primary` | boolean | No | Default `false`. |
| `stages[].sendValue` | boolean | No | Default `false`. |
| `hashedIdentifiers` | boolean | No |  |

## `GET /products/{productId}/conversions`

The delivery log: every conversion with its status, the platform’s answers and each attempt.

**Operation:** `conversions.log`, MCP tool `conversions_log`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`. **Outside text:** `conversions.[].reason`, `conversions.[].attempts.[].response`.

| Query | Type | Required | Rules |
| --- | --- | --- | --- |
| `channelId` | string | No |  |
| `status` | string | No | One of `queued`, `accepted`, `rejected`, `not_sent`. |
| `limit` | integer | No | From 1 to 500. Default `100`. |

## `GET /products/{productId}/conversions/counts`

Per channel and day: outcomes, eligible conversions, and how many were sent, accepted, rejected, not sent or still queued.

**Operation:** `conversions.counts`, MCP tool `conversions_counts`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`.

| Query | Type | Required | Rules |
| --- | --- | --- | --- |
| `from` | string | Yes | A date, YYYY-MM-DD. |
| `to` | string | Yes | A date, YYYY-MM-DD. |

## `GET /products/{productId}/ad-accounts`

List the connected ad accounts, with when each was last read and whether the read worked.

**Operation:** `adAccounts.list`, MCP tool `adAccounts_list`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`. **Outside text:** `adAccounts.[].name`, `adAccounts.[].lastSync.message`.

No query parameters.

## `POST /products/{productId}/numbers`

Report a tool’s raw number rows for a channel, keyed by the tool’s own ids and a day. Pass the outside tool’s rows through untouched: raw counts and spend only, never a rate, a ratio or a cost per result. Send `rows` or a `csv` in the tool’s export format. Reporting the same id and day again replaces the earlier row and keeps it in history. Rows that match no placement are kept as unmatched.

**Operation:** `numbers.report`, MCP tool `numbers_report`. **Who:** owners, admins and editors (`numbers.report`); agent keys with `report`. **Outside text:** `unmatched.[].name`, `flagged.[].name`.

| Body | Type | Required | Rules |
| --- | --- | --- | --- |
| `channelId` | string | Yes |  |
| `source` | string | Yes | 1 to 100 characters. |
| `rows` | object[] | No | At most 5000 items. |
| `rows[].outsideId` | string | Yes | 1 to 200 characters. |
| `rows[].day` | string | Yes | Matches `^\d{4}-\d{2}-\d{2}$`. |
| `rows[].columns` | object | Yes | Any keys; each value number. |
| `rows[].name` | string | No | At most 300 characters. |
| `csv` | string | No | At most 5000000 characters. |
| `timezone` | string | No |  |
| `currency` | string | No | Matches `^[A-Z]{3}$`. |

## `GET /products/{productId}/numbers`

List number rows, read or reported, with where each came from. Filter by day, channel, placement or unmatched.

**Operation:** `numbers.list`, MCP tool `numbers_list`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`. **Outside text:** `rows.[].names.ad`, `rows.[].names.campaign`, `rows.[].reportedBy.sourceName`.

| Query | Type | Required | Rules |
| --- | --- | --- | --- |
| `from` | string | Yes | Matches `^\d{4}-\d{2}-\d{2}$`. |
| `to` | string | Yes | Matches `^\d{4}-\d{2}-\d{2}$`. |
| `source` | string | No | One of `read`, `reported`. |
| `channelId` | string | No |  |
| `placementId` | string | No |  |
| `unmatched` | boolean | No |  |
| `limit` | integer | No | From 1 to 2000. Default `500`. |

## `GET /products/{productId}/numbers/{rowId}/history`

The earlier versions of a number row, replaced by a re-read or a later report.

**Operation:** `numbers.history`, MCP tool `numbers_history`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`. **Outside text:** `history.[].names.ad`, `history.[].names.campaign`, `history.[].reportedBy.sourceName`, `current.names.ad`, `current.names.campaign`, `current.reportedBy.sourceName`.

No query parameters.

## `GET /products/{productId}/numbers/sources`

Where each channel’s numbers come from, read or reported, when they last arrived, and whether they are stale.

**Operation:** `numbers.sources`, MCP tool `numbers_sources`. **Who:** owners, admins, editors and viewers (`record.read`); agent keys with `read`.

No query parameters.

## `POST /products/{productId}/ad-accounts/{adAccountId}/sync`

Read a connected ad account now, instead of waiting for the daily read.

**Operation:** `numbers.sync`, MCP tool `numbers_sync`. **Who:** owners, admins and editors (`numbers.report`); agent keys with `report`.

No body.
