> ## 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.

# Update Media Tag

> Update tags on one or more media items

## Endpoint

```
POST https://api.ugc.inc/media/update-tag
```

## Overview

Update tags on one or more media items. Works for both user-uploaded media and social audio. Supports bulk updates with different tags for each item in a single request.

## Request Body

### Bulk Update (Recommended)

<ParamField body="updates" type="array" required>
  Array of update objects, each containing:

  <Expandable title="Update Object">
    <ParamField body="id" type="string" required>
      The ID of the media item to update
    </ParamField>

    <ParamField body="tag" type="string" required>
      The new tag value for this item
    </ParamField>
  </Expandable>
</ParamField>

### Single Update (Deprecated)

<ParamField body="id" type="string">
  The ID of the media item to update (deprecated - use `updates` array instead)
</ParamField>

<ParamField body="tag" type="string">
  The new tag value (deprecated - use `updates` array instead)
</ParamField>

## Response

<ResponseField name="data.results" type="array">
  Array of update results, one for each item in the request:

  <Expandable title="Result Object">
    <ResponseField name="id" type="string">
      The ID of the media item
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Whether the update succeeded
    </ResponseField>

    <ResponseField name="media" type="UserMedia | SocialAudio">
      The updated media object (only present if successful)
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message (only present if failed)
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL (Bulk) theme={null}
  curl -X POST https://api.ugc.inc/media/update-tag \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "updates": [
        { "id": "media_abc123", "tag": "featured" },
        { "id": "media_def456", "tag": "archive" },
        { "id": "media_ghi789", "tag": "featured/videos" }
      ]
    }'
  ```

  ```python Python (Bulk) theme={null}
  import requests

  response = requests.post(
      'https://api.ugc.inc/media/update-tag',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'updates': [
              {'id': 'media_abc123', 'tag': 'featured'},
              {'id': 'media_def456', 'tag': 'archive'},
              {'id': 'media_ghi789', 'tag': 'featured/videos'}
          ]
      }
  )

  data = response.json()

  for result in data['data']['results']:
      if result['success']:
          print(f"Updated {result['id']} to: {result['media']['tag']}")
      else:
          print(f"Failed to update {result['id']}: {result['error']}")
  ```

  ```javascript JavaScript (Bulk) theme={null}
  const response = await fetch('https://api.ugc.inc/media/update-tag', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      updates: [
        { id: 'media_abc123', tag: 'featured' },
        { id: 'media_def456', tag: 'archive' },
        { id: 'media_ghi789', tag: 'featured/videos' }
      ]
    })
  });

  const data = await response.json();

  for (const result of data.data.results) {
    if (result.success) {
      console.log(`Updated ${result.id} to: ${result.media.tag}`);
    } else {
      console.log(`Failed to update ${result.id}: ${result.error}`);
    }
  }
  ```

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

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

  const response = await client.media.updateTags({
    updates: [
      { id: 'media_abc123', tag: 'featured' },
      { id: 'media_def456', tag: 'archive' },
      { id: 'media_ghi789', tag: 'featured/videos' }
    ]
  });

  if (response.ok) {
    for (const result of response.data.results) {
      if (result.success) {
        console.log(`Updated ${result.id} to: ${result.media?.tag}`);
      }
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response (All Succeeded) theme={null}
  {
    "ok": true,
    "code": 200,
    "data": {
      "results": [
        {
          "id": "media_abc123",
          "success": true,
          "media": {
            "id": "media_abc123",
            "org_id": "org_xyz789",
            "name": "video.mp4",
            "tag": "featured",
            "type": "video",
            "url": "https://api.ugc.inc/media/file/media_abc123",
            "created_at": "2024-01-15T10:30:00.000Z",
            "media_type": "user_media"
          }
        },
        {
          "id": "media_def456",
          "success": true,
          "media": {
            "id": "media_def456",
            "org_id": "org_xyz789",
            "name": "image.jpg",
            "tag": "archive",
            "type": "image",
            "url": "https://api.ugc.inc/media/file/media_def456",
            "created_at": "2024-01-14T09:00:00.000Z",
            "media_type": "user_media"
          }
        }
      ]
    },
    "message": "Successfully updated 2 media item(s)"
  }
  ```

  ```json Partial Success Response theme={null}
  {
    "ok": true,
    "code": 207,
    "data": {
      "results": [
        {
          "id": "media_abc123",
          "success": true,
          "media": {
            "id": "media_abc123",
            "tag": "featured",
            "..."
          }
        },
        {
          "id": "media_invalid",
          "success": false,
          "error": "Media not found"
        }
      ]
    },
    "message": "Partially updated: 1/2 succeeded"
  }
  ```

  ```json Error Response (All Failed) theme={null}
  {
    "ok": false,
    "code": 400,
    "data": {
      "results": [
        {
          "id": "media_invalid1",
          "success": false,
          "error": "Media not found"
        },
        {
          "id": "media_invalid2",
          "success": false,
          "error": "Media not found"
        }
      ]
    },
    "message": "All updates failed"
  }
  ```
</ResponseExample>
