# Endpoints

### Login Endpoint

Once your account is ready to use the Support Ticket API, the first step will be authenticating yourself. This authentication process necessitates the submission of a POST request to the login endpoint mentioned below. This request should include the **accessKey (email)** and **secretKey (password)** in JSON format to validate and establish the user's credentials.

### Login to API user

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/auth/login`

**Production** `POST https://merchants-api.lime-pay.com/v1/auth/login`

**Request Body**

| Name                                        | Type   | Description                       |
| ------------------------------------------- | ------ | --------------------------------- |
| accessKey<mark style="color:red;">\*</mark> | string | Configured API User email address |
| secretKey<mark style="color:red;">\*</mark> | string | Configured API User's password    |

{% tabs %}
{% tab title="200: OK Login success" %}

```json
{
    "idUser": 123,
    "username": "your@email.com",
    "idMerchant": 456
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid credentials" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Make sure you add in the header of the request the following value:\
**Content-Type: application/json**
{% endhint %}

***

### Switch Context Endpoint

In some cases where a user needs to manage tickets from more than one MID, the Switch Context endpoint allows you to switch effortlessly between MIDs irrespective of the number of MIDs the user account belongs to.

### Switch Between MIDs

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/auth/{mid}/switchContext`

**Production** `POST https://merchants-api.lime-pay.com/v1/auth/{mid}/switchContext`

**Headers**

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| Content-Type | String | `application/json` |
| Cookie       | String | BEARER\_TOKEN      |

{% hint style="info" %}
Replace the `{mid}` in the URLs above with your merchant MID.

Note: You cannot switch to an account that the user does not belong to.
{% endhint %}

If switched from MID A to MID B, note that all responses from other endpoints will operate under MID B.

{% tabs %}
{% tab title="200: OK Context switched" %}
Context switched successfully. Your session now operates under the new merchant.
{% endtab %}

{% tab title="401: Unauthorized Session expired" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}
{% endtabs %}

***

### Logout Endpoint

Invalidates the current session token. Use this when you are done to keep your account secure.

### Delete Session

<mark style="color:red;">`DELETE`</mark> `https://merchants-api-stg.lime-pay.com/v1/auth/session/destroy`

**Production** `DELETE https://merchants-api.lime-pay.com/v1/auth/session/destroy`

**Headers**

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| Content-Type | String | `application/json` |
| Cookie       | String | BEARER\_TOKEN      |

{% tabs %}
{% tab title="200: OK Session destroyed" %}
Session destroyed successfully.
{% endtab %}

{% tab title="401: Unauthorized Session expired" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}
{% endtabs %}

***

### TICKET ENDPOINTS

Described below are the endpoints for creating and confirming support tickets.

To send requests, ensure you include the BEARER\_TOKEN obtained from the Login Endpoint in the Authentication header field of the requests. You can use it in the following ways:

**As part of the header:**

```
Authorization: Bearer U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk
```

**Or as a cookie:**

```
cookie: BEARER_TOKEN=U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk
```

***

#### Create Draft Ticket

### Create a support ticket in draft state

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/tickets/createTicket`

**Production** `POST https://merchants-api.lime-pay.com/v1/tickets/createTicket`

Creates a new support ticket in **draft** state. The ticket is not submitted until confirmed. After creation, you can add attachments before calling the confirm endpoint.

**Request Body**

| Name                                          | Type    | Description                                       |
| --------------------------------------------- | ------- | ------------------------------------------------- |
| type<mark style="color:red;">\*</mark>        | string  | Ticket type (e.g. `DEPOSIT`)                      |
| category                                      | string  | Ticket category (e.g. `FLAG_FOR_REVIEW_DEPOSIT`)  |
| description<mark style="color:red;">\*</mark> | string  | Description of the issue                          |
| referenceId                                   | integer | ID of the related entity (deposit, cashout, etc.) |

**Headers**

| Name          | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| Content-Type  | String | `application/json`                               |
| Cookie        | String | `BEARER_TOKEN=U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk` |
| Authorization | String | `Bearer U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk`       |

