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

# Criar anexo a partir de uma mídia

> Cria um attachment que aponta para o arquivo de uma mídia (`type=MEDIA`) da central, sem subir o arquivo de novo. Devolve o mesmo formato de `POST /resource/upload-attachment`; use o `_id` no envio de mensagem ou na resposta rápida. Mídia inexistente ou de outra empresa responde 404 com `code: KNOWLEDGE_MEDIA_NOT_FOUND`.



## OpenAPI

````yaml /en/openapi.json post /v1/knowledge/{id}/attachment
openapi: 3.0.0
info:
  title: Nuvia API - Company
  description: API documentation for companies
  version: '1.0'
  contact: {}
servers:
  - url: https://api.nuvia.ai
security: []
tags:
  - name: messages
    x-group: Messages
  - name: contacts
    x-group: Contacts
  - name: campaigns
    x-group: Campaigns
  - name: tables
    x-group: Tables and lists
  - name: agents
    x-group: Agents
  - name: conversations
    x-group: Conversations
  - name: inboxes
    x-group: Inboxes
  - name: knowledge
    x-group: Knowledge base
  - name: Webhooks
    x-group: Webhooks
  - name: campaign-enrollments
    x-group: Campaign enrollments
  - name: custom-fields
    x-group: Custom fields
  - name: resources
    x-group: Files and attachments
  - name: hubspot
    x-group: HubSpot
  - name: users
    x-group: Users
paths:
  /v1/knowledge/{id}/attachment:
    post:
      tags:
        - knowledge
      summary: Criar anexo a partir de uma mídia
      description: >-
        Cria um attachment que aponta para o arquivo de uma mídia (`type=MEDIA`)
        da central, sem subir o arquivo de novo. Devolve o mesmo formato de
        `POST /resource/upload-attachment`; use o `_id` no envio de mensagem ou
        na resposta rápida. Mídia inexistente ou de outra empresa responde 404
        com `code: KNOWLEDGE_MEDIA_NOT_FOUND`.
      operationId: KnowledgeController_createAttachment
      parameters:
        - name: x-company-id
          in: header
          description: >-
            Target company identifier. Required only for global API keys
            (type=global). Ignored for company API keys and human users.
          required: false
          schema:
            type: string
        - name: id
          required: true
          in: path
          description: ID da mídia na central
          schema:
            type: string
      responses:
        '201':
          description: Attachment criado a partir da mídia
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachmentResponseDto'
        '400':
          description: Invalid data
        '401':
          description: Invalid or expired token
        '403':
          description: You do not have permission to access this resource
      security:
        - JWT-auth: []
components:
  schemas:
    AttachmentResponseDto:
      type: object
      properties:
        _id:
          description: Attachment ID.
          type: string
        s3_key:
          description: Storage key of the object, used to derive the signed URL.
          type: string
        extension:
          type: string
          description: File extension (jpg, png, pdf, and so on).
        external_url:
          type: string
          description: >-
            Public file URL. Deprecated: prefer deriving a signed URL from
            `s3_key`.
        file_type:
          type: string
          enum:
            - IMAGE
            - AUDIO
            - VIDEO
            - DOCUMENT
            - STICKER
          description: 'File type: IMAGE, AUDIO, VIDEO, DOCUMENT, or STICKER.'
        meta:
          description: >-
            Additional file metadata: `mimeType`, `size`, `fileName`, and
            others.
          type: object
          properties:
            mimeType:
              description: File MIME type
              type: string
            size:
              description: File size in bytes
              type: number
            fileName:
              description: Original file name
              type: string
            resourceUrl:
              description: Resource URL
              type: string
        company:
          description: Company that owns the attachment.
        createdAt:
          description: When the attachment was created.
        updatedAt:
          description: When the attachment was last updated.
      required:
        - extension
        - external_url
        - file_type
        - company
  securitySchemes:
    JWT-auth:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: JWT authentication token

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.