Enhance API security by enabling IP address restrictions in Klarna, allowing only approved IPs to access the integration. Start with reporting mode and move to full enforcement to block unauthorized traffic.
To enhance the security of API integrations, Klarna supports IP address restriction, allowing partners to define an allow-list of IP addresses from which requests are permitted. All requests originating from outside the defined list will be blocked.
Partners can specify up to 100 CIDR-blocks, each possibly covering multiple IPs, including both IPv4 and IPv6 formats, as part of this restriction policy. When enabled, Klarna validates every incoming API request against the configured IP list.
Enhance API security by restricting access to the Klarna API integration to approved source IP ranges. Start in reporting mode to validate the configuration, then enable enforcement to block traffic from IPs that are not on the allowlist.
This article is intended for Partners integrating with Klarna using Klarna API integration.
After enabling reporting mode, the responses to the subsequent requests include the Klarna-Ip-Validation-Status header with DENIED status because the IP allowlist is empty.
Partners might need to add a new IP to the already configured allow list. This can be done using the POST endpoint for /v2/account/integration/inbound-restrictions/ip/allowlist.
The request body is a list of IPs to append to the existing IP list. The response contains the complete list of configured IP allowlist.
Note: This endpoint can be used in either of the modes, ENFORCED or REPORTING.
The IP endpoint manages the enforcement state of the IP allowlist restrictions through a state machine with three modes: NOT_ENABLED, REPORTING, and ENFORCED. This endpoint allows transitioning between these states with fine-grained control over when enforcement takes effect.
NOT_ENABLED: IP allowlist validation is completely disabled. No restrictions are applied, and requests from any IP address are accepted. No status header is returned.
REPORTING: IP allowlist validation is enabled but not enforced. Requests are validated against the allowlist, but violations are only logged. Requests are still accepted. This mode is ideal for testing the allowlist configuration before enforcement.
ENFORCED: IP allowlist validation is fully enforced. Only requests originating from IP addresses in the allowlist are accepted. Requests from unlisted IP addresses are rejected.
Critical Concept: the enforcement_mode in the request body represents the intention, the enforcement state the Partner wants to achieve. However, the actual enforcement state in the response depends on the current status (which is set by enforcement_type in the request):
enforcement_type: NOW: transitions immediately. The response enforcement_mode matches the requested mode.
enforcement_type: SCHEDULED: transitions at the specified future time. The response enforcement_mode is REPORTING (transition pending) until the enforced_from timestamp is reached, at which point it becomes ENFORCED.
Example
JAVA
1
2
3
4
5
6
7
8
9
10
// Request: Client intends to enforce IP restrictions
{
"enforcement_mode": "ENFORCED",
"enforcement_type": "SCHEDULED",
"enforced_from": "2099-01-01T00:00:00Z"
}
// Response: Server acknowledges intention but keeps REPORTING until scheduled time
{
"enforcement_mode": "REPORTING",
This design provides a grace period during which the response status header Klarna-Ip-Validation-Status can be monitored before enforcement activates, ensuring the allowlist is configured correctly.
Behavior: Enables IP validation in monitoring mode. All requests are processed normally, but response headers indicate whether the source IP falls within the configured CIDR block/s.
Use Case: First step in enabling IP restrictions. Monitor response headers to verify the status to be ALLOWED.
Behavior: Stops blocking the requests but continues indicating validation status in response headers. This transition removes any configured enforcement timestamp.
Behavior: Disable IP restriction feature. Stops blocking the requests and the status header is not included in the response. This transition removes any configured enforcement timestamp.
Behavior: Disables IP restriction feature. Response headers no longer indicate IP validation status. This transition removes any configured enforcement timestamp.
Use Case: Rollback or permanently disable IP restriction feature.
Behavior: This transition is blocked. It is not possible to directly go from NOT_ENABLED to ENFORCED.
Motivation: This action is not allowed in order to make sure that the transition is done safely through the verification of the status headers returned during the reporting mode.
Behavior: Maintains current monitoring mode. No functional change.
Use Case: Idempotent operations or confirming current state.
Important Limitation: future enforcement cannot be scheduled while staying in REPORTING mode. To schedule enforcement, transition to ENFORCED mode (see transition #6).
// ❌ This will return 400 error
{
"enforcement_mode": "REPORTING",
"enforcement_type": "SCHEDULED",
"enforced_from": "2026-02-01T00:00:00Z"
}
Why This Fails: REPORTING mode means "monitor only, do not block." Scheduling is about when to start blocking, so it requires enforcement_mode: "ENFORCED" to express that intention.
This feature is backend-only. Configure and operate IP address restrictions in the backend deployment and network egress layer. No frontend changes are required.