How it works
/searchreturns a recommendation with agrclid, and when the merchant accepts machine payments acheckoutpointer the agent can pay directly.- Your agent pays the merchant with Link (or hands the user
click_url), keeping thegrclidwith the spend request. - When the spend request completes, your backend POSTs it to
/purchases/report, with thegrclidand the buyer’s hashed email.
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.
1. Pay with Link
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.
- MCP server
- CLI as a tool
Add to your MCP client config (Or run
.mcp.json or equivalent). Every CLI command becomes a tool.link-cli serve and point your host at http://127.0.0.1:54321/mcp./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 onspend_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.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.string
As returned on the spend request.
string
acme.comstring
Product or checkout URL.
string
Stripe account or merchant id if you have it.
string
Merchant
profile_… from the spend request (MPP only).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.
string
shared_payment_token, card, or link_pay_token.string
Merchant or Stripe payment id (
pi_…, order id).string
ltxn_…string
string
ISO 8601 timestamp of the charge.
string
What the user asked for that led to this purchase.
string
Which of your agents bought it.
string
Your conversation / session id.
object
Any JSON. Stored as sent, no schema.
object
The spend request object exactly as
link-cli returned it (--format json).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.
