What you need
- An Anchor API key, in
ANCHORBROWSER_API_KEY. - An Agentcard
client_idandclient_secret, from the Agentcard dashboard. - A user who has stored a card in the Agentcard Vault, and the
user_idyou received when they stored it. See Adding a card.
Install
@agent-cards/sdk 0.20.0 or later. Earlier versions, published under the older name @agent-cards/checkout, refuse a page that has Anchor’s extensions on it.
Attach Agentcard to a session
Create a session, then attach Agentcard to its page before your agent reaches the payment form.syncRegistry() loads the list of payment processors the SDK can hold. Call it once per client.
onApprovalUrl receives a link to the user’s approval screen. Send it from your own app, and keep it out of your logs: only the user should open it.
With Anchor’s agent
Pass the samesessionId to agentTask, so the agent shops in the session Agentcard is attached to. A task created without sessionId runs in a new browser where the SDK is not attached, the store receives the placeholder card, and the purchase fails.

