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

# Get Asset

> Retrieve details about a specific asset by its ID

## Overview

Fetch metadata and details for a specific uploaded asset using its unique identifier.

## Request

### Path Parameters

<ParamField path="assetId" type="string" required>
  The unique identifier of the asset (UUID format)
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key: `Bearer sk-bab-your-api-key`
</ParamField>

## Response

<ResponseField name="id" type="string">
  Unique identifier for the asset
</ResponseField>

<ResponseField name="name" type="string">
  Asset filename
</ResponseField>

<ResponseField name="url" type="string | null">
  S3 URL to access the asset
</ResponseField>

<ResponseField name="content_type" type="string">
  MIME type of the file
</ResponseField>

<ResponseField name="size" type="number | null">
  File size in bytes
</ResponseField>

<ResponseField name="state" type="string">
  Current state: `uploading`, `processing`, `ready`, or `error`
</ResponseField>

<ResponseField name="duration" type="number | null">
  Duration in seconds (for video/audio files)
</ResponseField>

<ResponseField name="width" type="number | null">
  Width in pixels (for image/video files)
</ResponseField>

<ResponseField name="height" type="number | null">
  Height in pixels (for image/video files)
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp of when the asset was uploaded
</ResponseField>

## Examples

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.babou.ai/api/v1/assets/ast_abc123xyz456789012 \
    -H "Authorization: Bearer $BABOU_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  async function getAsset(assetId: string) {
    const response = await fetch(
      `https://api.babou.ai/api/v1/assets/${assetId}`,
      {
        headers: {
          'Authorization': `Bearer ${process.env.BABOU_API_KEY}`
        }
      }
    );

    if (!response.ok) {
      throw new Error(`Failed to fetch asset: ${response.statusText}`);
    }

    const asset = await response.json();
    return asset;
  }

  const asset = await getAsset('ast_abc123xyz456789012');
  console.log('Asset URL:', asset.url);
  console.log('Size:', asset.size, 'bytes');
  ```

  ```python Python theme={null}
  import os
  import requests

  def get_asset(asset_id):
      response = requests.get(
          f'https://api.babou.ai/api/v1/assets/{asset_id}',
          headers={'Authorization': f'Bearer {os.environ["BABOU_API_KEY"]}'}
      )

      if not response.ok:
          raise Exception(f'Failed to fetch asset: {response.text}')

      return response.json()

  asset = get_asset('ast_abc123xyz456789012')
  print(f'Asset URL: {asset["url"]}')
  print(f'Size: {asset["size"]} bytes')
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "id": "ast_abc123xyz456789012",
  "name": "uploaded-file",
  "url": "s3://babou-assets/assets/ast_abc123xyz456789012-original",
  "content_type": "image/png",
  "size": 245678,
  "state": "ready",
  "duration": null,
  "width": 1920,
  "height": 1080,
  "created_at": "2025-12-02T10:00:00Z"
}
```

## Error Responses

<ResponseField name="NOT_FOUND" type="404">
  Asset not found or you don't have access

  ```json theme={null}
  {
    "error": "Asset not found",
    "code": "NOT_FOUND"
  }
  ```
</ResponseField>

<ResponseField name="UNAUTHORIZED" type="401">
  Invalid or missing API key

  ```json theme={null}
  {
    "error": "Unauthorized - Invalid API key",
    "code": "UNAUTHORIZED"
  }
  ```
</ResponseField>

## Use Cases

<AccordionGroup>
  <Accordion title="Check upload status">
    After uploading a large file, poll this endpoint to verify the upload completed successfully:

    ```typescript theme={null}
    async function waitForAssetReady(assetId: string, maxAttempts = 10) {
      for (let i = 0; i < maxAttempts; i++) {
        const asset = await getAsset(assetId);

        if (asset.state === 'ready') {
          return asset;
        }

        if (asset.state === 'failed') {
          throw new Error('Asset upload failed');
        }

        await new Promise(r => setTimeout(r, 2000)); // Wait 2s
      }

      throw new Error('Asset not ready after maximum attempts');
    }
    ```
  </Accordion>

  <Accordion title="Verify asset before using in project">
    Before referencing an asset in your video project, verify it exists and is accessible:

    ```typescript theme={null}
    async function validateAsset(assetId: string) {
      try {
        const asset = await getAsset(assetId);
        return asset.state === 'ready';
      } catch (error) {
        console.error('Asset validation failed:', error);
        return false;
      }
    }
    ```
  </Accordion>

  <Accordion title="Get download URL">
    Retrieve the public URL to download or display the asset:

    ```python theme={null}
    def get_asset_url(asset_id):
        asset = get_asset(asset_id)
        return asset['url']

    # Use the URL to download
    import requests
    url = get_asset_url('ast_abc123xyz456789012')
    content = requests.get(url).content
    ```
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Upload Asset" icon="upload" href="/api-reference/assets/upload">
    Upload a new asset
  </Card>

  <Card title="List Assets" icon="list" href="/api-reference/assets/list">
    View all your assets
  </Card>
</CardGroup>
