Skip to main content
Report the purchases your agent completes with Stripe Link so Gravity can attribute them to Index recommendations and pay you. One server-to-server call per purchase, like the advertiser Conversions API.

How it works

  1. /search returns a recommendation with a grclid, and when the merchant accepts machine payments a checkout pointer the agent can pay directly.
  2. Your agent pays the merchant with Link (or hands the user click_url), keeping the grclid with the spend request.
  3. When the spend request completes, your backend POSTs it to /purchases/report, with the grclid and the buyer’s hashed email.
Send every purchase your agent completes. Some will carry a grclid from an Index result; send the ones that don’t too. Gravity uses the grclid and the hashed email to tie each purchase back to the recommendations it made and credits you for the ones it can. Link CLI (@stripe/link-cli) is a tool the agent calls. The user signs in once with link-cli auth login; US and Canadian Link accounts only for now.
Add to your MCP client config (.mcp.json or equivalent). Every CLI command becomes a tool.
Or run link-cli serve and point your host at http://127.0.0.1:54321/mcp.
From a /search result, recommendation.checkout is either {protocol: "mpp", endpoint, network_id, attribution} (pay endpoint directly; it already carries ?grclid=…) or null (no machine checkout; use click_url). checkout.network_id is the merchant’s Stripe profile_… id; mpp pay reads it from the live 402 itself, so you only need it when creating the spend request by hand (link-cli mpp decode extracts it from a raw WWW-Authenticate header). Link caps a spend request at $500.

2. Report the purchase

When the spend request reaches a terminal status, POST it from your backend. Send everything you have: the merchant, the line items, the amounts, the ids Link gave you, the user’s request that led to the purchase, and the raw Link response if it’s easy. Idempotent on spend_request_id for your publisher, so retries are safe.
X-API-Key is the same publisher key you use for /search. Only spend_request_id and status are required.
string
required
Link lsrq_… id. Dedupe key.
string
required
Final spend-request status: succeeded for a completed purchase. failed, denied, canceled, expired, and approved (approved but charge not observed) are accepted for reconciliation.
Attribution
string
Send it whenever the purchase came from an Index result: checkout.attribution.click_id_value, or the result’s grclid. It must be a grclid issued to a search made with your key. Omit it when there isn’t one.
string
SHA-256 hex of the buyer’s email, trimmed and lowercased (same as hashed_email on /search). Include it on every report.
Merchant
string
As returned on the spend request.
string
acme.com
string
Product or checkout URL.
string
Stripe account or merchant id if you have it.
string
Merchant profile_… from the spend request (MPP only).
Items and amounts (minor units, i.e. cents)
object[]
One per product: name, sku, category, quantity, unit_price, url. Extra keys are kept.
string
ISO 4217, three letters.
integer
integer
integer
Total charged.
Ids and time
string
shared_payment_token, card, or link_pay_token.
string
Merchant or Stripe payment id (pi_…, order id).
ltxn_…
string
ISO 8601 timestamp of the charge.
Context
string
What the user asked for that led to this purchase.
string
Which of your agents bought it.
string
Your conversation / session id.
Anything else
object
Any JSON. Stored as sent, no schema.
The spend request object exactly as link-cli returned it (--format json).
Unknown top-level fields return 422; put anything not listed above in metadata. The JSON fields are capped at 64 KB each. Do not send Link access tokens, Shared Payment Tokens, card numbers, or the raw credential object. Reporting to Gravity is separate from Link’s own link-cli report, which goes to Stripe.

Contact

index@trygravity.ai if your Link setup doesn’t fit one of the shapes above.