Error handling: HTTP codes, retries and robust integration

HTTP status codes, error responses and retry logic of the PSB API: how to build a robust integration.

Every API integration will encounter errors sooner or later. A network outage, an unreachable server, an incorrectly formatted document: it comes with the territory. The PSB API communicates errors through standard HTTP status codes and structured JSON responses. In addition, the PSB has a built-in retry mechanism that automatically handles temporary errors during document delivery.

In this article you will learn which status codes the PSB returns, how to interpret error responses, when you can safely retry and how the PSB's automatic retry mechanism works.

HTTP status codes

The PSB API uses standard HTTP status codes to indicate the result of a request. The status codes fall into two categories: client errors (4xx) that you need to fix yourself, and server errors (5xx) that you can retry.

Success response
CodeMeaningExplanation200OKThe request was processed successfully
Client errors (4xx): do not retry

With a 4xx error the problem is in the request itself. Resending with the same data will produce the same result. Fix the cause before trying again.

CodeMeaningWhenAction400Bad RequestValidation error or syntax error in the documentCheck the request body. The JSON response contains details about what went wrong401UnauthorizedNo token sent, or the token has expired or is invalidRequest a new Bearer token from the Identity Server403ForbiddenThe token is valid, but the action is not allowed. Most common: you are using a partyId that your account does not have access to. Other causes: expired bearer token, invalid subscription key, or an endpoint that is not available for your authorisation levelCheck that you are using the correct partyId and that the user who obtained the bearer token has access to that partyId. If in doubt: obtain a new token via the Identity Server404Not FoundThe requested endpoint or resource does not existCheck the URL and the partyId409ConflictThe document has already been processed (idempotency)No action needed: the document was received successfully earlier. See idempotency413Content Too LargeThe file exceeds the maximum sizeReduce the document or attachments. IDR limit: 15 MB

SBDH envelope validation (API400.USRMS1 / API400.USRMS2): these error codes indicate a mismatch between the Peppol envelope (SBDH) and the e-invoice document itself. With USRMS1 the sender or recipient in the envelope does not match the identifiers in the invoice XML. With USRMS2 the PSB cannot find a recognisable sender in the document. Check that the EndpointID and PartyIdentification in your UBL match the values provided when sending. The PSB rejects the document at the AS4 level and returns the error to the sending Access Point.

Server errors (5xx): retry

A 5xx error indicates a temporary problem on the server side. The request itself may be correct. These are the only status codes where retrying makes sense.

CodeMeaningWhenAction500Internal Server ErrorUnexpected server errorRetry with exponential backoff503Service UnavailableThe PSB is temporarily unavailable (maintenance, overload)Retry with exponential backoff

Note: the send endpoint accepts a maximum of 24 MB per request, including HTTP overhead. Payloads exceeding this limit are rejected by the web server with an HTTP 500 instead of a 413, because the rejection occurs before the application layer performs its validation. Keep this in mind with base64-encoded attachments: they add approximately 33% to the file size.

API500UH during deployments: the error code API500UH (Unhandled error) can occur when the PSB performs an internal service update (Service Fabric deployment). In many cases the document has already been delivered successfully to the recipient, but the confirmation step fails due to the migration. The PSB's retry mechanism automatically attempts to complete the remaining steps. If you receive an API500UH, check via the status events whether the document was delivered before resending it.

Reading error responses

With a 4xx error the response contains a JSON body describing the problem. This information helps you identify the cause quickly.

{
  "error": "Validation failed",
  "message": "The supplied document is not valid UBL 2.1",
  "details": [
    "cbc:InvoiceTypeCode is missing"
  ]
}

With a 5xx error the response is not always structured. Base your retry logic on the HTTP status code, not on the content of the body.

Retry strategy for your integration

Not every error deserves a retry. The rule of thumb is simple: only 5xx status codes and network timeouts are worth retrying. With 4xx errors you need to modify the request before sending it again.

Exponential backoff

The recommended retry strategy is exponential backoff: start with a short wait time and double it with each subsequent attempt.

AttemptWait time11 second22 seconds34 seconds48 seconds516 seconds632 seconds7+60 seconds (maximum)

Tip: add a small random spread (jitter) to the wait time. If multiple clients retry simultaneously after an outage, jitter prevents them from all hitting the server at the same moment.

Safe retries with idempotency

Always combine your retry logic with the X-EConnect-DocumentId header. By including the same documentId with each attempt, the PSB guarantees that a document is never processed twice. If the PSB receives a documentId that has already been processed, it returns a 409 Conflict as confirmation.

See Idempotency: preventing duplicate submissions for the full explanation and code examples.

Decision tree
Automatic retry mechanism of the PSB

In addition to the retry logic you implement yourself, the PSB has its own retry mechanism for document delivery. If the PSB attempts to deliver an invoice or order to the recipient and that party returns a 5xx error, the PSB automatically resumes delivery.

Document delivery (invoices and orders)

The PSB makes up to 8 retry attempts spread over approximately 35 hours. With each attempt the PSB publishes an event so you can track progress:

EventMeaningInvoiceSentRetryA new delivery attempt for an invoice has startedInvoiceSentErrorAll 8 attempts have failed, the invoice could not be deliveredOrderSentRetryA new delivery attempt for an order has startedOrderSentErrorAll 8 attempts have failed, the order could not be delivered

If you have configured a webhook for these topics, you receive a notification with each attempt. After an InvoiceSentError or OrderSentError, manual action is required: contact the recipient or escalate via eConnect Support.

Tip: subscribe to the InvoiceSentRetry and InvoiceSentError topics via a webhook. This way you detect delivery issues immediately and can act proactively.

Webhook delivery

For webhooks the PSB uses a separate retry schedule. If your webhook endpoint is unreachable or does not return a 2xx status code, the PSB retries delivering the event.

ParameterValueMaximum retry duration5 daysStrategyExponential backoffTimeout per attempt100 secondsEvent per attemptHookSentRetryEvent on definitive failureHookSentError

The PSB expects a 2xx response from your endpoint within 100 seconds. Any other response (or a timeout) counts as a failed attempt. Therefore, process incoming webhooks as quickly as possible, confirm receipt with a 200 OK and perform heavy processing asynchronously in a background process.

Note: if your endpoint is unreachable for an extended period, the PSB stops retrying after 5 days. Missed events can still be retrieved via the batch endpoint. See Batch hooks for more information.

Overview: retryable or not?
Status codeRetryableStrategy200 OKNot neededProcessed400 Bad RequestNoFix request401 UnauthorizedNoRequest new token403 ForbiddenNoCheck permissions404 Not FoundNoCheck URL/resource409 ConflictNoDocument was already processed413 Content Too LargeNoReduce file size500 Internal Server ErrorYesExponential backoff503 Service UnavailableYesExponential backoff

In short Client errors (4xx) require your attention: fix the problem in your request. Server errors (5xx) are temporary and can be safely retried with exponential backoff. Always use the X-EConnect-DocumentId header to prevent duplicate processing on retries. The PSB automatically retries document delivery up to 8 times over approximately 35 hours, and webhooks for up to 5 days.

View the full API documentation