> For the complete documentation index, see [llms.txt](https://docs.tebex.io/developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tebex.io/developers/affiliate-api/referrals.md).

# Referrals

## Create Referral

<mark style="color:green;">`POST`</mark> `https://affiliate.tebex.io/api/referrals`

This endpoint should be called when your customer requests that they want to install Tebex on their game server. It will send an email to the customer containing a link which allows them to setup their webstore and ensure your affiliate account is associated with the customer.

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer \<Your API Key> |

#### Request Body

| Name           | Type   | Description                                                                                                                                                               |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| link           | string | The UUID of your referral link within your affiliate panel. You can find this on <https://affiliate.tebex.io/links>, under your Link name.                                |
| reference      | string | A unique ID that references the customer's game server within your management panel. You will use this to identify the game server when we send the installation webhook. |
| game\_type\_id | number | The ID of the game type found within the game types endpoint.                                                                                                             |
| server\_name   | string | The name of your customer's game server.                                                                                                                                  |
| email          | string | The email address of the customer.                                                                                                                                        |
| last\_name     | string | The last name of the customer.                                                                                                                                            |
| first\_name    | string | The first name of the customer.                                                                                                                                           |

{% tabs %}
{% tab title="201: Created Affiliate successfully created." %}

```json
{
  "data": {
    "reference": "123456",
    "secret": null,
    "game_type": {
      "id": 1
    },
    "setup_at": null
  }
}
```

{% endtab %}
{% endtabs %}

## Get Referral

<mark style="color:blue;">`GET`</mark> `https://affiliate.tebex.io/api/referrals/:reference`

Retrieve an existing referral. This method is useful for checking if a customer has created their webstore and can also be used to retrieve the plugin urls and locations of the premade config files.

#### Path Parameters

| Name      | Type   | Description                                           |
| --------- | ------ | ----------------------------------------------------- |
| reference | string | The reference provided when you created the referral. |

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer \<Your API Key> |

{% tabs %}
{% tab title="200: OK Successfully retrieved an existing referral" %}

```json
{
  "data": {
    "reference": "123456",
    "secret": "9a6747fc6259aa374ab4e1bb03074b6ec672cf99",
    "game_type": {
      "id": 1,
      "plugins": {
        "bukkit": {
          "platform": "bukkit",
          "version": "10.2",
          "url": "https://d2vpaemuugs53a.cloudfront.net/latest/10.2/bukkit/BuycraftX.jar",
          "config": "http://affiliate.tebex.io/api/referrals/123456/config/bukkit"
        },
        "sponge": {
          "platform": "sponge",
          "version": "10.2",
          "url": "https://d2vpaemuugs53a.cloudfront.net/latest/10.2/sponge/BuycraftX.jar",
          "config": "http://affiliate.tebex.io/api/referrals/123456/config/sponge"
        },
        "bungeecord": {
          "platform": "bungeecord",
          "version": "10.2",
          "url": "https://d2vpaemuugs53a.cloudfront.net/latest/10.2/bungeecord/BuycraftX.jar",
          "config": "http://affiliate.tebex.io/api/referrals/123456/config/bungeecord"
        },
        "forge": {
          "platform": "forge",
          "version": "12.0.1",
          "url": "https://d2vpaemuugs53a.cloudfront.net/latest/minecraft-java/12.0.1/forge/BuycraftX.jar",
          "config": "http://affiliate.tebex.io/api/referrals/123456/config/forge"
        }
      }
    },
    "setup_at": "2020-11-17T09:41:57+00:00"
  }
}
```

{% endtab %}
{% endtabs %}

## Get Referral Config File

<mark style="color:blue;">`GET`</mark> `https://affiliate.tebex.io/api/referrals/:reference/config/:platform`

Retrieve the premade config file for a specific platform (such as Minecraft Spigot or Forge). The config file will include the customer's secret key, removing any need of manual setup of the Tebex plugin on the server's behalf.

#### Path Parameters

| Name      | Type   | Description                                           |
| --------- | ------ | ----------------------------------------------------- |
| platform  | string | The plugin platform such as bukkit or forge.          |
| reference | string | The reference provided when you created the referral. |

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer \<Your API Key> |

{% tabs %}
{% tab title="200: OK The premade config file for the Tebex plugin" %}

```
#BuycraftX configuration file
push-commands=true
server-key=a8ba0940f9deb37b79d66fa19f8b36ba5df14fa2
verbose=false
disable-buy-command=false
check-for-updates=true
buy-command-name=buy
is-bungeecord=false
language=en-GB
```

{% endtab %}
{% endtabs %}
