ServicesAPISign in

API documentation

Start visits and A/B experiments from your own programs. Requests and answers are JSON.

Base address: https://app.buyergap.com/api/v1. For code generators: openapi.json.

Connect an AI app

BuyerGap works inside Claude, ChatGPT, Cursor and other apps that support MCP. Connect once, then just ask in plain words. The app adds your site, picks customers, starts visits and explains the reports.

Server address: https://app.buyergap.com/mcp

AppHow to connect
Claude (claude.ai, desktop and mobile)Settings, Connectors, Add custom connector. Name: BuyerGap, address: the server address above. Press Connect, sign in to BuyerGap and press Allow.
ChatGPTIn Settings, Apps & Connectors, Advanced settings, turn on Developer mode. Then Create a connector: name BuyerGap, address above, authentication OAuth. Sign in to BuyerGap and press Allow. Your plan must allow custom connectors.
Claude CodeIn a terminal: claude mcp add --transport http buyergap https://app.buyergap.com/mcp, then type /mcp in Claude Code and sign in.
Cursor, VS Code, Windsurf and othersAdd a remote (HTTP) MCP server with the address above. Apps that cannot sign in with OAuth can send an API key: header Authorization: Bearer bg_live_… (create the key in Account).
Example for Cursor (~/.cursor/mcp.json)
{
  "mcpServers": {
    "buyergap": {
      "url": "https://app.buyergap.com/mcp"
    }
  }
}

With a key instead of signing in:

{
  "mcpServers": {
    "buyergap": {
      "url": "https://app.buyergap.com/mcp",
      "headers": {
        "Authorization": "Bearer bg_live_..."
      }
    }
  }
}

What to say

  • “Check my site shop.example.com through a customer’s eyes on a phone.”
  • “Watch my site every week with two customers and tell me when something breaks.”
  • “We released a new checkout. Check the site now.”
  • “Compare my pricing page with the new version at preview.shop.example.com/pricing.”
  • “What did the last report say? What should I fix first?”

Runs and your consent

Every visit uses 1 run from your balance. Before it starts visits, an experiment or watching, the app tells you how many runs it needs and waits for your yes. When watching starts, we also email you with a Stop button. You can disconnect an app at any time in Account. To try without spending anything, connect with a sandbox key (bg_test_…).

Regular checks, step by step

Sites change every week: a new banner, a checkout update, a plugin. Watching sends the same customers on a schedule and tells you when something they need got harder (or easier) to find.

  1. Choose what to watch. Ask your AI app (“Watch my site every week on a phone with Dana and Sam”), open Watching, or call POST /watches. Pick 1 to 5 customers, phone and/or computer, and how often: every day, week or month.
  2. See the cost and agree. Each round uses 1 run for every customer on every device: 2 customers on a phone every week is 2 runs a round, about 9 a month. Nothing starts until you agree.
  3. The first round starts at once. Its reports are the starting point. You get an email that watching started, with a Stop button.
  4. Later rounds are compared with the one before. For every customer we check what they needed: found, partly found or not found. When something gets worse or better, or a visit cannot finish, you get one email for the round (or a webhook to your system).
  5. After a release, check at once. Ask the app “check my site now”, or let your deploy call the API:
curl -X POST "https://app.buyergap.com/api/v1/watches/$WATCH_ID/check"   -H "Authorization: Bearer $BUYERGAP_KEY"   -H "Idempotency-Key: release-$GIT_SHA"

Pause or stop at any time: in the app, on the Watching page, or with POST /watches/{id}/pause and /stop. When your balance is too small, a round is skipped and we tell you once.

Prefer that we choose the customers, connect it to your releases and look after it? We can do it for you.

Quick start

  1. Sign in and create a key in Account. Begin with a sandbox key: it answers in seconds and spends nothing.
  2. Add a site and wait until its status is ready.
  3. Start a run with one of its personas, then read the report.
export BUYERGAP_KEY=bg_test_...

# 1. Add a site
curl -X POST "https://app.buyergap.com/api/v1/sites" \
  -H "Authorization: Bearer $BUYERGAP_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://normal.sandbox.example/"}'

# 2. Repeat until "status" is "ready"; note a persona id
curl "https://app.buyergap.com/api/v1/sites/$SITE_ID" -H "Authorization: Bearer $BUYERGAP_KEY"

# 3. Start a run, then repeat the GET until "status" is "ready"
curl -X POST "https://app.buyergap.com/api/v1/runs" \
  -H "Authorization: Bearer $BUYERGAP_KEY" -H "Content-Type: application/json" \
  -d '{"site_id":"'$SITE_ID'","persona_id":"'$PERSONA_ID'","device":"mobile"}'
curl "https://app.buyergap.com/api/v1/runs/$RUN_ID" -H "Authorization: Bearer $BUYERGAP_KEY"

