> ## Documentation Index
> Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Klarna

> Manage Klarna BNPL orders: look up order details and capture, refund, or cancel orders

## At a glance

* **Availability**: Experimental ([how to enable](/cloud/integrations)).
* **Auth**: Basic auth.
* **Connection**: HTTP Basic auth with `KLARNA_API_USERNAME` as the username and `KLARNA_API_PASSWORD` as the password.
* **Docs**: [https://docs.klarna.com/api/authentication/](https://docs.klarna.com/api/authentication/)

## Credentials

Set these per environment. See [Connect an integration](/cloud/integrations).

| Variable              | Required | Description                                                                                                                                                                |
| --------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `KLARNA_API_USERNAME` | Yes      | Klarna API username (the UID shown when creating credentials in the Merchant Portal), used as the HTTP Basic username [Docs](https://docs.klarna.com/api/authentication/). |
| `KLARNA_API_PASSWORD` | Yes      | Klarna API password/key associated with the username, used as the HTTP Basic password [Docs](https://docs.klarna.com/api/authentication/).                                 |

## Setup

1. **Get a Klarna merchant account**: Sign up as a Klarna merchant at [https://www.klarna.com/business/](https://www.klarna.com/business/) and log in to the Merchant Portal at [https://portal.klarna.com/](https://portal.klarna.com/). For testing without a live contract, use the Playground environment ([https://portal.playground.klarna.com/](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/](https://docs.klarna.com/api/ordermanagement/)

## Tools

| Tool                            | Access | Description                                                                                                                                                                               |
| ------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Get Order                       | Read   | Retrieve a Klarna order including status, amounts, order lines, captures, and refunds                                                                                                     |
| Capture Order                   | Write  | Capture a full or partial amount of an authorized order (activates the payment after fulfillment)                                                                                         |
| Refund Order                    | Write  | Refund a full or partial captured amount back to the customer                                                                                                                             |
| Cancel Order                    | Write  | Cancel an authorized order that has not been captured, releasing the full authorization                                                                                                   |
| Release Remaining Authorization | Write  | Release 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 Capture                     | Read   | Get 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.
