# Cancel Tour

Ends a running free tour early. Use the `tour_id` you sent to [Create Tour](https://my.nexusggr.com/app/docs/integration/freespin-tour-api/create-tour).

> **`PRAGMATIC` only for now**, like [Create Tour](https://my.nexusggr.com/app/docs/integration/freespin-tour-api/create-tour) — there are no tours on other providers to cancel.

### Endpoint

```
POST https://api.nexusggr.com
```

**Content-Type:** `application/json`

### Request

**Method:** `tour_cancel`

```json
{
    "method": "tour_cancel",
    "agent_code": "your_agent_code",
    "agent_token": "your_agent_token",
    "tour_id": "free_tour_777"
}
```

| Field         | Type   | Required | Description                         |
| ------------- | ------ | -------- | ----------------------------------- |
| `method`      | string | Yes      | Must be `tour_cancel`               |
| `agent_code`  | string | Yes      | Your agent code                     |
| `agent_token` | string | Yes      | Your agent API token                |
| `tour_id`     | string | Yes      | The `tour_id` of the tour to cancel |

### Response

#### Success

```json
{
    "status": 1,
    "code": 7777777,
    "msg": "SUCCESS",
    "tour_id": "free_tour_777",
    "user_code": "test",
    "provider_code": "PRAGMATIC",
    "game_code": "vs20doghouse",
    "rest_count": 6,
    "total_win": 15500,
    "canceled_money": 54460
}
```

| Field            | Type    | Description                                              |
| ---------------- | ------- | -------------------------------------------------------- |
| `rest_count`     | integer | Free rounds the user never got to play                   |
| `total_win`      | number  | What the tour had already paid the user                  |
| `canceled_money` | number  | Returned to your agent balance: `real_win` − `total_win` (or − what the tour's transactions paid out, if that is more), never below `0` |

The user keeps what the tour already paid. Only the part that was never played is given back.

#### Failure

```json
{
    "status": 0,
    "code": 7770025,
    "msg": "There is no running tour."
}
```

```json
{
    "status": 0,
    "code": 7770502,
    "msg": "External Error : TOUR_IN_PROGRESS"
}
```

The text after `External Error : ` says why:

| Reason                                                                     | Description                                                                                                                  |
| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `TOUR_NOT_FOUND`                                                           | The game server has no such tour, or it already ended. A tour that expired is refunded on its own (see [Create Tour](https://my.nexusggr.com/app/docs/integration/freespin-tour-api/create-tour)) |
| `TOUR_IN_PROGRESS`                                                         | A free round is being played right now. Cancelling mid-round would turn it into a paid one — retry once the round is over    |
| `tour_id free_tour_777 is still being created, try again in a few minutes` | Its [Create Tour](https://my.nexusggr.com/app/docs/integration/freespin-tour-api/create-tour) request has not finished yet. Retry in a few minutes                                                |
| `tour_id free_tour_777 is being settled, try again in a few minutes`       | Another cancel, or the tour's expiry, is being settled right now. Retry in a few minutes                                     |
| `the request to the PRAGMATIC game server failed`                          | The game server did not answer. Nothing was refunded — retry                                                                 |

A tour can only be canceled once, and it is refunded only once. `There is no running tour.` also comes back for a tour that was already canceled or refunded on expiry.
