> ## Documentation Index
> Fetch the complete documentation index at: https://docs.topsort.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating an asset

> Learn how to create an image, video, html, or json asset.

# Overview

Creating an asset is a two-step process where you first create the asset and then upload the actual file.

For more information about using the assets in your campaigns, see the [working with assets](/en/knowledge-base/ad-platform/assets/) page.

# Step 1: Create the asset

Create the asset by calling the [Create Asset](/en/api-reference/assets-api/create-asset) API. This will return an upload URL along with all the information needed to upload the file.

The asset status will be `pending_upload` at this point.

# Step 2: Upload the file

<Warning>
  The upload URL is only valid for a short period of time, so make sure to upload the file within 30 minutes after creating the asset.

  If the upload URL expires, you can create a new asset and use the new upload URL.
</Warning>

Once you have the upload URL, you can upload the file using a standard HTTP POST request.

## Example API Request for image/html/json assets

Following Python snippet shows how to upload a GIF asset using the `id`, `fields`, and `uploadUrl` returned in the asset creation response.

You can also use your preferred language and library to upload the file:

```python theme={null}
import requests
# create_asset_response is the JSON response from the create asset request
create_asset_response = {...}
with open("my-asset.gif", "rb") as f:
    files = {"file": (create_asset_response["id"], f)}
    http_response = requests.post(
        url=create_asset_response["uploadUrl"],
        data=create_asset_response["fields"],
        files=files,
    )
```

## Example API Request for video assets

Following Python snippet shows how to upload a video asset using the `id` and `uploadUrl` returned in the asset creation response.

You can also use your preferred language and library to upload the file:

```python theme={null}
import requests
# create_asset_response is the JSON response from the create asset request
create_asset_response = {...}
with open("my-asset.mp4", "rb") as f:
    files = {"file": (create_asset_response["id"], f)}
    http_response = requests.post(
        url=create_asset_response["uploadUrl"],
        files=files,
    )
```

# Step 3: Confirm that the asset is ready to use

Once the file has been uploaded, you can confirm that the asset is ready to use by calling the [Get Asset](/en/api-reference/assets-api/get-asset) API after a few seconds delay. In the case of videos, the delay might be longer due to the video encoding process.

The asset status should now be `approved` and the `url` field will contain the URL to the asset. You can now use the asset in your campaigns by passing the asset ID in your banners during [campaign creation](/en/api-reference/campaign-api/create-campaign).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.