# Report outcomes

> Report each stage your product's users reach to the outcomes API, with the visit token when you have one, so Handline can trace results and send conversions.

Report an outcome every time someone reaches one of the product's stages: signed up, activated, paid, or for a sales-led product, a lead, a meeting, an opportunity or a win. Report it from your server, with or without a token.

## Before you start

- **The product key.** An owner or admin creates it on **Keys** in the product's settings. It starts with `hl_prod_` and is shown once. Keep it on your server, such as in `HANDLINE_PRODUCT_KEY`. It can only report outcomes and delete a visitor's data.
- **The product id.** It is in the product's address in Handline, `/p/<product id>/`, and starts with `prd_`.
- **The stage ids.** They are set on **Outcome stages**: `signed-up`, `activated` and `paid` for a self-serve product; `lead`, `meeting`, `opportunity` and `won` for a sales-led one, unless your team changed them.

## Send the request

`POST https://app.handline.io/api/v1/products/{productId}/outcomes`, operation `outcomes.report`, with `Authorization: Bearer <product key>` and a JSON body.

```bash
curl https://app.handline.io/api/v1/products/prd_01J…/outcomes \
  -H "Authorization: Bearer $HANDLINE_PRODUCT_KEY" \
  -H "content-type: application/json" \
  -d '{"stage":"signed-up","externalId":"acct_8812","token":"v1.eyJ…","occurredAt":"2026-11-22T09:14:03Z"}'
```

With the [helper package](/docs/developers/helper-package), `reportOutcome` sends the same request.

::field{name="stage" type="string" required}
One of the product's live stages. A retired or unknown stage is refused, with the stages you can use.

::field{name="externalId" type="string" required}
Your own opaque id for who reached the stage, such as the account id, 1 to 200 characters. Never an email or a name: an id that looks like an email is refused.

::field{name="token" type="string or null"}
The visit token kept at sign-up, up to 400 characters. Leave it out, or send `null`, when there is none.

::field{name="occurredAt" type="string"}
When it happened, ISO 8601 with an offset. Defaults to when Handline receives it. An outcome more than 90 days old is recorded as late.

::field{name="value" type="object"}
`{ "amount": 49, "currency": "EUR" }`: a non-negative amount and a three-letter currency code. Kept only for stages that carry a value, such as `paid`.

::field{name="hashedEmail" type="string"}
SHA-256, as 64 lower-case hex characters, of the trimmed, lower-case email. Handline forwards it to an ad platform only when the product allows it and the visitor consented, and never stores it. A plain email is refused.

::field{name="test" type="boolean"}
A test outcome while setting up: shown on the set-up checklist, never in results, never sent on.

## Read the answer

```json
{
  "outcome": { "id": "out_3f…", "stage": "signed-up", "traced": true, "late": false, "test": false, "inherited": false },
  "duplicate": false,
  "conversions": [{ "id": "cnv_…", "channelId": "meta", "status": "queued", "reason": null }]
}
```

- `traced` is whether Handline joined the outcome to a visit.
- `inherited` is true when a later stage had no token and was joined through an earlier stage with the same `externalId`.
- `conversions` lists what goes to the ad platform the visit came from. Each is `queued`, or `not_sent` or `rejected` with the reason, such as no consent or the platform's age limit.

## Rules that make retries safe

- **The same stage and `externalId` is recorded once.** Reporting it again answers `"duplicate": true` and changes nothing, so retry freely.
- **A later stage can leave out the token.** Report it with the same `externalId`, and Handline joins it to the visit of the earlier traced stage.
- **One click converts once per stage.** A second account on the same token is recorded, but sends no second conversion.
- **Report every outcome**, traced or not. Handline shows the share it can trace; a sudden drop opens a work item.

## Errors and limits

Every error has `error.code`, `error.message` and `error.next`, which says what to do, and `error.details` naming each field to fix.

| Status | Means |
| --- | --- |
| 400 | The body is not valid. `error.details` says which field and how to fix it. |
| 401 | No valid key. Send `Authorization: Bearer <product key>`. |
| 403 or 404 | The key can't call this route, or the product isn't the key's. |
| 429 | Rate limited: a product key may make 1,200 calls a minute. Retry after the seconds in `retry-after`. |

## Later stages from a CRM or an agent

For a sales-led product, your CRM or your agent reports `meeting`, `opportunity` and `won` the same way. Use the `externalId` and token from the [lead form delivery](/docs/developers/lead-forms). An agent key with the `report` scope can call the MCP tool `outcomes_report`.

## Delete one visitor's data

With the same product key, `POST /api/v1/products/{productId}/privacy/delete` (operation `privacy.deleteVisits`) with `{ "token": "v1.…" }` or `{ "outcomeId": "out_…" }`. See [delete data](/docs/privacy/deletion).
