# Merge agent-owned annotations (tags, notes) onto one library video (/docs/api-reference/v1/library/video-metadata/post)

`POST https://api.viralquery.com/v1/library/video-metadata`

Merge agent-owned annotations (tags, notes) onto one library video

Operation ID: `updateVideoAgentMetadata`

OpenAPI document: https://viralquery.com/openapi.json

## Authentication

Bearer token: `Authorization: Bearer $VIRALQUERY_API_KEY`

## Request

### Request body — application/json (required)

```json
{
  "type": "object",
  "properties": {
    "videoId": {
      "type": "string",
      "minLength": 1
    },
    "agentMetadata": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 500
          },
          {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "maxItems": 20
          },
          {
            "nullable": true
          },
          {
            "nullable": true
          }
        ]
      },
      "description": "Shallow merge of at most 50 keys. Key names are 1-100 characters; strings are at most 500 characters; arrays contain at most 20 such strings; null deletes a key."
    }
  },
  "required": [
    "videoId",
    "agentMetadata"
  ],
  "additionalProperties": false
}
```

## Responses

### `200` — OK

**application/json**

```json
{
  "type": "object",
  "properties": {
    "outcome": {
      "type": "string",
      "enum": [
        "updated",
        "not_found",
        "workspace_required",
        "limit_reached"
      ]
    },
    "agentMetadata": {
      "type": "object",
      "nullable": true,
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 500
          },
          {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "maxItems": 20
          }
        ]
      },
      "description": "Agent-owned annotations: at most 50 keys, key names 1-100 characters, and each value is a string up to 500 characters or up to 20 such strings."
    },
    "droppedKeys": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Present for limit_reached; none of these requested keys were saved."
    }
  },
  "required": [
    "outcome",
    "agentMetadata"
  ]
}
```

### `400` — Invalid request (input failed validation)

**application/json**

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "invalid_request"
      ],
      "description": "Stable machine-readable error code."
    },
    "message": {
      "type": "string",
      "description": "Human-readable summary."
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "path",
          "message"
        ]
      },
      "description": "First-class Zod validation issues (path + message), not a stringified blob."
    }
  },
  "required": [
    "error",
    "message",
    "issues"
  ]
}
```

### `401` — Unauthorized (missing or invalid API key)

**application/json**

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "enum": [
            "unauthorized"
          ]
        },
        "message": {
          "type": "string"
        },
        "subscribeUrl": {
          "type": "string",
          "description": "Human-clickable ViralQuery pricing and subscription URL."
        }
      },
      "required": [
        "error",
        "message",
        "subscribeUrl"
      ]
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "enum": [
            "auth_required"
          ]
        },
        "message": {
          "type": "string",
          "description": "The session-scoped key is expired or no longer resolves to its account."
        }
      },
      "required": [
        "error",
        "message"
      ]
    }
  ]
}
```

### `402` — Payment Required (active subscription required)

**application/json**

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "subscription_required"
      ]
    },
    "message": {
      "type": "string"
    },
    "subscribeUrl": {
      "type": "string",
      "description": "Human-clickable ViralQuery pricing and subscription URL."
    }
  },
  "required": [
    "error",
    "message",
    "subscribeUrl"
  ]
}
```

### `403` — Forbidden (scope or plan is insufficient)

**application/json**

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "forbidden"
      ]
    },
    "message": {
      "type": "string"
    },
    "requiredScope": {
      "type": "string",
      "description": "Scope or explicit session capability required by this operation."
    },
    "grantedScopes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Scopes present on the calling key."
    }
  },
  "required": [
    "error",
    "message",
    "requiredScope",
    "grantedScopes"
  ]
}
```

### `409` — Conflict or operation error

**application/json**

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "operation_error"
      ]
    },
    "message": {
      "type": "string",
      "description": "The operation failed while handling the request."
    }
  },
  "required": [
    "error",
    "message"
  ]
}
```

### `429` — Too Many Requests (rate limited)

**application/json**

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "rate_limited"
      ]
    },
    "message": {
      "type": "string"
    },
    "retryAfter": {
      "type": "number",
      "description": "Seconds to wait before retrying (mirrors the Retry-After header)."
    }
  },
  "required": [
    "error",
    "message",
    "retryAfter"
  ]
}
```