Skip to main content

At a glance

Credentials

Set these per environment. See Connect an integration.
VariableRequiredDescription
KLARNA_API_USERNAMEYesKlarna API username (the UID shown when creating credentials in the Merchant Portal), used as the HTTP Basic username Docs.
KLARNA_API_PASSWORDYesKlarna API password/key associated with the username, used as the HTTP Basic password Docs.

Setup

  1. 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/).
  2. 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.
  3. 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.
  4. 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.
Provider API reference: https://docs.klarna.com/api/ordermanagement/

Tools

ToolAccessDescription
Get OrderReadRetrieve a Klarna order including status, amounts, order lines, captures, and refunds
Capture OrderWriteCapture a full or partial amount of an authorized order (activates the payment after fulfillment)
Refund OrderWriteRefund a full or partial captured amount back to the customer
Cancel OrderWriteCancel an authorized order that has not been captured, releasing the full authorization
Release Remaining AuthorizationWriteRelease the remaining (uncaptured) authorized amount of an order after the final partial capture - the standard end-of-fulfillment step that frees the customer’s remaining authorization
Get CaptureReadGet a single capture of an order with its status and amounts

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.