> For the complete documentation index, see [llms.txt](https://docs.ecommerce.seb.ee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecommerce.seb.ee/integration/merchant-api/response-handling.md).

# Response Handling

When processing API responses, it is important to distinguish between:

* **HTTP Status Codes** – Indicates whether the request was successfully processed from a technical perspective.
* **Error Codes** – Provides additional details when a request cannot be processed successfully.
* **Payment Statuses and Status Reasons** – Indicates the business outcome of a payment operation.

### HTTP Status Codes

HTTP status codes indicate the outcome of the API request itself.

| Status Range | Description                                                                                                                                                          |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `2xx`        | The request was successfully received and processed.                                                                                                                 |
| `4xx`        | The request could not be processed due to an issue with the request, such as validation errors, authentication failures, insufficient permissions, or rate limiting. |
| `5xx`        | The request could not be completed due to an internal system error or temporary service unavailability.                                                              |

A successful `2xx` response only indicates that the request was processed successfully. It does **not** necessarily mean that the payment itself was successful, for this the payment statuses are used.

#### Error Codes

For non-successful requests, the response contains one or more error codes describing the specific reason for the failure.

Typical examples include:

* Invalid or missing request parameters.
* Authentication or authorization failures.
* Rate limit violations.
* Other business or technical validation errors.

Error codes should be used together with the HTTP status code when implementing error handling and troubleshooting logic.

### Payment Statuses

For payment-related operations, the payment outcome is communicated through the **payment status** returned in the API response or delivered through callback notifications.

A successful HTTP response may indicate a payment that is **pending**, **successful**, or **failed**, depending on the outcome of the payment processing. Applications should therefore use the payment status as the authoritative source for determining the payment outcome.

#### Payment Status Reasons

Payment statuses may include an accompanying **status reason** that provides additional context about why a payment reached its current state.

Status reasons indicate:

* Business-level outcomes, such as insufficient funds, expired cards, suspected fraud, issuer declines, or network declines.
* Processing and communication issues, such as issuer unavailability, network interruptions, or temporary processing failures.

Status reasons are intended to support payment handling logic, troubleshooting, reporting, and customer communication where appropriate.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecommerce.seb.ee/integration/merchant-api/response-handling.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