{% tabs %}
{% tab title="200: OK Draft ticket created" %}

```json
{
    "idTicket": 12345,
    "description": "Deposit not credited after 48h",
    "requiredDocuments": [
        "VOUCHER"
    ],
    "uploadedDocuments": []
}
```

{% endtab %}

{% tab title="401: Unauthorized" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}

{% tab title="403: Forbidden" %}

```json
{
    "code": "FORBIDDEN",
    "message": "Missing required capability: TICKETS_CREATE"
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Check the `requiredDocuments` field in the response. If there are items listed that are not in `uploadedDocuments`, you need to attach them before confirming the ticket.
{% endhint %}

***

#### Add Attachment

### Upload a document to a draft ticket

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/tickets/{idTicket}/addAttachment`

**Production** `POST https://merchants-api.lime-pay.com/v1/tickets/{idTicket}/addAttachment`

Uploads a file to a draft ticket. The ticket must still be in draft state (not yet confirmed).

{% hint style="info" %}
Replace `{idTicket}` with the ticket ID returned by the create ticket endpoint.

This request must be sent as **multipart/form-data**, not JSON.
{% endhint %}

**Request Body (multipart/form-data)**

| Name                                           | Type   | Description                                                  |
| ---------------------------------------------- | ------ | ------------------------------------------------------------ |
| file<mark style="color:red;">\*</mark>         | binary | The file to upload (PDF, image, etc.)                        |
| documentType<mark style="color:red;">\*</mark> | string | Type of document: `VOUCHER`, `ID_DOCUMENT`, `BANK_STATEMENT` |

**Headers**

| Name          | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| Content-Type  | String | `multipart/form-data`                            |
| Cookie        | String | `BEARER_TOKEN=U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk` |
| Authorization | String | `Bearer U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk`       |

{% tabs %}
{% tab title="200: OK Attachment uploaded" %}

