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

# Add YouTube

> Add a YouTube video transcript to an agent's knowledge base.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.thinnest.ai/knowledge/add-youtube \
    -H "Authorization: Bearer $THINNESTAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "agent_id": "ag_c47e7c97_b2f2",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }'
  ```

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

  url = "https://api.thinnest.ai/knowledge/add-youtube"
  headers = {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
      "Content-Type": "application/json",
  }

  payload = {
    "agent_id": "ag_c47e7c97_b2f2",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.thinnest.ai/knowledge/add-youtube", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
    "agent_id": "ag_c47e7c97_b2f2",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }),
  });

  const data = await response.json();
  console.log(data);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "fmt"
      "io"
      "net/http"
  )

  func main() {
      payload := []byte(`{
    "agent_id": "ag_c47e7c97_b2f2",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }`)
      req, _ := http.NewRequest("POST", "https://api.thinnest.ai/knowledge/add-youtube", bytes.NewBuffer(payload))
      req.Header.Set("Authorization", "Bearer YOUR_THINNESTAI_API_KEY")
      req.Header.Set("Content-Type", "application/json")

      resp, err := http.DefaultClient.Do(req)
      if err != nil { panic(err) }
      defer resp.Body.Close()
      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

***

## Request Body

<ParamField body="agent_id" type="string" required>
  The agent's public ID (ag\_\*)
</ParamField>

<ParamField body="url" type="string" required>
  YouTube video URL
</ParamField>

Supported URL formats:

* `https://www.youtube.com/watch?v=VIDEO_ID`
* `https://youtu.be/VIDEO_ID`

***

## Response `201`

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 4,
    "name": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "type": "youtube",
    "status": "processing",
    "created_at": "2026-03-07T14:00:00Z"
  }
  ```
</ResponseExample>

The transcript is extracted and indexed asynchronously. Check status via [List Sources](/api-reference/knowledge/list).

> **Note:** The video must have captions/subtitles available (auto-generated or manual).

***

## Errors

| Code  | Description                                    |
| ----- | ---------------------------------------------- |
| `401` | Missing or invalid authentication              |
| `404` | Agent not found                                |
| `422` | Invalid YouTube URL or no transcript available |


## OpenAPI

````yaml POST /knowledge/add-youtube
openapi: 3.1.0
info:
  title: ThinnestAI API
  description: REST API for ThinnestAI — build, deploy, and manage AI agents.
  version: 1.0.0
servers: []
security: []
tags:
  - name: Agents
    description: Create, configure, and manage AI agents
  - name: Chat
    description: Send messages and get AI responses from agents
  - name: Knowledge
    description: Upload files, URLs, and text to agent knowledge bases
  - name: Sessions
    description: View and manage chat sessions and message history
  - name: Voice
    description: Start and manage voice call sessions
  - name: Recordings
    description: Manage voice call recordings
  - name: Campaigns
    description: Create and run automated outreach campaigns
  - name: Webhooks
    description: Register webhook endpoints for real-time event notifications
  - name: Evaluations
    description: Run and track agent evaluation benchmarks
  - name: Analytics
    description: Query agent performance metrics and usage data
  - name: Agent Tools
    description: View and manage tools attached to agents
  - name: BYOK
    description: >-
      Bring Your Own Key — manage credentials for LLM/STT/TTS providers,
      telephony BYOK (Vobiz/Twilio/Plivo/Exotel/Telnyx), and tool-specific BYOK
      (Razorpay UPI Payment, Surepass Aadhaar eKYC)
paths:
  /knowledge/add-youtube:
    post:
      tags:
        - Knowledge
      summary: Add Youtube Endpoint
      description: >-
        Add YouTube video transcript to knowledge base.


        SECURITY: Requires authentication - users can only add YouTube videos to
        their own knowledge base.
      operationId: add_youtube_endpoint_knowledge_add_youtube_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/YouTubeRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    YouTubeRequest:
      properties:
        user_id:
          type: string
          title: User Id
        url:
          type: string
          title: Url
      type: object
      required:
        - user_id
        - url
      title: YouTubeRequest
      description: Request to add a YouTube video to knowledge base.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````