How it works
- At the payment step, once the final total is known, the agent’s code calls
conto.checkout.getLinkCard(). - Conto checks the purchase against the agent’s rules and holds the amount against its limits. When a rule requires it, the owner approves in Conto first.
- After Conto approves, Stripe’s Link CLI on your machine asks Stripe Link for a card for that amount at that store. The person completes any approval Link requires through the supported Link flow.
- Your code gets the card and fills in the store’s card form. Keep the card out of any model prompt, tool result, or log.
- Right before paying, the agent calls
confirm(). After paying, it reports the outcome.
Set up
Install Stripe’s Link CLI on the machine where your agent runs, and log in with the Link account that pays:link-cli logged out could release the hold while the Link
request was still open.
Complete any approval your Link flow requires, in the Link app or on the web. See Link’s own authorization. Nobody connects Link to Conto, and there is no Link setup in the Conto dashboard.
You also need an agent and its standard SDK key, as for checkout checkpoints. Organization policies, per-agent limits, and approval workflows apply as described in managing several agents. A shared budget that covers the agent counts the purchase. If it refuses, getLinkCard() and replaceLinkCard() fail with status 409 and a reasonCode before Stripe Link is asked for a card.
Get a card with the SDK
getLinkCard() takes the same purchase details as checkout.begin(), plus the wallet. The
checkout method is always LINK. It waits for the owner when a rule requires approval, then for
the person in Link. Two optional settings limit each wait, and both default to 10 minutes:
ownerApprovalTimeoutMs and linkApprovalTimeoutMs. Pass signal to stop early.
While Conto’s approval is open and no confirm() has started, retrying getLinkCard() with the
same input resumes the same checkpoint and the same Link request, so the person is not asked twice.
Once a confirm() has started, a retry returns no card and leaves Link alone. Do not retry
getLinkCard() while another flow may confirm the same checkpoint. If the retry fails, it closes the Link
request, which can leave the other flow paying with a closed card.
Approve on the web
The person does not need the Link app. Each Stripe Link request has an approval page on link.com, and the person can approve there while signed in to Link. PassonLinkApproval to get that page
and show it to them:
checkpoint, linkRequestId, approvalUrl, and
approvalExpiresAt, the time Link stops accepting approval. approvalUrl is always an HTTPS
link.com address. It is missing when Link does not provide one, and the person can still approve
in the Link app. The page works only for the Link account that is signed in.
The SDK does not wait for onLinkApproval, and an error in it does not stop the purchase. A retry
that resumes the same Link request calls it again with the same page. replaceLinkCard() takes
it too.
A LinkCardError also has approvalUrl when the SDK stopped while the request was waiting for the
person. With code LINK_CARD_NOT_CANCELLED the request is still open, so the person can approve
there and a retry with the same input resumes it. After a LinkCardTimeoutError, Conto has already
cancelled the request.
The card
The card stays in your agent’s process. Printing or serializing the result shows only the last
four digits, the brand, and the expiry. Use the card only in the store’s card form for this
purchase.
linkCliWallet() runs Link CLI without a shell and reads the card from a private temporary file
that it deletes before the call returns. Its options are binary (defaults to link-cli on PATH),
test, paymentMethodId (defaults to the person’s default payment method), timeoutSeconds, and
env.
When the total changes
Read the final items and charges in your trusted checkout code and pass them aslineItems and totals to confirm(). confirm() checks the items and the final total even when the total is unchanged. Tax and shipping rows may differ from the ones passed to begin().
If an item changed at the same price, cancel the Link request with wallet.cancel(result.linkRequestId), cancel the checkpoint with conto.checkout.cancel(result.checkpoint.id), and call getLinkCard() again with the new items and a new idempotency key. replaceLinkCard() handles a changed total only.
A repeated confirm() can return its earlier confirmation, so it is not permission to pay twice. Your executor must claim dispatch once per purchase.
Call getLinkCard() at the payment step, when the total includes shipping and tax. The card
covers the amount Conto approved, so confirm() refuses a different total for it with
LINK_CARD_TOTAL_CHANGED. From SDK 0.8.1, confirm() reads the checkpoint from Conto when your copy
has no Link request, so a saved copy is safe to pass. From SDK 0.14.2, it also refuses when the
checkpoint reads linkRequestStarted: true with no Link request ID, and the spend stays held,
because Link may still have a card for it.
If the total changes anyway, get a new card for the final total:
replaceLinkCard() cancels the old Link request and checkpoint, checks the final total against
the agent’s rules, and gets a new card. Confirm replacement.checkpoint with the final total.
From SDK 0.8.1, replaceLinkCard() reads the checkpoint before it touches the card. If the checkpoint
was already confirmed, is still being checked, or has a different Link request on record, it throws
LINK_CARD_NOT_REPLACED and changes nothing, at the same total too. If the old card closes but Conto
does not release the spend, it throws CHECKPOINT_NOT_CANCELLED, and trying again is safe.
If the total changes again, pass the latest result to replaceLinkCard(). Do not run it while another
flow may confirm the same checkpoint, because Conto cannot refuse that confirm and close the card in
one step.
These reads need the transactions:read scope, which standard agent keys have.
When something goes wrong
If any call throws, do not pay.
A
ContoError from confirm() means something else, even with the same code. Link already has a
request, and the spend may still be held. The error has no checkpoint, so read it with
conto.checkout.get(result.checkpoint.id). Act on the stage in the table under
When LINK_CARD_NOT_CANCELLED is thrown, and use
result.linkRequestId as the request ID. For LINK_CARD_TOTAL_CHANGED, follow error.retryGuidance
instead.
The four Link errors extend LinkCardError, which also covers other Link failures. Each has
holdReleased, which is true when the checkpoint no longer holds the spend. It says nothing about
the card, so follow error.retryGuidance whatever its value. Error messages never contain card data.
From SDK 0.8.1, these codes mean:
When LINK_CARD_NOT_CANCELLED is thrown
Link could still issue the card, or a card may already be out. Before you cancel anything, read the
checkpoint with conto.checkout.get(error.checkpoint.id), because another attempt may have confirmed
it. Then act on the stage:
A few more things to check:
- A second request.
error.linkRequestIdholds one ID, the request on record when there is one. If the error names a second Link request, cancel that one too before you callconto.checkout.cancel(). - No record. If
error.checkpoint.paymentReferenceis missing, Conto has no ID for the request. From SDK 0.12.0, the SDK marks the checkpoint before it asks Link, so the checkpoint readslinkRequestStarted: trueand the spend stays held when the approval lapses. Find the request in Link and cancel it before you cancel the checkpoint. With SDK 0.11.0 and earlier, the spend can be released when the approval lapses while the card may still work, so retry or cancel before then. With nolinkRequestIdat all, the wallet failed while asking Link for the card, so Conto cannot tell whether Link created the request. Retry with the same input to resume it. - Logged out. With Link CLI logged out, the retry and
wallet.cancel()both fail, so runlink-cli auth loginfirst. Do not callconto.checkout.cancel()before the request is closed, because Conto cannot see the card and would release the spend while it still works. - A request with no checkpoint. If
error.retryGuidancenames a Link request with no checkpoint on it, a retry cannot resume until that request closes. Do not cancel that request yourself, because it may be the person’s own purchase. Follow that guidance. - An action in Link. A request in
requires_actionthat Link will not resume cannot be retried or cancelled, but Link closes it on its own.wallet.waitForApproval(error.linkRequestId, { timeoutSeconds: 0 })returns itsactionUrl, where the person can fix the problem. To buy this, begin a new purchase with a new idempotency key once they have. Do not callconto.checkout.cancel()yet. The hold stays until Link closes the request, and then a retry releases it.
linkCliWallet().cancel() also succeeds when Link already closed the request, for
example when it expired. If it throws, the card may still work or may have been used, so do not call
conto.checkout.cancel(). Fix what stopped it and try again. If it keeps failing, stop. If
error.checkpoint.paymentReference is set, or from SDK 0.12.0 linkRequestStarted is, the owner gets
a review alert after the approval lapses and records what happened on the checkout page. If neither is
set, or the checkpoint has closed, no alert comes, and the card may still work with nothing held
behind it, so tell the owner.
From SDK 0.13.0, pass the checkpoint you last read: conto.checkout.cancel(checkpoint.id, { lastRead: checkpoint }).
Conto then cancels only while the checkpoint’s Link request is still the one in that read. If another
Link request reached Conto since then, the cancel throws a ContoError with code
CHECKPOINT_LINK_REQUEST_CHANGED, nothing is released, and the spend stays held. Read the checkpoint
again, cancel its Link request, then cancel again. The cancels that getLinkCard(), confirm() and
replaceLinkCard() make do this for you.
Stage CONFIRMING
CONFIRMING means a confirm() started and has not finished. Conto has not cleared the payment, so do
not pay. Do not cancel the Link request either, because the check can still end in CONFIRMED. This
normally lasts seconds. Wait, read the checkpoint with conto.checkout.get(), and act on the new
stage. If you have no checkpoint ID, call conto.checkout.begin() with the same input and
checkoutMethod: 'LINK' to get it.
If Conto stopped during the check, confirm(), conto.checkout.cancel(), and reportOutcome() return
409 and the spend stays held, so stop trying after a few minutes. About 5 to 10 minutes after
expiresAt, the stage changes on its own. If Conto has the Link request on record, or the checkpoint
reads linkRequestStarted: true, it becomes OUTCOME_UNKNOWN with linkRequestOpen: true, so follow
the steps for that field. If not, it becomes
EXPIRED and Conto releases the spend, so cancel any Link request you hold and do not pay. A Link
request you name after expiresAt and before the stage changes is recorded even though the call
returns 409, which keeps the spend held. Read the checkpoint’s paymentReference to check. The owner
can also record what happened on the checkout page at any time before then.
When Conto’s approval ends
SDK 0.8.0 and later tell Conto the Link request ID as soon as Link creates it. SDK 0.12.0 and later also tell Conto right before they ask Link for a card, so the spend stays held even when the request ID never reaches Conto, for example after a crash between Link’s answer and the SDK’s record. If Conto cannot be told first, Link is not asked, and the SDK throwsLINK_CARD_NOT_STARTED with the spend still held. If the checkpoint then lapses or a rule stops it before confirm(), Conto keeps the spend held, because the card may still work. A confirm() refused for either reason moves the checkpoint to stage OUTCOME_UNKNOWN at once. A lapse with no confirm() moves it about 5 to 10 minutes later. Until then the stage still reads APPROVED, and retrying getLinkCard() with the same input can return the card, but confirm() refuses it. During that time the checkpoint reads approvalLapsed: true, which Conto sets by its own clock. Once the stage is OUTCOME_UNKNOWN, that retry throws a LinkCardError with code CHECKOUT_CHECKPOINT_NOT_APPROVED and the linkRequestId.
The checkpoint then has linkRequestOpen: true, which a confirmed checkpoint with no outcome never has. Act on it as the OUTCOME_UNKNOWN row in the table above says. If you do nothing, the owner gets a review alert and records what happened. After a cancel or a not paid decision, a retry throws CheckoutCheckpointClosedError.
A not paid decision does not close the card, which can work for up to 48 hours. After CheckoutCheckpointClosedError, if error.checkpoint.paymentReference is set, cancel the request with wallet.cancel(error.checkpoint.paymentReference.id) before you start a new purchase. If that call throws, the card may have been used, so do not begin a new purchase.
If Conto cannot record the request, the SDK reads the checkpoint, cancels the request in Link, then cancels the checkpoint, and throws LINK_CARD_NOT_RECORDED. holdReleased is false if the checkpoint could not be cancelled. If the read fails, a confirm has started, or Link cannot cancel a request that is still open, the SDK throws LINK_CARD_NOT_CANCELLED instead. From SDK 0.12.0 the hold stays, because the SDK marked the checkpoint first. With earlier versions, Conto may have no record of that request, so the hold can end when the approval lapses while the card may still work.
A closed checkpoint can read holdReleasePending: true for a few minutes if releasing its spend failed. The spend stays held until Conto’s retry lands, so you do not need to release it. The field says nothing about the card, so still cancel an open Link request. SDK 0.11.0 and later keep holdReleased false until the release lands. Earlier versions read only the stage, so holdReleased can be true during that time.
Test mode
linkCliWallet({ test: true }) creates test-mode Link requests. Link returns test card data and
charges nothing. Complete any Link approval required by the test flow. Conto checks and records
test purchases like any other purchase.
MCP
The Conto MCP server does not issue Link cards. A tool result goes into the model’s context and often into the MCP host’s logs, so a card number and CVC must never be in one. Get the card withconto.checkout.getLinkCard() in code the model does not see, and pass the model only the
checkpoint ID, the linkRequestId, and the card’s last four digits.
The MCP checkpoint tools still take a linkRequestId. checkout_checkpoint_confirm and
checkout_checkpoint_report_outcome send it to Conto as the payment reference. With
CONTO_LINK_WALLET set to link-cli, checkout_checkpoint_cancel also cancels the request Conto has
on record, or the linkRequestId you pass, and keeps the spend held until Link cancels it or reports it
closed. Pass the ID if your SDK is older than 0.8.0, because Conto then has no record of the request.
These rules need MCP server 0.7.2 or later. See MCP tools.
If the agent creates the Link request itself, it calls checkout_checkpoint_link_request right
before and right after, so Conto keeps the spend held if the approval lapses before the confirm. This
needs MCP server 0.9.0 or later. See
checkout_checkpoint_link_request.
From MCP server 0.10.0, checkout_checkpoint_cancel tells Conto which Link request it read. If
another one reaches Conto during the cancel, the spend stays held and the tool says to call it again.
That call closes the request first, or asks for its linkRequestId when Conto knows only that one was
started. The tools also read Conto’s approvalLapsed instead of comparing
expiresAt with the host’s clock.
What this protects
This integration makes Conto’s approval part of how the agent pays, as long as Conto is the agent’s only way to get a Link card. It stops:- An agent going off script. Link is asked for a card only for a purchase Conto approved.
- Overspending. The card is limited to the approved amount, and the amount counts toward the agent’s limits.
- The wrong store. Conto checks the store’s domain against the owner’s rules before any card exists, and the person sees the store in Link.
- Too many purchases. Count and velocity rules apply to each card request.
conto.checkout.getLinkCard() in trusted code the model cannot see or change. Do not give the model Link CLI, a shell, or your Link credentials. Conto’s MCP checkpoint tools are safe to give it, since they never return card data.