```json
{
    "idTicket": 12345,
    "description": "Deposit not credited after 48h",
    "requiredDocuments": [
        "VOUCHER"
    ],
    "uploadedDocuments": [
        "VOUCHER"
    ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid file or type" %}

```json
{
    "code": "INVALID_DOCUMENT",
    "message": "Invalid file or document type"
}
```

{% endtab %}

{% tab title="404: Not Found" %}

```json
{
    "code": "NOT_FOUND",
    "message": "Ticket not found or already confirmed"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
For deposit review tickets, if a voucher already exists in the system it gets attached automatically. Check `uploadedDocuments` before uploading a duplicate.
{% endhint %}

***

### Confirm and submit a draft ticket

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/tickets/{idTicket}/confirmTicket`

**Production** `POST https://merchants-api.lime-pay.com/v1/tickets/{idTicket}/confirmTicket`

Confirms a draft ticket and submits it to the support team. Once confirmed, the ticket **cannot be modified**.

{% hint style="info" %}
Replace `{idTicket}` with the ticket ID returned by the create ticket endpoint.
{% endhint %}

**Headers**

| Name          | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| Content-Type  | String | `application/json`                               |
| Cookie        | String | `BEARER_TOKEN=U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk` |
| Authorization | String | `Bearer U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk`       |

{% tabs %}
{% tab title="200: OK Ticket confirmed" %}

```json
{
    "idTicket": 12345,
    "description": "Deposit not credited after 48h",
    "requiredDocuments": [
        "VOUCHER"
    ],
    "uploadedDocuments": [
        "VOUCHER"
    ]
}
```

{% endtab %}

{% tab title="401: Unauthorized" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}

{% tab title="403: Forbidden" %}

```json
{
    "code": "FORBIDDEN",
    "message": "Missing required capability: TICKETS_CONFIRM"
}
```

{% endtab %}

{% tab title="404: Not Found" %}

```json
{
    "code": "NOT_FOUND",
    "message": "Ticket not found"
}
```

{% endtab %}
{% endtabs %}

***

### DEPOSIT REVIEW ENDPOINTS

These endpoints allow you to flag a deposit or a deposit reversal for manual review. They automatically create a draft ticket — you only need to attach any missing documents and confirm.

***

#### Flag Deposit for Review

### Flag a deposit for manual review

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/deposits/{idDeposit}/flagForReview`

**Production** `POST https://merchants-api.lime-pay.com/v1/deposits/{idDeposit}/flagForReview`

Flags a deposit for manual review. Internally creates a ticket of type `FLAG_FOR_REVIEW_DEPOSIT`.

{% hint style="info" %}
Replace `{idDeposit}` with the deposit ID you want to flag for review.
{% endhint %}

**Validations performed before ticket creation:**

* Deposit must exist
* Deposit must belong to the authenticated merchant
* A minimum time interval must have passed since the deposit was created

If the deposit has a voucher, it is **automatically attached** to the ticket.

**Headers**

| Name          | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| Content-Type  | String | `application/json`                               |
| Cookie        | String | `BEARER_TOKEN=U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk` |
| Authorization | String | `Bearer U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk`       |

{% tabs %}
{% tab title="200: OK Review ticket created" %}

```json
{
    "idTicket": 67890,
    "description": "Flag for review - Deposit #98765",
    "requiredDocuments": [
        "VOUCHER"
    ],
    "uploadedDocuments": [
        "VOUCHER"
    ]
}
```

{% endtab %}

{% tab title="400: Bad Request Deposit not reviewable" %}

```json
{
    "code": "DEPOSIT_NOT_REVIEWABLE",
    "message": "The deposit does not meet the minimum requirements to be flagged for review"
}
```

{% endtab %}

{% tab title="401: Unauthorized" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}

{% tab title="403: Forbidden" %}

```json
{
    "code": "FORBIDDEN",
    "message": "Missing required capability: DEPOSITS_FLAG_REVIEW"
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
After flagging, check `requiredDocuments` vs `uploadedDocuments`. If the voucher was auto-attached, you may be able to confirm the ticket right away without uploading anything extra.
{% endhint %}

After receiving the response, you may add more attachments and confirm the ticket via `POST /v1/tickets/{idTicket}/confirmTicket`.

***

#### Flag Deposit Reversal for Review

### Flag a deposit reversal for manual review

<mark style="color:green;">`POST`</mark> `https://merchants-api-stg.lime-pay.com/v1/deposits/{idDeposit}/flagForReviewReversal`

**Production** `POST https://merchants-api.lime-pay.com/v1/deposits/{idDeposit}/flagForReviewReversal`

Flags a deposit **reversal** for manual review. Internally creates a ticket of type `FLAG_FOR_REVIEW_DEPOSIT_REVERSAL`. Applies the same validations and auto-attachment logic as `flagForReview`.

{% hint style="info" %}
Replace `{idDeposit}` with the deposit ID whose reversal should be flagged for review.
{% endhint %}

**Headers**

| Name          | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| Content-Type  | String | `application/json`                               |
| Cookie        | String | `BEARER_TOKEN=U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk` |
| Authorization | String | `Bearer U3dcUx8IRJ5nLjb0WYM4cHa3qHFqnrqAk`       |

{% tabs %}
{% tab title="200: OK Reversal review ticket created" %}

```json
{
    "idTicket": 67891,
    "description": "Flag for review reversal - Deposit #98765",
    "requiredDocuments": [
        "VOUCHER"
    ],
    "uploadedDocuments": [
        "VOUCHER"
    ]
}
```

{% endtab %}

{% tab title="400: Bad Request Deposit not reviewable" %}

```json
{
    "code": "DEPOSIT_NOT_REVIEWABLE",
    "message": "The deposit does not meet the minimum requirements to be flagged for review"
}
```

{% endtab %}

{% tab title="401: Unauthorized" %}

```json
{
    "code": "UNAUTHORIZED",
    "message": "Session expired or invalid token"
}
```

{% endtab %}

{% tab title="403: Forbidden" %}

```json
{
    "code": "FORBIDDEN",
    "message": "Missing required capability: DEPOSITS_FLAG_REVIEW"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lime-pay.com/api-documentation/support-tickets-api/endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
