POST
/
v1
/
attachments
Upload files for Devin
curl --request POST \
  --url https://api.devin.ai/v1/attachments \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form file=@example-file
"https://storage.devin.ai/attachments/xxx/file.py"
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

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 prefixing it with ATTACHMENT: on its own line

Complete Example

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}"

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data

Response

200
text/plain

File successfully uploaded

A string URL where the uploaded file can be accessed