> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.lootlabs.gg/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# LootLabs API Documentation

||| ${color}[#ff0000](\*\* Note: \*\* )The API checks user data from the user that generated it, if you didn't fill in your MANDATORY creator details the API will have a failed response just like trying to create a link in the panel. In order to change creator setting [Click Here](https://help.lootlabs.gg/en/article/how-do-i-change-creator-details-change-name-avatar-and-social-links-xejvsb/)

# Loot Labs API Documentation - Create Link Shortener

## API Endpoint:
\*\* `POST&#32;`https://creators.lootlabs.gg/api/public/content_locker \*\*

## Description:
This endpoint allows you to create a link shortener.
The endpoint supports both POST and GET requests

This API is older and less versatile than the newer [REDIRECT API](https://help.lootlabs.gg/en/article/how-do-i-get-a-lootlabs-api-key-1ccz7zy/) We recommended using that API for more reliable automation
## Request Body:
| Field Name | Field Description | Field Mandatory | Validation | Options |
| ---- |
| `title` | The title of the link. | \*\* Mandatory  \*\* | String value, Max 30 characters. |  |
| `url` | The final destination of the content monetizer, this is the link you're locking. | \*\* Mandatory \*\* | String | Needs to be a valid link. |
| `tier_id` | The tier of the advertisements shown. | \*\* Mandatory \*\* | Numeric value, Options 1-3. | 1 - Trending & Recommended / 2 - Gaming Offers & Recommendations / 3 - Profit Maximization / 4 - Maximum Profit and Software Products |
| `number_of_tasks` | The max number of ads associated with the link shortener in a given session. | \*\* Mandatory \*\* | Numeric value between 1 and 5. | 1-5 |
| `theme` | The theme of the link monetizer site. | \*\* Optional \*\* | Numeric value, Options 1-5, \*\* Default: 1. \*\* | 1 - Classic / 2 - Sims / 3 - Minecraft / 4 - GTA / 5 - Space |
| `thumbnail` | thumbnail is another name for our thumbnail, it's the little image/video in the link | \*\* Optional \*\* | Needs to be a valid link | Could be a link of any image format or a youtube link. |

# POST REQUESTS

## Authorization:
When making \*\* POST \*\* requests to this API endpoint, you should include your API token in the \*\* "Authorization" header \*\* of your HTTP request. Set the header as follows:

`Authorization: Bearer YOUR_API_TOKEN` 

Replace  \*\* `YOUR_API_TOKEN` \*\* with your actual API token obtained from The Loot Labs Panel Under API.

## Response:
If the request is successful, the API will respond with a success message and the details of the created link shortener.

## Example POST Request:

\`POST https://creators.lootlabs.gg/api/public/content_locker
{
"title": "hello",
"url": "https://yourlinkhere.com",
"tier\_id": 1,
"number\_of\_tasks": 3,
"theme": 3,
"thumbnail": "https://example.com/thumbnail.jpg"
}\`

## Example Successfull Response:

```json
{
"type": "created",
"request_time": 256,
"message": {
            "title": "hello",
            "url": "https://yourlinkhere.com",
            "tier_id": 1,
            "number_of_tasks": 3,
            "theme": 3,
             "thumbnail": "https://example.com/thumbnail.jpg",
            "short": "xxxx",
            "loot_url": "https://loot-link.com/s?xxxx"
        }
}
```

## Example Failed Response:
```json
{
"type": "error",
"request_time": 6926,
"message": "Missing mandatory field: number_of_tasks"
}
```

# GET REQUEST

We also support passing parameters in the query parameters GET request using the following syntax:

### Authorization
Authorization is checked using the \*\* GET  \*\* request with the query parameter called \*\* api\_token=<YOURTOKEN> \*\* be sure to change yourtoken to the API token you generate in the panel.

## Example GET Request:

`GET https://creators.lootlabs.gg/api/public/content_locker?api_token=<YOURTOKEN>&title=title&url=url.com&tier_id=3&number_of_tasks=3&theme=1&thumbnail=https://www.youtube.com/watch?v=dQw4w9WgXcQ`

## Example Successfull Response:

```json
{
"type": "fetch",
"request_time": 2203,
"message": {
            "title": "title",
            "url": "url.com",
            "tier_id": 3,
            "number_of_tasks": 3,
            "theme": 1,
             "thumbnail": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
            "short": "xxxx",
            "loot_url": "https://loot-link.com/s?xxxx"
        }
}
```

## Example Failed Response:

```json
{
"type": "error",
"request_time": 889,
"message": "Internal Server Error"
}
```

# Examples of Endpoint API integration:

## Javascript/NodeJS POST request
```javascript
const axios = require('axios');

// API Endpoint
const url = 'https://creators.lootlabs.gg/api/public/content_locker';

// Replace 'YOUR_API_TOKEN' with your actual API token
const headers = {| xx | xx | xx |
| --- | --- | --- |
|  | xx | xx |
| xx | xx | xx |
    Authorization: 'Bearer YOUR_API_TOKEN'
};

// Request body data
const data = {
    title: 'hello',
    url: 'https://yourlinkhere.com',
    tier_id: 1,
    number_of_tasks: 3,
    theme: 3,
    thumbnail: 'https://example.com/thumbnail.jpg'
};

// Send POST request
axios.post(url, data, { headers: headers })
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error('Error:', error);
    });
```

## Javascript/NodeJS GET request

```javascript
const axios = require('axios');

// API Endpoint with query parameters
const api_token = 'YOUR_API_TOKEN'; // Replace with your actual API token
const url = `https://creators.lootlabs.gg/api/public/content_locker?api_token=${api_token}&title=title&url=url.com&tier_id=3&number_of_tasks=3&theme=1&thumbnail=https://www.youtube.com/watch?v=dQw4w9WgXcQ`;

// Send GET request
axios.get(url)
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error('Error:', error);
    });
