Skip to main content
This page tells you how to report to Gravity the purchases that your agent completes with Stripe Link. You send one server-to-server call for each purchase, like the advertiser Conversions API.
Now, /purchases/report only records the purchase. A report does not create a charge, an attribution, or a payout by itself. Attribution and payouts come from the advertiser conversion feed. Gravity stores the grclid and the hashed email so that it can connect each purchase to your Index searches.

How it works

  1. /search returns a recommendation with a grclid (Gravity click ID). If the merchant accepts machine payments, the recommendation also has a checkout pointer that the agent can pay directly.
  2. Your agent pays the merchant with Link, or gives the user click_url. Keep the grclid with the spend request.
  3. When the spend request is complete, your backend sends it to /purchases/report with the grclid and the buyer’s hashed email.
Send every purchase that your agent completes. Some purchases have a grclid from an Index result. Send the purchases without a grclid too.

Before you start

  • Get your publisher API key. This is the key that you use for /search.
  • Install the Link CLI (@stripe/link-cli) for your agent.
The Link CLI is a tool that the agent calls. The user signs in one time with link-cli auth login. Only US and Canadian Link accounts are supported now.
Add the Link MCP server to your MCP client config (.mcp.json or an equivalent file). Each CLI command becomes a tool.
Or run link-cli serve and point your host at http://127.0.0.1:54321/mcp.
In a /search result, recommendation.checkout has one of two values:
  • {protocol: "mpp", endpoint, network_id, attribution}: pay endpoint directly. It already contains ?grclid= and the click ID.
  • null: there is no machine checkout. Use click_url.
checkout.network_id is the merchant’s Stripe profile_ ID. It can be null. mpp pay reads the ID from the live 402 response, so you need it only when you create the spend request yourself. link-cli mpp decode gets the ID from a raw WWW-Authenticate header. Link limits a spend request to $500.

2. Report the purchase

When the spend request gets to a final status, send it from your backend. Send all the data that you have: the merchant, the line items, the amounts, the IDs from Link, the user’s request that caused the purchase, and the raw Link response. The endpoint is idempotent on spend_request_id for your publisher, so a retry is safe.

Authentication

Send your publisher API key in the X-API-Key header. This endpoint does not accept the key in the body.

Request fields

Only spend_request_id and status are required.
string
required
The Link lsrq_ ID, up to 64 characters. Gravity uses it to remove duplicates.
string
required
The final status of the spend request. Use succeeded for a completed purchase. The endpoint also accepts failed, denied, canceled, expired, and approved (approved, but you did not see the charge) for reconciliation.
Attribution
string
Send it when the purchase came from an Index result: use checkout.attribution.click_id_value or the result’s grclid. It must be a grclid from a search that you made with your key. Leave it out when there is none.
string
The SHA-256 hash of the buyer’s email as 64 hex characters, after you trim it and change it to lowercase. This is the same format as hashed_email on /search. Include it in every report.
Merchant
string
The merchant name from the spend request.
string
For example acme.com.
string
The product or checkout URL.
string
The Stripe account ID or merchant ID, if you have it.
string
The merchant profile_ ID from the spend request (MPP only).
Items and amounts (in minor units, for example cents)
object[]
One item for each product: name, sku, category, quantity, unit_price, url. Gravity keeps other keys too. Up to 500 items.
string
An ISO 4217 code, three letters.
integer
integer
integer
The total that the merchant charged.
IDs and time
string
shared_payment_token, card, or link_pay_token.
string
The merchant or Stripe payment ID (pi_ ID, or an order ID).
The ltxn_ ID.
string
The ISO 8601 time of the charge.
Context
string
What the user asked for that caused this purchase.
string
The agent of yours that made the purchase.
string
Your conversation or session ID.
Other data
object
Any JSON. Gravity stores it as you send it, with no schema.
The spend request object exactly as link-cli returned it (--format json).
Unknown top-level fields return 422. Put other data in metadata. Each of metadata, line_items, and link_response can be at most 64 KB.
Do not send Link access tokens, Shared Payment Tokens, card numbers, or the raw credential object.
A report to Gravity is separate from the Link command link-cli report, which sends data to Stripe.

Responses

Contact

If your Link setup does not fit one of the shapes on this page, write to index@trygravity.ai.