fill api then puts the approved credential into the attached browser without passing it through your application’s code or model context. see how KERNEL pays for details.
link is the wallet provider, not the merchant’s payment processor. for the overall offering, see payments on KERNEL.
Before you start
link currently supports only users with US phone numbers.
kernel and vault variables.
Choose an oauth client
use KERNEL’s oauth client by default. if you bring your own client, complete the setup below before following the shared payment lifecycle.bring your own link oauth client
register a provider configuration once for your organization. configurations are shared across projects, so authenticate this step with an organization-scoped api key. project-scoped credentials can reference an existing configuration when creating a wallet, but can’t create, update, or delete configurations. keep the client credentials outside the agent’s accessible files. the SDK examples read them from backend environment variables. for the CLI, create a protected file readable only by its owner (for example, mode0600):
link-client.json
kernel client and vault from
Before you start. supply the access and refresh tokens from
the same grant, with a currently valid access token. CLI users should restore
their project-scoped KERNEL_API_KEY before running the wallet command and put
the grant in this protected file:
link-grant.json
connected wallet without a link_oauth action.
KERNEL takes over refresh-token rotation, so your backend must stop refreshing
that grant. continue with Select a payment method.
Lifecycle
- connect a wallet: use KERNEL’s client and present the returned
link_oauthaction, or complete oauth in your backend and import the grant with your provider configuration. - require the wallet to be
connected. - request the advertised
payment_methodsexpansion and let the user choose an eligible method. - create a browser with the vault attached, navigate it to the final checkout page, and verify the purchase.
- create a
carditem with that browser’s session id, the checkout’s exactpage_url, and the purchase details. creation starts link’s spend request and returns aspend_approvalorpush_approvalaction. - present the action to the user and wait for
state.statusto becomeready. - invoke the advertised
filloperation with the inputs its description names, inspect the outcome, then have the agent click the checkout’s pay button once.
Connect a wallet
this section shows the KERNEL-managed oauth path. if you imported a connected wallet with your own client above, continue with Select a payment method. before showing a link connection option, list the vault’s items. if a link wallet already exists in any state, reuse it and do not let the user add another. show its existing action or status instead. the api makes item keys unique but does not currently enforce one wallet per provider, so the ui must enforce a maximum of one link wallet per vault. the examples usepresentProviderAction, an application-owned function that
publishes the action to an authenticated session for the end user who owns the
vault. bind the action to that user, vault, and item; apply a short application
ttl capped by wallet.expires_at when present; and stop serving it when the
action changes or disappears. derive authenticatedUser from the server-side
session, not a request field. do not log the url or put it in model context.
Select a payment method
requestpayment_methods only when available_expansions advertises it. the expansion comes from link at request time and is not persisted in the vault item.
LINK_PAYMENT_METHOD_ID. missing capability metadata means eligibility is unknown. only eligible: false is an explicit negative result.
Open the checkout
create the card item only after the agent reaches the final checkout page, the page where the next step is paying. KERNEL inspects that page when you create the card, so the browser session must be running, have the vault attached, and have the checkout open at that url.checkoutURL / checkout_url is the browser’s exact current top-level https url, including path, query, and fragment, obtained through your browser-control method. verify the merchant, amount, currency, and items in your controller before creating the card. see verify and confirm the purchase.
Create a card item at checkout
creating the card item starts link’s spend request and the user’s approval. use the session id from the browser above, not a browser name.state.status: pending_authorization and an action. spend_approval includes a url the user opens to approve the purchase in link; push_approval means the user approves in their link app. after approval, the card becomes ready and advertises fill. one bounded wait can finish before approval does; retrieve the item again rather than creating another card.
amount uses minor currency units, so 2306 means 23.06 usd. context must contain at least 100 characters. card creation is live-only, and spec.test is not supported.
How KERNEL pays
when you create the card, KERNEL inspects the checkout page through WebMCP and chooses how link pays. you never choose or see the mode; read the card’s advertisedfill operation instead.
the virtual-card path doesn’t require a native processor adapter or a stripe merchant, but it needs uniquely selectable card inputs on the checkout page. don’t call the page’s WebMCP tools yourself or pass a merchant account id. if the checkout doesn’t support link pay tokens and
amount exceeds 50000, creation returns 400.
Change or retry a request
card items are immutable. repeating the sameupsert with an identical spec returns the existing item without inspecting the checkout again or repeating approval. a different spec at the same key returns 409; PATCH isn’t supported for cards.
to change the purchase, browser, or checkout page, create a new card item under a new key. delete the old item when you no longer need it; deletion can be blocked while a provider outcome is unresolved. never create a replacement card to retry a payment whose outcome is uncertain.
Handle creation errors
checkout inspection runs before KERNEL creates the item or contacts link. these errors mean no card was created and no approval started, so you can correct the cause and create the card again:Fill the checkout
after the user completes approval, retrieve the card withwait: 60. continue only when it’s ready and advertises fill. read that operation’s description: it names the inputs this card needs. the examples below show the fill request; for the full controller and agent handoff, follow the browser agent payments guide.
browser_id and page_url must exactly match the card’s spec.browser_id and spec.page_url, and that page must still be open. any other browser or page returns 403 destination_denied. the card must remain ready, unexpired, and undeleted, with an existing parent wallet. timeout_ms is optional.
fill never submits payment or clicks buttons. after a completed fill, the agent clicks the checkout’s pay button once.
Fill a link pay token checkout
when the advertisedfill description says to omit fields, send only browser_id and page_url. KERNEL supplies the approved link pay token to the checkout through its verified WebMCP tool, and the result’s fields array is empty.
Map card fields to inputs
when the advertisedfill description asks for field/selector bindings, KERNEL writes the one-time virtual card into the page’s card inputs. the examples below continue with a ready notebook-order card, the same project-scoped kernel client with retries disabled, and the browser and checkoutURL / checkout_url the card is bound to. verify the purchase and destination before calling fill; neither a model-proposed url nor a selector authorizes disclosure.
format is forbidden for every field except a card’s combined expiration. request only needed billing fields. an absent or empty requested billing value returns 400 field_unavailable before any browser writes; it doesn’t make other card fields unavailable. don’t invent missing billing data.
these selectors illustrate a checkout you control with separate number, combined expiry, and cvc inputs. replace them with selectors verified on your page, including within payment frames. supply 1–32 ordered bindings, never raw values or frame ids.
Handle the outcome
the cli exits nonzero forfailed or unknown, but retains the value-free result on stdout with -o json. preserve that output and its per-field statuses; don’t discard it or retry just because the exit code is nonzero. a transport error can leave the outcome uncertain even without a result body.
see the shared fill outcome contract for per-field statuses and reconciliation.
fill returns a value-free outcome. completed means KERNEL supplied the payment credential to the page, not that payment succeeded. a failed result can leave earlier writes in place; unknown or a lost response requires reconciliation. don’t automatically retry fill or fall back to aliases. decide whether to submit separately, and never retry checkout automatically.
validation errors before any write return 400, 403, 404, or 409 with an error code such as destination_denied, target_changed, ambiguous_page, browser_unavailable, field_unavailable, timeout, or execution_failed. inspect and correct the cause before deciding on a new fill.
one-time describes the provider-issued credential, not item consumption. fill doesn’t consume the item or clear its encrypted material on the first write. expiry, deletion, and item lifecycle restrictions still apply; a ready item isn’t evidence that a purchase can safely be repeated.
don’t create a replacement item to retry an unknown purchase. inspect outcomes, item events, and the merchant’s order state first.
Item reference
wallet and card items accept thesespec fields. fields not listed here are rejected. a card’s spec.wallet must reference a link wallet in the same vault.
wallet items also return a read-only
description with server-generated guidance for agents.
the default link client is {type: 'kernel_managed'}. for your own client, set
authorization.client to {type: 'customer_managed', provider_config: {name: 'checkout-link'}}
and supply authorization.tokens with access_token and refresh_token.
browser_id is a running browser session id with the vault attached, not a reusable browser name. page_url is the exact final checkout url and must use https without embedded credentials. amount uses minor currency units: 1–500000 when the checkout supports link pay tokens and 1–50000 otherwise. link requires a three-letter currency, limits merchant_name to 255 characters, and requires at least 100 characters in context. its optional expires_at is a unix timestamp in seconds.
link line_items support name, quantity, unit_amount, description, sku, url, image_url, product_url, and totals. each totals entry supports type, display_text, and amount. link metadata accepts string values.
card items are immutable. create a new item to change any spec field.
Item states
- wallet:
pending_authorization,connected,declined,reconnect_required,degraded - card:
requested,pending_authorization,ready,consumed,expired,declined,recovery_required
masks.brand and masks.last4. retrieve the card’s advertised operations before using it. for an unresolved provider outcome, follow payment recovery; a ready item alone isn’t evidence that a purchase can safely be repeated.
deleting a card clears its stored provider value. deleting a wallet also invalidates its dependent cards.