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

# Get Media

> Retrieve media files with optional filters

## Endpoint

```
POST https://api.ugc.inc/media
```

## Overview

Retrieve all media for your organization, including both user-uploaded files and social audio. Supports filtering by specific IDs or tags.

## Request Body

<ParamField body="ids" type="string[]">
  Filter to specific media IDs. Returns only media matching these IDs.
</ParamField>

<ParamField body="tag" type="string">
  Filter media by tag
</ParamField>

## Response

<ResponseField name="data" type="Media[]">
  Array of media objects (both UserMedia and SocialAudio)

  <Expandable title="UserMedia properties">
    <ResponseField name="id" type="string">
      Unique media identifier
    </ResponseField>

    <ResponseField name="org_id" type="string">
      Organization ID
    </ResponseField>

    <ResponseField name="name" type="string | null">
      File name
    </ResponseField>

    <ResponseField name="tag" type="string | null">
      Custom tag for categorization
    </ResponseField>

    <ResponseField name="type" type="'video' | 'image' | 'audio' | null">
      Media type
    </ResponseField>

    <ResponseField name="url" type="string">
      Public URL to the file
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO timestamp of creation
    </ResponseField>

    <ResponseField name="media_type" type="'user_media'">
      Discriminator field
    </ResponseField>
  </Expandable>

  <Expandable title="SocialAudio properties">
    <ResponseField name="id" type="string">
      Unique audio identifier
    </ResponseField>

    <ResponseField name="org_id" type="string">
      Organization ID
    </ResponseField>

    <ResponseField name="name" type="string | null">
      Audio/song title
    </ResponseField>

    <ResponseField name="tag" type="string | null">
      Custom tag for categorization
    </ResponseField>

    <ResponseField name="social_post_link" type="string | null">
      Link to a TikTok post using this audio
    </ResponseField>

    <ResponseField name="social_audio_link" type="string | null">
      Direct link to the TikTok audio/music page
    </ResponseField>

    <ResponseField name="platform_type" type="'tiktok' | null">
      Source platform
    </ResponseField>

    <ResponseField name="preview_url" type="string | null">
      URL to cover image
    </ResponseField>

    <ResponseField name="audio_url" type="string | null">
      URL to audio file
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO timestamp of creation
    </ResponseField>

    <ResponseField name="media_type" type="'social_audio'">
      Discriminator field
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.ugc.inc/media \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "tag": "products"
    }'
  ```

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

  response = requests.post(
      'https://api.ugc.inc/media',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'tag': 'products'
      }
  )

  data = response.json()

  if data['ok']:
      for media in data['data']:
          if media['media_type'] == 'user_media':
              print(f"File: {media['name']} - {media['url']}")
          else:
              print(f"Audio: {media['name']} - {media['audio_url']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.ugc.inc/media', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      tag: 'products'
    })
  });

  const data = await response.json();

  if (data.ok) {
    data.data.forEach(media => {
      if (media.media_type === 'user_media') {
        console.log(`File: ${media.name} - ${media.url}`);
      } else {
        console.log(`Audio: ${media.name} - ${media.audio_url}`);
      }
    });
  }
  ```

  ```typescript React theme={null}
  import { UGCClient } from 'ugcinc';

  const client = new UGCClient({
    apiKey: 'YOUR_API_KEY'
  });

  // Get all media
  const response = await client.media.getMedia();

  // Get media by specific IDs
  const byIds = await client.media.getMedia({
    ids: ['media_abc123', 'audio_def456']
  });

  // Get media by tag
  const byTag = await client.media.getMedia({
    tag: 'products'
  });

  if (response.ok) {
    response.data.forEach(media => {
      console.log(`${media.name} (${media.media_type})`);
    });
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "ok": true,
    "code": 200,
    "data": [
      {
        "id": "media_abc123",
        "org_id": "org_xyz789",
        "name": "product-video.mp4",
        "tag": "products",
        "type": "video",
        "url": "https://api.ugc.inc/media/file/media_abc123",
        "created_at": "2024-01-15T10:30:00.000Z",
        "media_type": "user_media"
      },
      {
        "id": "audio_def456",
        "org_id": "org_xyz789",
        "name": "Trending Sound",
        "tag": "products",
        "social_post_link": "https://www.tiktok.com/@user/video/123",
        "social_audio_link": "https://www.tiktok.com/music/Trending-Sound-123",
        "platform_type": "tiktok",
        "preview_url": "https://api.ugc.inc/media/file/audio_def456/preview",
        "audio_url": "https://api.ugc.inc/media/file/audio_def456/audio",
        "created_at": "2024-01-14T09:00:00.000Z",
        "media_type": "social_audio",
        "type": "social_audio"
      }
    ]
  }
  ```
</ResponseExample>
