# Webhook Data Structure

This document explains the structure and meaning of each field.

### Example Payload

```json
{
  "event": "payment.success",
  "created_at": "2025-09-04T13:45:44-04:00",
  "request_id": "51b97ba5891ec220e8b64385a00c3826",  
  "webhook_id": "458",
  "store_id": "7541",
  "mode": "live", // live or test
  "data": {
    "id": 71134,
    "type": 1, // 1 = payment | 2 = subscription
    "transaction_id": "68B9D0471D02A",
    "gateway": "paypal", // stripe, paypal or free
    "amount": {
      "total_paid": 12,
      "currency": "EUR"
    },
    "user": {
      "email": "example@gmail.com",
      "username": "Murga",
      "steam_id": "76561198030562915",
      "steam_username": "Murgator",
      "discord_id": "376442921087995901",
      "discord_username": "murgator"
    },
    "basket": [
      {
        "id": 183,
        "sub_key": "762szqztj",
        "name": "Gold Sword",
        "price": 10,
        "quantity": 1,
        "custom_fields": {
          "1": {
            "field_id": 1,
            "name": "Level",
            "value": {
              "option_id": 2,
              "name": "Maximum",
              "value": "800", // value selected by the customer
              "price": 2.00
            },
            "total_price": 2,
            "type": "selection"
          }
        }
      }
    ],
    "actions": [
      {
        "server_id": "20861",
        "commands": [
          {
            "str": "give apple {minecraft_uuid} 1",
            "event": "0",
            "item_key": 0,
            "product_id": "183"
          },
          {
            "str": "give hook{minecraft_uuid} 1",
            "event": "0",
            "item_key": 0,
            "product_id": "185"
          }
        ]
      },
      {
        "server_id": "20859",
        "commands": [
          {
            "str": "give apple {minecraft_uuid} 1",
            "event": "0",
            "item_key": 0,
            "product_id": "183"
          },
          {
            "str": "give hook{minecraft_uuid} 1",
            "event": "0",
            "item_key": 0,
            "product_id": "185"
          }
        ]
      }
    ],
  }
}
```

***

### 🧾Main Fields

<table><thead><tr><th>Field</th><th>Type</th><th width="213">Example</th><th>Description</th></tr></thead><tbody><tr><td><code>event</code></td><td>string</td><td><code>payment.success</code>, <code>payment.refused</code>, <code>payment.refunded</code>, <code>subscription.created</code>, <code>subscription.renewed</code>, <code>subscription.expired</code></td><td>Event name</td></tr><tr><td><code>created_at</code></td><td>string (ISO 8601)</td><td><code>2025-09-04T13:45:44-04:00</code></td><td>Date and time of the event</td></tr><tr><td><code>request_id</code></td><td>string</td><td><code>51b97ba5891ec220e8b64385a00c3826</code></td><td>Unique webhook ID (useful for logs/debug)</td></tr><tr><td><code>webhook_id</code></td><td>int</td><td><code>458</code></td><td>Webhook ID</td></tr><tr><td><code>store_id</code></td><td>int</td><td><code>7541</code></td><td>Your shop ID</td></tr><tr><td><code>data</code></td><td>object</td><td><code>{...}</code></td><td>Event-related data</td></tr><tr><td><code>mode</code></td><td>string</td><td><code>test</code>, <code>live</code></td><td>Payment mode</td></tr></tbody></table>

***

### 💳 `Data` Object

| Field            | Type   | Example                                   | Description                                             |
| ---------------- | ------ | ----------------------------------------- | ------------------------------------------------------- |
| `id`             | int    | `71134`                                   | Internal payment ID or subscription ID                  |
| `transaction_id` | string | `68B9D0471D02A`                           | Transaction ID                                          |
| `gateway`        | string | `free`, `paypal`, `stripe`                | Payment gateway used or free order                      |
| `amount`         | object | `{ "total_paid": 12, "currency": "EUR" }` | Paid amount and currency                                |
| `user`           | object | `{...}`                                   | User information (multi-game + Discord/Steam/etc.)      |
| `basket`         | array  | `[ {...} ]`                               | Purchased products                                      |
| `actions`        | object | `{...}`                                   | Commands related to the payment (Discord, server, etc.) |
| `type`           | int    | `1`, `2`                                  | 1 = payment, 2 = subscription                           |

***

### 👤 `user` Object

Contains identifiers of the user, which may vary depending on the configuration:

* `email` → User email
* `username` → Display name
* `steam_id`, `steam_username` → Steam identity
* `minecraft_username`, `minecraft_uuid` → Minecraft identity
* `eosid` → ARK:SA ID
* `fivem_citizen_id` → FiveM identifier
* `discord_id`, `discord_username` → Discord identity

⚠️ Some fields may be missing if the user has not linked that service.

***

### 🛒 `basket` Object

Each purchased product is listed here:

| Field           | Example     | Description                               |
| --------------- | ----------- | ----------------------------------------- |
| `id`            | `183`       | Product ID                                |
| `sub_key`       | `762szqztj` | Tip4Serv product key                      |
| `name`          | `VIP Rank`  | Product name                              |
| `price`         | `10.00`     | Unit price                                |
| `quantity`      | `1`         | Quantity purchased                        |
| `custom_fields` | `{...}`     | Custom fields associated with the product |

***

### ⚙️ `commands` Object

The `commands` object contains **all servers (API type only) and actions** configured by the seller in the product editor.\
For each server you will find one or more groups of commands which depends on what you have configured in the products ordered by the customer.

| Field        | Example                   | Description                                                                                                                    |
| ------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `str`        | `give {steam_id} apple 1` | The actual command string to execute.                                                                                          |
| `event`      | `0 or 1`                  | <p>Option selected by the seller in the product editor:<br>0 → Always execute<br>1  → Execute only if the player is online</p> |
| `product_id` | `183`                     | The Tip4Serv product ID linked to this command.                                                                                |
| `item_key`   | `0`, `1`, `2`...          | <p>Index of the item in the buyer’s basket. </p><p>0 = first product, 1 = second product...</p>                                |
| `server_id`  | `XXXXXX`                  | Server ID on which these commands should be executed                                                                           |


---

# 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.tip4serv.com/webhooks-developers-only/webhook-data-structure.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.
