DocsConversions API

Conversions API

Report payments, refunds and leads from your own server: the key, the request, idempotent retries, batches, outcomes and errors.

On this page

Overview#

The conversions API lets your own server report a payment or a lead: after your checkout confirms an order, your CRM closes a deal, or a back office books a refund. It is the right tool when a payment processor has no connection here, or when your server already knows the truth about an order.

It is one endpoint, POST /api/public/v1/conversions, included in the Growth and Agency plans. Each report is written to the site's revenue ledger. If it carries a visitor token that matches a visitor who saw an experiment, the revenue is credited to the variant they saw; otherwise it is recorded as unmatched site-level revenue that never decides a winner.

Browser revenue is advisory

Revenue reported from the browser with lift.revenue() can be forged by anyone who knows the public site key, so it cannot pick a winner on its own. Payments reported by a server, with a token we issued, are the revenue that can.

The API key#

Create a key with the conversions scope under Settings → API keys (admin role). Such a key is bound to one site when it is created, and it can do one thing: record conversions for that site. It cannot read anything, write anything else, or touch another site, and it is never combined with the read or write scope.

Keys start with lift_sk_ and are secrets: keep them on a server. The full key is shown once. Send it as a bearer token.

Report a purchasebash
curl -X POST https://lift.example.com/api/public/v1/conversions \
  -H "Authorization: Bearer lift_sk_YOUR_CONVERSIONS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "externalId": "order-1001",
    "amount": "49.99",
    "currency": "USD",
    "occurredAt": "2026-03-20T12:00:00Z",
    "visitorToken": "lvt_0123456789abcdef0123456789abcdef"
  }'

The request#

The body is one JSON object, or { "conversions": [ … ] } with up to 100 of them. Unknown fields are refused: nothing that identifies a person is accepted.

FieldRequiredMeaning
externalIdYesYour id of this payment or lead, up to 255 characters of letters, digits and . _ : ~ = + / -. It is the idempotency key.
currencyYesThree letters. It must be the currency the site records revenue in; any other is refused, not converted.
amountOne of amount, amountMinorA decimal in major units, as a string or a number: "49.99". More decimals than the currency has are refused.
amountMinorOne of amount, amountMinorAn integer in minor units (cents): 4999. Never send both amount fields.
kindNopurchase (default), lead, refund or adjustment. A lead may leave out the amount.
occurredAtNoISO 8601 with an offset. Default: the time of the request. A time more than 5 minutes ahead is refused.
visitorTokenNoThe token your checkout carried (how). Without it the payment is unmatched.
orderIdNoFor a purchase, the id a later refund will point at (default: externalId). For a refund, the orderId of the original payment, so the refund finds its visitor.
goalIdNoThe revenue goal to credit. Default: the site's only revenue goal, when it has exactly one.
siteKeyNoThe public key of the site. Leave it out: the key already names its site. A different site key answers 404.

Kinds: purchase, lead, refund, adjustment. Send amounts as positive numbers: a refund is stored as a negative amount for you.

What comes back#

A single conversion answers 200 with the outcome (this endpoint does not wrap its answer in data):

Matched to a visitorjson
{
  "outcome": "matched",
  "ledgerId": "0198c1dd-…"
}
Recorded as site-level revenuejson
{
  "outcome": "unmatched",
  "ledgerId": "0198c1de-…",
  "reason": "no_token"
}
outcomeMeaning
matchedRecorded and credited to the variant of a visitor who was exposed inside the attribution window.
unmatchedRecorded as site-level revenue. reason says why it has no visitor (no token, an unknown or expired token, no exposure, outside the window, or a refund whose original payment is not in the ledger). See how a payment is matched.
duplicateThis externalId was recorded before: nothing changed.

Retrying safely#

The same externalId of the same kind is recorded once, however often you send it. Retry any request that failed with 429 or a 5xx status, or that timed out, without fear of counting a payment twice. A 4xx other than 429 will not succeed on retry: fix the request.

A retrying senderjs
// Safe to retry: the same externalId is recorded once.
async function reportPayment(payment) {
  for (let attempt = 0; attempt < 5; attempt += 1) {
    const response = await fetch('https://lift.example.com/api/public/v1/conversions', {
      method: 'POST',
      headers: {
        Authorization: 'Bearer ' + process.env.LIFT_CONVERSIONS_KEY,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        externalId: payment.id,
        amountMinor: payment.amountCents,
        currency: 'USD',
        visitorToken: payment.liftToken, // may be missing: the payment is then unmatched
      }),
    });
    if (response.ok) return response.json();
    if (response.status !== 429 && response.status < 500) {
      throw new Error('Rejected: ' + response.status);
    }
    const wait = Number(response.headers.get('retry-after')) || 2 ** attempt;
    await new Promise((resolve) => setTimeout(resolve, wait * 1000));
  }
  throw new Error('Still failing after 5 attempts');
}

Refunds and leads#

Refunds

Send kind: "refund" with a positive amount and the orderId of the original payment. The refund is subtracted from the same variant the payment was credited to. A refund whose original payment is not in the ledger is recorded at site level.

A refundjson
{
  "externalId": "refund-9001",
  "kind": "refund",
  "amount": "12.00",
  "currency": "USD",
  "orderId": "order-1001"
}

Leads

A lead (a form turned into a deal, a booked call) needs no amount. If you know its value, send it.

A leadjson
{
  "externalId": "lead-5521",
  "kind": "lead",
  "currency": "USD",
  "visitorToken": "lvt_0123456789abcdef0123456789abcdef"
}

Batches#

Send up to 100 conversions in one request. Each is judged on its own: one that fails does not stop the others. The answer has one entry per conversion, in order. The plan check applies to the whole request.

Requestjson
{
  "conversions": [
    { "externalId": "order-1001", "amount": "49.99", "currency": "USD" },
    { "externalId": "order-1002", "amountMinor": 12900, "currency": "USD" }
  ]
}
200 OKjson
{
  "results": [
    { "ok": true, "result": { "outcome": "unmatched", "ledgerId": "0198c1de-…", "reason": "no_token" } },
    { "ok": false, "error": { "code": "validation", "message": "…" } }
  ]
}

Errors and limits#

StatusWhen
401The key is missing, malformed, revoked or expired.
402The organization's plan does not include the revenue ledger (Growth and Agency do).
403The key does not have the conversions scope, or is not bound to a site.
404The site key is not the key's site, or does not exist.
413The body is larger than 262144 bytes.
422The body is invalid, or the currency is not the one the site records revenue in. error.fieldErrors names the fields.
429Too many requests. Wait for Retry-After seconds.
  • Each key can make 120 requests per minute; the x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-reset headers say where you stand. Use batches for bulk loads.
  • Every response carries an x-request-id to quote to support.
  • A refused payment in the wrong currency is stored for visibility but counted nowhere. This version has one currency per site.