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

> Fazer upload de arquivos para o Devin usar durante as sessões. Suporta vários tipos de arquivos, incluindo código, dados e documentação.

# Enviar um anexo

Este endpoint faz upload de arquivos para nossos servidores e retorna uma URL que você pode usar como referência em sessões do Devin. O arquivo não é enviado automaticamente para nenhuma sessão — você precisa incluir a URL nos seus prompts.

<div id="how-to-use-uploaded-files">
  ## Como usar arquivos carregados
</div>

<Warning>
  Devin só reconhece anexos quando eles estão escritos exatamente no formato `ATTACHMENT:"{file_url}"` (`ATTACHMENT` no singular, em letras maiúsculas). A linha com `ATTACHMENT:` deve estar sozinha no prompt, e a URL deve estar entre aspas duplas.

  Simplesmente incluir a URL sem esse formato não vai funcionar. Variações como `ATTACHMENTS:` (no plural) também não são reconhecidas.
</Warning>

Para fazer referência a um arquivo carregado em uma sessão do Devin:

1. **Envie o arquivo** usando este endpoint para obter uma URL
2. **Inclua a URL no seu prompt** ao criar uma sessão ou enviar uma mensagem
3. **Formate a URL corretamente** colocando `ATTACHMENT:"{file_url}"` em uma linha própria no seu prompt

<div id="complete-example">
  ## Exemplo completo
</div>

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

DEVIN_API_KEY = os.getenv("DEVIN_API_KEY")

# Passo 1: Fazer upload do arquivo
with open("data.csv", "rb") as f:
    response = requests.post(
        "https://api.devin.ai/v1/attachments",
        headers={"Authorization": f"Bearer {DEVIN_API_KEY}"},
        files={"file": f}
    )
file_url = response.text

# Passo 2: Criar uma sessão que referencia o arquivo carregado
session_response = requests.post(
    "https://api.devin.ai/v1/sessions",
    headers={"Authorization": f"Bearer {DEVIN_API_KEY}"},
    json={
        "prompt": f"""Analise os dados no arquivo CSV anexado e crie um relatório resumido.
Foque em identificar tendências e insights principais.

ATTACHMENT:"{file_url}"
"""
    }
)

print(session_response.json())
```

**Importante:** O prefixo `ATTACHMENT:` deve estar em uma linha separada no prompt, com a URL entre aspas duplas, exatamente como mostrado acima: `ATTACHMENT:"{url}"`. Para anexar vários arquivos, adicione uma linha `ATTACHMENT:"{file_url}"` para cada arquivo.


## OpenAPI

````yaml pt-BR/v1-openapi.yaml POST /v1/attachments
openapi: 3.1.0
info:
  description: API do Devin v1 com chaves de API pessoais e de serviço
  title: Devin API v1
  version: 1.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v1/attachments:
    post:
      summary: Enviar um anexo
      description: >-
        Envie um arquivo como anexo que poderá ser usado em sessões do Devin.
        Retorna a URL do anexo enviado como string.
      operationId: upload_attachment_customer_endpoint_v1_attachments_post
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_attachment_customer_endpoint_v1_attachments_post
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                title: >-
                  Response Upload Attachment Customer Endpoint V1 Attachments
                  Post
                type: string
          description: Resposta bem-sucedida
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Erro de validação
components:
  schemas:
    Body_upload_attachment_customer_endpoint_v1_attachments_post:
      properties:
        file:
          format: binary
          title: File
          type: string
      required:
        - file
      title: Body_upload_attachment_customer_endpoint_v1_attachments_post
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    bearerAuth:
      description: Chave de API pessoal (apk_user_\*) ou chave de API de serviço (apk_\*)
      scheme: bearer
      type: http

````