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

# Authorize Klarna Checkout

> Confirms the Klarna authorization token after customer approval in the Klarna widget

## Overview

After the customer authorizes payment in the Klarna widget (client-side), this endpoint confirms the authorization with Firmly. It stores the `authorization_token` in the session and returns the cart with the confirmed Klarna payment method.

## Authentication

**x-firmly-authorization** `string` *required*

Device authentication token from Browser Session

## Path Parameters

**domain** `string` *required*

The merchant domain (e.g., "merchant.example.com")

## Request Body

**attributes** `object` *required*

Klarna authorization details

**Attributes**

**authorization\_token** `string` *required*

The authorization token received from the Klarna Payments SDK after the customer approves payment. Obtained from the `Klarna.Payments.authorize()` callback.

## Response

Returns the cart with the confirmed Klarna payment method.

**cart\_id** `string`

Unique identifier for the cart

**line\_items** `array`

Array of items in the cart

**payment\_method** `object`

Confirmed Klarna payment method

**Payment Method**

**payment\_type** `string`

Always `"Klarna"` for this gateway

**attributes** `object`

Klarna authorization details

**Attributes**

**session\_id** `string`

Klarna payment session identifier (from start checkout)

**authorization\_token** `string`

The confirmed authorization token

**shipping\_info** `object`

Delivery address details

**total** `object`

Grand total including all costs

**sub\_total** `object`

Subtotal before shipping and tax

**tax** `object`

Tax amount

**fees** `array`

Merchant-imposed fees (e.g. recycle, regulatory), if any

**fee\_total** `object`

Total of all fees

## Code Example

```javascript JavaScript theme={null}
// After Klarna.Payments.authorize() callback returns authorization_token
const response = await fetch(
  'https://api.firmly.work/api/v1/domains/merchant.example.com/express/klarna/authorize',
  {
    method: 'POST',
    headers: {
      'x-firmly-authorization': authToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      attributes: {
        authorization_token: 'klarna_auth_token_from_widget'
      }
    })
  }
);

const cart = await response.json();
// Payment is now authorized, proceed to complete order
```

```python Python theme={null}
import requests

response = requests.post(
    'https://api.firmly.work/api/v1/domains/merchant.example.com/express/klarna/authorize',
    headers={
        'x-firmly-authorization': auth_token,
        'Content-Type': 'application/json'
    },
    json={
        'attributes': {
            'authorization_token': 'klarna_auth_token_from_widget'
        }
    }
)

cart = response.json()
```

```bash cURL theme={null}
curl -X POST https://api.firmly.work/api/v1/domains/merchant.example.com/express/klarna/authorize \
  -H "x-firmly-authorization: YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"attributes": {"authorization_token": "klarna_auth_token_from_widget"}}'
```

## Response Example

```json theme={null}
{
  "cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
  "line_items": [
    {
      "line_item_id": "3e66bef5-43f5-4a80-8957-91c5c8233163",
      "sku": "MT12",
      "quantity": 1,
      "description": "Cassius Sparring Tank",
      "price": {
        "currency": "USD",
        "value": 18,
        "number": 1800,
        "symbol": "$"
      },
      "line_price": {
        "currency": "USD",
        "value": 18,
        "number": 1800,
        "symbol": "$"
      }
    }
  ],
  "payment_method": {
    "payment_type": "Klarna",
    "attributes": {
      "session_id": "kp_abc123def456",
      "authorization_token": "klarna_auth_token_from_widget"
    }
  },
  "shipping_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "phone": "2065551212",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "WA",
    "country": "US",
    "postal_code": "98101"
  },
  "total": {
    "currency": "USD",
    "value": 32,
    "number": 3200,
    "symbol": "$"
  },
  "sub_total": {
    "currency": "USD",
    "value": 18,
    "number": 1800,
    "symbol": "$"
  },
  "tax": {
    "currency": "USD",
    "value": 2,
    "number": 200,
    "symbol": "$"
  },
  "fees": [
    {
      "description": "Recycle fee",
      "currency": "USD",
      "value": 2,
      "number": 200,
      "symbol": "$"
    }
  ],
  "fee_total": {
    "currency": "USD",
    "value": 2,
    "number": 200,
    "symbol": "$"
  }
}
```

## Error Responses

| Code | Description |
| - | - |
| `ErrorCartNotFound` | No active cart for this domain |
| `ErrorBadRequest` | Missing `authorization_token` in request body |
| `ErrorGatewayNotFound` | Klarna is not enabled for this merchant |
| `ErrorPaymentMethodNotAvailable` | Klarna is not available for this cart |
| `ErrorPrecondition` | Precondition failed (e.g., cart state invalid) |
| `ErrorSubmitExpressCheckout` | Authorization failed at the merchant |
| `ErrorRateLimited` | Too many requests |

## Related Endpoints

* [Start Klarna Checkout](https://firmly.mintlify.site/api-reference/payment/express-checkout/start-klarna.md) - Create Klarna session first
* [Complete Klarna Order](https://firmly.mintlify.site/api-reference/payment/express-checkout/complete-order-klarna.md) - Finalize the order


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.