Keys

Send the key with every request: Authorization: Bearer bg_live_.... Keep it on your server. We store only a fingerprint, so a lost key cannot be shown again: revoke it and create another.

KeyWhat it does
bg_test_…Sandbox. Separate data, nothing is visited, no run is spent. You start with 100 sandbox runs.
bg_live_…Real visits. Spends your balance.

Every answer has the header BuyerGap-Mode.

A/B test, step by step

  1. Add the site with POST /sites and wait until it is ready. The answer lists its personas.
  2. Create the experiment with POST /experiments. Each variant needs its own public address: a preview address, or a parameter such as ?variant=b. Variants chosen by a cookie are not supported.
  3. Wait for the webhook, or repeat GET /experiments/{id} until status is finished.
  4. Read result.comparisons[].verdict: variant_better, control_better, no_clear_difference, not_enough_data or inconclusive.
What the verdict meansIt compares how much of what simulated customers need they can find on each variant. It is not a measured conversion rate, and your visitors are not split. A verdict needs at least 5 persona and device pairs, for example 3 personas on 2 devices.

Account and balance

A run is one persona on one device. The balance is a number of runs.

GET /account

Balance of runs.

Example request
curl "https://app.buyergap.com/api/v1/account" \
  -H "Authorization: Bearer $BUYERGAP_KEY"
Example answer
{
  "mode": "live",
  "balance": 12
}

GET /billing/packs

Packs of runs and their prices.

Example request
curl "https://app.buyergap.com/api/v1/billing/packs" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

POST /billing/checkout

Address of the payment page for a pack. A person pays there; the runs appear in the balance after payment.

Body

{
  "pack_id": "price_..."
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/billing/checkout" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pack_id":"price_..."}'

Sites

A site is read once. Studying it and suggesting three personas is free for your first site and uses 1 run for later ones.

POST /sites

Add a site. personas "suggest" studies it and suggests three customers (the first site is free, later ones may cost runs, see runs_charged); "own" only checks that it opens, free. Repeat the GET until status is "ready".

Body

