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
/searchreturns a recommendation with agrclid(Gravity click ID). If the merchant accepts machine payments, the recommendation also has acheckoutpointer that the agent can pay directly.- Your agent pays the merchant with Link, or gives the user
click_url. Keep thegrclidwith the spend request. - When the spend request is complete, your backend sends it to
/purchases/reportwith thegrclidand the buyer’s hashed email.
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.
1. Pay with Link
The Link CLI is a tool that the agent calls. The user signs in one time withlink-cli auth login. Only US and Canadian Link accounts are supported now.
- MCP server
- CLI as a tool
Add the Link MCP server to your MCP client config (Or run
.mcp.json or an equivalent file). Each CLI command becomes a tool.link-cli serve and point your host at http://127.0.0.1:54321/mcp./search result, recommendation.checkout has one of two values:
{protocol: "mpp", endpoint, network_id, attribution}: payendpointdirectly. It already contains?grclid=and the click ID.null: there is no machine checkout. Useclick_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 onspend_request_id for your publisher, so a retry is safe.
Authentication
Send your publisher API key in theX-API-Key header. This endpoint does not accept the key in the body.
Request fields
Onlyspend_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.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.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).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.
string
shared_payment_token, card, or link_pay_token.string
The merchant or Stripe payment ID (
pi_ ID, or an order ID).string
The
ltxn_ ID.string
string
The ISO 8601 time of the charge.
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.
object
Any JSON. Gravity stores it as you send it, with no schema.
object
The spend request object exactly as
link-cli returned it (--format json).422. Put other data in metadata. Each of metadata, line_items, and link_response can be at most 64 KB.
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 toindex@trygravity.ai.