# Prefetch API

The serverside.ai pre-fetch API offers a robust solution for the efficient delivery of ad sources, ensuring they are conditioned and ready for use upon request.&#x20;



## Get the ad medias for a given channel

<mark style="color:blue;">`GET`</mark> `https://admin.serverside.ai/api/v2/medias`

#### Headers

| Name                                        | Type   | Description                    |
| ------------------------------------------- | ------ | ------------------------------ |
| x-api-key<mark style="color:red;">\*</mark> | String | Your **serverside.ai** API key |

#### Request Body

| Name      | Type   | Description                                                                                              |
| --------- | ------ | -------------------------------------------------------------------------------------------------------- |
| type      | String | <p><code>deliverable</code> for ready conditioned medias <br><code>source</code> for ad media source</p> |
| channelId | String | Request for a given channel                                                                              |

## Prefetch ad media condition for given channel

<mark style="color:orange;">`PUT`</mark> `https://admin.serverside.ai/api/v2/channel-assets`

#### Headers

| Name                                        | Type   | Description                    |
| ------------------------------------------- | ------ | ------------------------------ |
| x-api-key<mark style="color:red;">\*</mark> | String | Your **serverside.ai** API key |

#### Request Body

| Name                                        | Type    | Description                                                     |
| ------------------------------------------- | ------- | --------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark>        | String  | Unique Identifier of the ad creative                            |
| name<mark style="color:red;">\*</mark>      | String  | Name of the ad creative/campaign                                |
| source<mark style="color:red;">\*</mark>    | String  | URL to the ad media creative                                    |
| channelId<mark style="color:red;">\*</mark> | String  | Provide the channel Id for which the prefetch should be applied |
| allChannels                                 | boolean | true if should be applied to all configured channels.           |

{% tabs %}
{% tab title="200: OK Successful" %}

{% endtab %}

{% tab title="400: Bad Request " %}
```
{
  "name": "BadRequestError",
  "message": "BadRequest",
  "code": 400,
  "type": "Your input data is not valid."
}
```
{% endtab %}

{% tab title="401: Unauthorized " %}
```
{
  "name": "UnAuthorizedError",
  "message": "Unauthorized",
  "code": 401,
  "type": "Request cannot be authenticated. Check if you are transferring an API-Key or JWT in the header."
}
```
{% endtab %}

{% tab title="403: Forbidden " %}
```
{
  "name": "ForbiddenError",
  "message": "Forbidden",
  "code": 403,
  "type": "You have no rights to access the resorce."
}
```
{% endtab %}

{% tab title="404: Not Found " %}
```
{
  "name": "NotFoundError",
  "message": "NotFound",
  "code": 404,
  "type": "No such item."
}
```
{% endtab %}

{% tab title="500: Internal Server Error " %}
```
{
  "name": "ServerError",
  "message": "ServerError",
  "code": 500,
  "type": "Error on server side."
}
```
{% endtab %}
{% endtabs %}
