Learn how to refund and manage orders efficiently using the Klarna Order Management API.
Use the Order management API to refund the items on a captured order.
When your customers return the items they bought and you need to refund that order, use this API call to credit the amount back to your customers.
The following diagram depicts how this API call works:
sequenceDiagram
autonumber
participant A as MERCHANT
participant B as KLARNA
A ->> B: POST /ordermanagement/v1/orders/{order_id}/refunds
note over A, B: Provide the refund amount (full or partial)
alt SUCCESSFUL
B -->> A: 201: Created includes refund_id, location
else ERROR
B -->> A: 403: correlation_id, error_code, error_message
end
If you want to learn how to correctly allocate refunds when you deliver in multiple shipments, see the Refund allocation section.
Klarna-Idempotency-Key : This header will guarantee the idempotency of the operation. The key should be unique and is recommended to be a UUID version 4. Retries of requests are safe to be applied in case of errors such as network errors, socket errors and timeouts.
Body
refunded_amount (required): the total order amount to be refunded. It must be less or equal to the captured_amount from the order capture
reference (optional): Internal reference to the refund. This will be included in the settlement files.
description (optional): text to add details of the refunds. Your customers can see this description
order_lines (optional): list of details associated with this refund. We highly recommend you send order lines as they allow us to locate the refund to the right capture (consumer invoice). Order lines are also helpful for your customers to visualize the refunded amount in the Klarna app
JSON
1
2
3
4
5
6
7
8
9
10
{
"refunded_amount": 100000000",
"reference": "9dfcd4b6-9428-4835-ad93-3720ea808608",
"description": "Description of the refund shown to the customer",
"order_lines": [
{
"image_url": "https://yourstore.example/product/headphones.png",
"merchant_data": "Some metadata",
"name": "string",
"product_identifiers": {
To charge return fees, you have to call the same endpoint you use for refunding an order, but with type: return_fee as an additional parameter in order_lines.
Send a POST request to the [{apiUrl}](https://docs.klarna.com/api/ordermanagement/#operation/refundOrder)/ordermanagement/v1/orders/{order_id}/refunds endpoint.
Include the following in your request:
Header
Klarna-Idempotency-Key: This header will guarantee the idempotency of the operation. The key should be unique and is recommended to be a UUID version 4. Retries of requests are safe to be applied in case of errors such as network errors, socket errors and timeouts.
Body
refunded_amount (required): the total order amount to be refunded. It must be less or equal to the captured_amount from the order capture
reference (optional): Internal reference to the refund. This will be included in the settlement files.
description (optional): text to add details of the refunds. Your customers can see this description
order_lines (required): list of details associated with this capture. You have to add an extra order line representing the return fee and set its type to return_fee
JSON
1
2
3
4
5
6
7
8
9
10
{
"refunded_amount": 9500,
"reference": "1786c73b-a2be-4d42-a9f7-ff1c4bca5ccc",
"description": "Description of the refund shown to the customer",
"order_lines": [
{
"name": "T-Shirt",
"type": "physical",
"quantity": 1,
"unit_price": 10000,
Sample request to refund with return fees.
You must add the parameter type: return_fee in the order lines to charge the return fee successfully. Adding this parameter lets your customer visualize the fee in the Klarna app.
You can also remove the charged fees added in the request explained above. For this action, you have to send a new request to refund an order, including the amount previously charged as a return fee.
Use the Order management API to release the authorization of an order.
When you have an order that isn't fully captured and you don't plan to perform more captures on it, you should cancel it by releasing the order's authorization.
With this action, your customers won't be debited for the remaining authorized order amount. If your customers paid by card, we'll refund the remaining amount to their account.
To release the authorization of an order, send a POST request to the [{apiUrl}](https://docs.klarna.com/api/ordermanagement/#operation/releaseRemainingAuthorization)/ordermanagement/v1/orders/{order_id}/release-remaining-authorization endpoint.
Provide the order_id as path parameters. The order_id is the identifier you get in a successful response when [ placing a new order].
You don't need a request body for this POST method.
To get the available options for extending an order's payment due date, send a GET request to the [{apiUrl}](https://docs.klarna.com/api/ordermanagement/#operation/getOptionsForExtendDueDate)/ordermanagement/v1/orders/{order_id}/captures/{capture_id}/extend-due-date-options endpoint.
Provide order_id and capture_id as path parameters. The order_id is the identifier you get in a successful response when placing a new order, and the capture_id is the identifier you get when successfully capturing an order.
You don't need a request body for this POST method.
If your request contains errors, you'll receive an error response. Ensure the order_id and the capture_id values you provided are valid and correctly formatted.
To extend the payment due date for a specific order, send a PATCH request to the [{apiUrl}](https://docs.klarna.com/api/ordermanagement/#operation/extendDueDate)/ordermanagement/v1/orders/{order_id}/captures/{capture_id}/extend-due-date-options endpoint.
JSON
1
2
3
4
{
"number_of_days": 0
}
Sample of a request to extend the payment due date.
Provide one of the extension options you got as number_of_days from Step 1.
If your request contains errors, you'll receive an error response. Ensure the order_id and the capture_id values you provided are valid and correctly formatted.