{
  "url": "https://yourshop.com",
  "personas": "suggest"
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/sites" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Idempotency-Key: any-unique-text" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://yourshop.com","personas":"suggest"}'

GET /sites/{id}

Site status and its personas.

Example request
curl "https://app.buyergap.com/api/v1/sites/$ID" \
  -H "Authorization: Bearer $BUYERGAP_KEY"
Example answer
{
  "id": "b5c1c8f2-0d5e-4b8e-9a57-1f2f3c4d5e6f",
  "url": "https://yourshop.com/",
  "status": "ready",
  "error": null,
  "personas": [
    {
      "id": "b5c1c8f2-0d5e-4b8e-9a57-1f2f3c4d5e6f",
      "name": "Dana, gift buyer",
      "description": "Buys a present for a friend.",
      "goal": "Decide whether a gift can arrive by Friday.",
      "motivation": "A safe choice that arrives on time.",
      "concern": "Can it be exchanged?",
      "requirements": [
        "Delivery time",
        "Return rules"
      ],
      "origin": "suggested"
    }
  ]
}

GET /sites

Your sites with the names of their personas.

Example request
curl "https://app.buyergap.com/api/v1/sites" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

Personas

Every persona belongs to one site. Use the suggested ones, take some from the library or write your own.

GET /personas/library

Ready-made personas. Send one of them, changed or not, to POST /sites/{id}/personas. Free.

Example request
curl "https://app.buyergap.com/api/v1/personas/library" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

POST /sites/{id}/personas

Add a persona: your own or one from the library.

Body

{
  "name": "Dana, gift buyer",
  "description": "...",
  "goal": "...",
  "motivation": "...",
  "concern": "...",
  "requirements": [
    "Delivery time"
  ]
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/sites/$ID/personas" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Dana, gift buyer","description":"...","goal":"...","motivation":"...","concern":"...","requirements":["Delivery time"]}'

POST /sites/{id}/personas/{persona_id}

Change a persona; send only the fields to change. A persona of yours changes on every site it is on.

Body

{
  "goal": "..."
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/sites/$ID/personas/$PERSONA_ID" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"goal":"..."}'

POST /sites/{id}/personas/{persona_id}/delete

Take a persona off this site. Finished reports stay.

Example request
curl -X POST "https://app.buyergap.com/api/v1/sites/$ID/personas/$PERSONA_ID/delete" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Runs and reports

A visit takes about 15 minutes. A visit that fails, is blocked or stops early goes back to your balance.

GET /runs

Your latest runs, newest first. Query: site_id, limit (up to 100).

Example request
curl "https://app.buyergap.com/api/v1/runs" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

POST /runs

Start one run (1 run from the balance).

Body

{
  "site_id": "...",
  "persona_id": "...",
  "device": "mobile",
  "url": "optional other page"
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/runs" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Idempotency-Key: any-unique-text" \
  -H "Content-Type: application/json" \
  -d '{"site_id":"...","persona_id":"...","device":"mobile","url":"optional other page"}'

GET /runs/{id}

Run status and report.

Example request
curl "https://app.buyergap.com/api/v1/runs/$ID" \
  -H "Authorization: Bearer $BUYERGAP_KEY"
Example answer
{
  "id": "b5c1c8f2-0d5e-4b8e-9a57-1f2f3c4d5e6f",
  "site_id": "b5c1c8f2-0d5e-4b8e-9a57-1f2f3c4d5e6f",
  "experiment_id": null,
  "variant": null,
  "persona": "Dana, gift buyer",
  "device": "mobile",
  "status": "ready",
  "charged": true,
  "engine": "app-4c01cb0",
  "created_at": "2026-12-01T11:36:20.000Z",
  "finished_at": "2026-12-01T11:58:02.000Z",
  "report": {
    "summary": "Dana found the price but not the delivery date.",
    "verdict": "Left without buying.",
    "note": null,
    "steps": 24,
    "pages_checked": 18,
    "needs": [
      {
        "need": "Delivery time",
        "status": "not_found",
        "detail": "No date on the product page.",
        "url": "https://yourshop.com/mug"
      }
    ],
    "recommendations": [
      {
        "id": 1,
        "title": "Show the delivery date on the product page",
        "saw": "The page shows a price and no date.",
        "why": "Dana needs it by Friday.",
        "todo": [
          "Add the date next to the button"
        ],
        "priority": 1,
        "kind": "fix",
        "url": "https://yourshop.com/mug",
        "step": 7,
        "screenshot": "https://app.buyergap.com/api/v1/runs/…/frames/0007-original.png"
      }
    ],
    "pdf": "https://app.buyergap.com/api/v1/runs/…/pdf"
  }
}

POST /runs/{id}/cancel

Cancel a run that has not started; it is returned.

Example request
curl -X POST "https://app.buyergap.com/api/v1/runs/$ID/cancel" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

GET /runs/{id}/pdf

Report as PDF.

Example request
curl "https://app.buyergap.com/api/v1/runs/$ID/pdf" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

GET /runs/{id}/frames/{file}

Screenshot of a recommendation.

Example request
curl "https://app.buyergap.com/api/v1/runs/$ID/frames/$FILE" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

Status of a run

StatusMeaningCharged
queuedWaiting
visiting, checking, buildingIn progress
readyThe report is completeyes
partialThe visit stopped early; what was seen is in the reportreturned
blockedThe site stopped our browserreturned
failed, cancelledNo reportreturned

A/B experiments

The same personas visit 2 to 4 addresses. The first variant is the control.

POST /experiments

Compare 2 to 4 addresses with the same personas. The first variant is the control. Runs = variants x personas x devices x repeats.

Body

{
  "site_id": "...",
  "name": "New pricing page",
  "variants": [
    {
      "name": "A",
      "url": "https://yourshop.com/pricing"
    },
    {
      "name": "B",
      "url": "https://preview.yourshop.com/pricing"
    }
  ],
  "persona_ids": [
    "...",
    "...",
    "..."
  ],
  "devices": [
    "desktop",
    "mobile"
  ],
  "repeats": 1,
  "webhook_url": "https://your.system/hook"
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/experiments" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Idempotency-Key: any-unique-text" \
  -H "Content-Type: application/json" \
  -d '{"site_id":"...","name":"New pricing page","variants":[{"name":"A","url":"https://yourshop.com/pricing"},{"name":"B","url":"https://preview.yourshop.com/pricing"}],"persona_ids":["...","...","..."],"devices":["desktop","mobile"],"repeats":1,"webhook_url":"https://your.system/hook"}'

GET /experiments/{id}

Progress, runs and the result.

Example request
curl "https://app.buyergap.com/api/v1/experiments/$ID" \
  -H "Authorization: Bearer $BUYERGAP_KEY"
Example answer
{
  "id": "b5c1c8f2-0d5e-4b8e-9a57-1f2f3c4d5e6f",
  "name": "New pricing page",
  "site_id": "b5c1c8f2-0d5e-4b8e-9a57-1f2f3c4d5e6f",
  "status": "finished",
  "variants": [
    {
      "name": "A",
      "url": "https://yourshop.com/pricing"
    },
    {
      "name": "B",
      "url": "https://preview.yourshop.com/pricing"
    }
  ],
  "devices": [
    "desktop",
    "mobile"
  ],
  "repeats": 1,
  "progress": {
    "total": 12,
    "finished": 12,
    "ready": 12
  },
  "created_at": "2026-12-01T09:00:00.000Z",
  "finished_at": "2026-12-01T13:10:00.000Z",
  "result": {
    "comparisons": [
      {
        "control": "A",
        "variant": "B",
        "verdict": "variant_better",
        "pairs": 6,
        "variant_better_in": 6,
        "control_better_in": 0,
        "equal_in": 0,
        "mean_difference": 0.31,
        "p_value": 0.031
      }
    ]
  },
  "runs": []
}

POST /experiments/{id}/cancel

Cancel the runs that have not started; they are returned.

Example request
curl -X POST "https://app.buyergap.com/api/v1/experiments/$ID/cancel" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Watching

The same personas visit a site every day, week or month; each round is compared with the one before.

POST /watches

Watch a site: the same personas visit it every day, week or month, and you hear when something changed. The first round starts at once. Each round uses runs_per_round runs. Send dry_run: true first to see the cost.

Body

{
  "site_id": "...",
  "persona_ids": [
    "...",
    "..."
  ],
  "devices": [
    "mobile"
  ],
  "every": "week",
  "notify": "changes",
  "url": "optional page to start from",
  "webhook_url": "https://your.system/hook"
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/watches" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"site_id":"...","persona_ids":["...","..."],"devices":["mobile"],"every":"week","notify":"changes","url":"optional page to start from","webhook_url":"https://your.system/hook"}'

GET /watches

Your watches that are not stopped.

Example request
curl "https://app.buyergap.com/api/v1/watches" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

GET /watches/{id}

A watch and its last rounds: what got worse or better since the round before. Query: rounds (up to 20).

Example request
curl "https://app.buyergap.com/api/v1/watches/$ID" \
  -H "Authorization: Bearer $BUYERGAP_KEY"

POST /watches/{id}/check

Start a round now, for example after a release (uses runs_per_round runs). The schedule does not change.

Example request
curl -X POST "https://app.buyergap.com/api/v1/watches/$ID/check" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /watches/{id}/pause

Pause: no rounds until you resume.

Example request
curl -X POST "https://app.buyergap.com/api/v1/watches/$ID/pause" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /watches/{id}/resume

Resume a paused watch; the next round is one period away.

Example request
curl -X POST "https://app.buyergap.com/api/v1/watches/$ID/resume" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /watches/{id}/stop

Stop for good. Runs not started yet are returned.

Example request
curl -X POST "https://app.buyergap.com/api/v1/watches/$ID/stop" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Sandbox

Only for keys that start with bg_test_.

POST /sandbox/balance

Sandbox keys only: set the sandbox balance, for example 0 to see the not_enough_runs error.

Body

{
  "balance": 0
}
Example request
curl -X POST "https://app.buyergap.com/api/v1/sandbox/balance" \
  -H "Authorization: Bearer $BUYERGAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"balance":0}'

The address decides what happens, so you can test every case:

AddressOutcome
https://better.sandbox.example/finds everything
https://worse.sandbox.example/finds nothing
https://fail.sandbox.example/the visit fails and is returned
https://blocked.sandbox.example/the site blocks the visit, returned
https://partial.sandbox.example/the visit stops early, returned
any other addressa mixed report

A site is ready in about 5 seconds, a run in about 15.

Webhooks

Give webhook_url when you create an experiment or a watch. We send a POST when the experiment ends or a round of the watch is done (type watch.round) and try 6 times in about 9 hours. The header BuyerGap-Signature: t=TIME,v1=HEX proves it is ours: HEX is HMAC-SHA256 of TIME.BODY with the webhook_secret from the answer to POST /experiments. Check it before you trust the body:

import { createHmac, timingSafeEqual } from 'node:crypto';

function isFromBuyerGap(rawBody, header, secret) {
  const t = /t=(\d+)/.exec(header)?.[1], v1 = /v1=([0-9a-f]+)/.exec(header)?.[1];
  if (!t || !v1 || Math.abs(Date.now() / 1000 - t) > 300) return false;
  const want = createHmac('sha256', secret).update(t + '.' + rawBody).digest();
  const got = Buffer.from(v1, 'hex');
  return got.length === want.length && timingSafeEqual(got, want);
}

Errors and limits

{
  "error": {
    "code": "not_enough_runs",
    "message": "You need 12 runs and have 3."
  }
}
HTTPCodeWhat to do
400invalid_requestFix the request; the message says what is wrong
401unauthorizedCheck the key
402not_enough_runsBuy runs
403forbiddenThe account is paused, or the request needs another kind of key
404not_foundThe id is wrong or belongs to another account
409site_not_ready, conflict, idempotency_conflictWait, or use a new Idempotency-Key
429too_many_requestsWait a minute
500server_errorRepeat with the same Idempotency-Key
  • Up to 120 requests a minute.
  • Send Idempotency-Key with every POST that spends runs. A repeated request gets the first answer and is not charged again.