```

## PHP POST Request

```php
<?php

// API Endpoint
$url = 'https://creators.lootlabs.gg/api/public/content_locker';

// Replace 'YOUR_API_TOKEN' with your actual API token
$headers = [
    'Authorization: Bearer YOUR_API_TOKEN',
    'Content-Type: application/json'
];

// Request body data
$data = [
    'title' => 'hello',
    'url' => 'https://yourlinkhere.com',
    'tier_id' => 1,
    'number_of_tasks' => 3,
    'theme' => 3,
    'thumbnail' => 'https://example.com/thumbnail.jpg'
];

// Initialize cURL session
$ch = curl_init($url);

// Set cURL options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute cURL session and get the response
$response = curl_exec($ch);

// Close cURL session
curl_close($ch);

// Print response
echo $response;
?>
```

## PHP GET request

```php
<?php

// API Endpoint with query parameters

$api_token = 'YOUR_API_TOKEN'; // Replace with your actual API token

$url = 'https://creators.lootlabs.gg/api/public/content_locker?api_token=' . $api_token . '&title=title&url=url.com&tier_id=3&number_of_tasks=3&theme=1&thumbnail=https://www.youtube.com/watch?v=dQw4w9WgXcQ';

// Initialize cURL session
$ch = curl_init($url);

// Set cURL options
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute cURL session and get the response
$response = curl_exec($ch);

// Close cURL session
curl_close($ch);

// Print response
echo $response;
?>
```

## Python POST Request

```python
import requests

# API Endpoint
url = "https://creators.lootlabs.gg/api/public/content_locker"

# Replace 'YOUR_API_TOKEN' with your actual API token
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN"
}

# Request body data
data = {
    "title": "hello",
    "url": "https://yourlinkhere.com",
    "tier_id": 1,
    "number_of_tasks": 3,
    "theme": 3,
    "thumbnail": "https://example.com/thumbnail.jpg"
}

# Send POST request
response = requests.post(url, headers=headers, json=data)

# Print response
print(response.json())
```

## Python GET Request

```python
import requests

# API Endpoint with query parameters
api_token = "YOUR_API_TOKEN"  # Replace with your actual API token
url = f"https://creators.lootlabs.gg/api/public/content_locker?api_token={api_token}&title=title&url=url.com&tier_id=3&number_of_tasks=3&theme=1&thumbnail=https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# Send GET request
response = requests.get(url)

# Print response
print(response.json())
```
