Intents Route
POST
/v0/connect/tokenExchange a Connect code for the store's keys (server to server)
Called by the plugin’s server, never a browser. The code is spent by the first attempt, right or wrong; presenting a spent code again revokes the connection it made. Returns a secret key named for the site and scoped to the merchant, which can create invoices and register webhooks but never change where the merchant is paid. Test-mode keys unless the code was approved for live after go-live.
Authentication
Section titled “Authentication”A secret key (ik_) as a Bearer token. The prefix sets the mode: _test_ or _live_. Publishable keys (pk_) cannot call it.
Body parameters
Section titled “Body parameters”codestringRequiredcode_verifierstringRequiredsite_urlstringRequiredThe same
site_urlthe request named
Responses
Section titled “Responses”- 200Connected
- 400CONNECT_CODE_INVALID: unknown, expired, used, wrong verifier or site
- 403LIVE_MODE_LOCKED or MERCHANT_RESTRICTED
Request
Section titled “Request”curl https://api.intents.fi/v0/connect/token \ -X POST \ -H 'authorization: Bearer $INTENTS_SECRET_KEY' \ -H 'content-type: application/json' \ -d '{ "code": "<the code from return_url>", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "site_url": "https://shop.northwood.example" }'const response = await fetch("https://api.intents.fi/v0/connect/token", { method: "POST", headers: { authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`, "content-type": "application/json", }, body: JSON.stringify({ "code": "<the code from return_url>", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "site_url": "https://shop.northwood.example" }),});
if (!response.ok) { const { error } = await response.json(); throw new Error(`${error.code}: ${error.message}`);}const data = await response.json();import osimport httpx
response = httpx.post( "https://api.intents.fi/v0/connect/token", headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"}, json={ "code": "<the code from return_url>", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "site_url": "https://shop.northwood.example" },)response.raise_for_status()data = response.json()Errors
Section titled “Errors”{ "error": { "code": "INVOICE_EXPIRED", "message": "This invoice has expired" } }Switch on code, not on the message: every code has a page under Error codes. Base URL https://api.intents.fi; the whole reference is on one page.