# Command Queue

## Get due players

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/queue`

List the players who have commands due to be executed when they next login to the game server. This endpoint also returns any offline commands to be processed and the amount of seconds to wait before performing the queue check again. All clients should strictly follow the response of `next_check`, failure to do so would result in your secret key being revoked or IP address being banned from accessing the API.\
\
NOTE: The \`player.id\` field is an internal ID, sometimes referred to as the 'plugin username ID'. This is the value to use to retrieve online commands for a player (see below). the \`player.uuid\` field is the actual username ID value, depending on the username type (a Steam64ID for steam games, an XUID for Xbox Live etc), and is the value that should be used to replace the \`{id}\` placeholder in commands.\


#### Headers

| Name           | Type   | Description                    |
| -------------- | ------ | ------------------------------ |
| X-Tebex-Secret | string |  The secret key of the server. |

{% tabs %}
{% tab title="200 " %}
```javascript
{
  "meta": {
    "execute_offline": false,
    "next_check": 90,
    "more": false
  },
  "players": [
    {
      "id": 1,
      "name": "Notch",
      "uuid": "365bfa21803249ee9b634fe890c9d43f"
    },
    {
      "id": 2,
      "name": "7n",
      "uuid": "ef01f2da1b284ad6ba8ba2aaf4432e22"
    },
    {
      "id": 3,
      "name": "hfmx",
      "uuid": "897a2737777a4776909a0148919c376a"
    }
  ]
}
```
{% endtab %}
{% endtabs %}

## Get offline commands

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/queue/offline-commands`

Get the offline commands which are due to be executed.\
\
These commands should be executed immediately and no checks are required against the related players.\
\
NOTE: The \`player.id\` field is an internal ID, sometimes referred to as the 'plugin username ID', and isn't needed for offline commands. The \`player.uuid\` field is the actual username ID value, depending on the username type (a Steam64ID for steam games, an XUID for Xbox Live etc), and is the value that should be used to replace the \`{id}\` placeholder in commands.

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| X-Tebex-Secret | string | The secret key of the server. |

{% tabs %}
{% tab title="200 " %}
```javascript
{
  "meta": {
    "limited": false
  },
  "commands": [
    {
      "id": 1,
      "command": "say Thank you for purchasing, {name}.",
      "payment": 123,
      "package": 123,
      "conditions": {
        "delay": 60
      },
      "player": {
        "id": 1,
        "name": "Notch",
        "uuid": "365bfa21803249ee9b634fe890c9d43f"
      }
    },
    {
      "id": 2,
      "command": "say Thank you for purchasing, {name}.",
      "payment": 123,
      "package": 123,
      "conditions": {
        "delay": 0
      },
      "player": {
        "id": 2,
        "name": "7n",
        "uuid": "ef01f2da1b284ad6ba8ba2aaf4432e22"
      }
    },
    {
      "id": 3,
      "command": "say Thank you for purchasing, {name}.",
      "payment": 123,
      "package": 123,
      "conditions": {
        "delay": 0
      },
      "player": {
        "id": 3,
        "name": "hfmx",
        "uuid": "897a2737777a4776909a0148919c376a"
      }
    }
  ]
}
```
{% endtab %}
{% endtabs %}

## Get online commands

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/queue/online-commands/{player-id}`

List the due online commands for a specific player.\
\
These commands should only be executed when the player is online and all the conditions have been met (such as if the player has the required amount of inventory slots).

#### Path Parameters

| Name      | Type   | Description                                                        |
| --------- | ------ | ------------------------------------------------------------------ |
| player-id | string | The ID of the player you want to retrieve the online commands for. |

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| X-Tebex-Secret | string | The secret key of the server. |

{% tabs %}
{% tab title="200 " %}
```javascript
{
  "commands": [
    {
      "id": 1,
      "command": "give {name} TNT",
      "payment": 123,
      "package": 123,
      "conditions": {
        "delay": 0,
        "slots": 0
      }
    },
    {
      "id": 2,
      "command": "give {name} DIRT",
      "payment": 123,
      "package": 123,
      "conditions": {
        "delay": 0,
        "slots": 0
      }
    },
    {
      "id": 3,
      "command": "give {name} STONE",
      "payment": 123,
      "package": 123,
      "conditions": {
        "delay": 0,
        "slots": 0
      }
    }
  ]
}
```
{% endtab %}
{% endtabs %}

## Delete commands

<mark style="color:red;">`DELETE`</mark> `https://plugin.tebex.io/queue`

Delete one or more commands which have been executed on the game server.\
\
An empty response with the status code of`204 No Content` will be returned on completion.

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| X-Tebex-Secret | string | The secret key of the server. |

#### Request Body

| Name | Type  | Description                                    |
| ---- | ----- | ---------------------------------------------- |
| ids  | array | An array of one or more command IDs to delete. |

{% tabs %}
{% tab title="204 " %}
```
```
{% endtab %}
{% endtabs %}
