Handle Swish API errors using the standard error envelope and HTTP status codes.
When a request fails, the Swish API returns a JSON error response with a consistent structure. The HTTP status code indicates the category of failure, and the response body provides details for debugging.
The @swishapp/api-client never throws on API errors. Instead, every response
is a union: check for "error" in result to distinguish failures from
successful responses.
Every response - successful or failed - includes a requestId. When reporting an issue to Swish support, include the request ID so the team can look up the exact request in the logs.
Assistant
Responses are generated using AI and may contain mistakes.