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

> Upload files for Devin to work with during sessions. Supports various file types including code, data, and documentation files.

# Upload an attachment

This endpoint uploads files to our servers and returns a URL that you can reference in Devin sessions. The file isn't automatically sent to any session - you need to include the URL in your prompts.

## How to Use Uploaded Files

<Warning>
  Devin only recognizes attachments when they are written in the exact format `ATTACHMENT:"{file_url}"` (singular `ATTACHMENT`, all caps). The `ATTACHMENT:` line must be on its own line in the prompt, and the URL must be enclosed in double quotes.

  Simply including the raw URL without this format will not work. Variants like `ATTACHMENTS:` (plural) are also not recognized.
</Warning>

To reference an uploaded file in a Devin session:

1. **Upload the file** using this endpoint to get a URL
2. **Include the URL in your prompt** when creating a session or sending a message
3. **Format the URL correctly** by putting `ATTACHMENT:"{file_url}"` on its own line in your prompt

## Complete Example

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

DEVIN_API_KEY = os.getenv("DEVIN_API_KEY")

# Step 1: Upload the file
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

# Step 2: Create a session that references the uploaded file
session_response = requests.post(
    "https://api.devin.ai/v1/sessions",
    headers={"Authorization": f"Bearer {DEVIN_API_KEY}"},
    json={
        "prompt": f"""Please analyze the data in the attached CSV file and create a summary report.
Focus on identifying trends and key insights.

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

print(session_response.json())
```

**Important:** The `ATTACHMENT:` prefix must be on its own line in the prompt with the URL enclosed in double quotes, exactly as shown above: `ATTACHMENT:"{url}"`. To attach multiple files, add one `ATTACHMENT:"{file_url}"` line per file.


## OpenAPI

````yaml /v1-openapi.yaml POST /v1/attachments
openapi: 3.1.0
info:
  description: Devin v1 API with Personal and Service API Keys
  title: Devin API v1
  version: 1.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v1/attachments:
    post:
      summary: Upload an attachment
      description: >-
        Upload a file attachment that can be used in Devin sessions. Returns the
        URL of the uploaded attachment as a 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: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
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: Personal API Key (apk_user_*) or Service API Key (apk_*)
      scheme: bearer
      type: http

````