At a glance
- Availability: Experimental (how to enable).
- Auth: Basic auth.
- Connection: HTTP Basic auth with
KLARNA_API_USERNAMEas the username andKLARNA_API_PASSWORDas the password. - Docs: https://docs.klarna.com/api/authentication/
Credentials
Set these per environment. See Connect an integration.Setup
- Get a Klarna merchant account: Sign up as a Klarna merchant at https://www.klarna.com/business/ and log in to the Merchant Portal at https://portal.klarna.com/. For testing without a live contract, use the Playground environment (https://portal.playground.klarna.com/).
- Create API credentials: In the Merchant Portal, go to Settings > API credentials and generate a new credential. You get a username (a UID linked to your merchant ID) and a password/API key - the password is shown only once, so store it immediately.
- Set environment variables: Add KLARNA_API_USERNAME (the UID) and KLARNA_API_PASSWORD (the API key/password) to your .env. Requests authenticate with HTTP Basic auth using these two values.
- Pick your regional host and verify: All tools take an apiHost parameter (default api.klarna.com for Europe). Use api-na.klarna.com for North America or api-oc.klarna.com for Oceania. Run Get Order with a known order ID to verify access.
- Playground (test) credentials only work against the playground hosts (api.playground.klarna.com, api-na.playground.klarna.com, api-oc.playground.klarna.com) and production credentials only against production hosts - pass the matching apiHost.
- All amounts are in minor units of the order currency (e.g. 1050 = 10.50 EUR).
- Refunds require a prior capture; cancel only works on orders that have not been captured.
Tools
Example prompts
- Look up a Klarna order I specify and summarize its status, authorized, captured, and refunded amounts.
- Capture the full remaining amount of a Klarna order I specify, with the shipment reference as the capture reference.
- Issue a partial refund on a Klarna order I specify and confirm the new refunded total.