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

> セッション中にDevinが使用するファイルをアップロードします。コード、データ、ドキュメントファイルなど、さまざまなファイル形式をサポートします。

# 添付ファイルをアップロード

このエンドポイントはファイルを当社のサーバーにアップロードし、Devinのセッション内で参照できるURLを返します。ファイルはどのセッションにも自動的には送信されないため、プロンプト内でそのURLを指定する必要があります。

<div id="how-to-use-uploaded-files">
  ## アップロードしたファイルの使い方
</div>

<Warning>
  Devin が添付ファイルを認識するのは、`ATTACHMENT:"{file_url}"` という形式で正確に記述されている場合だけです（単数形の `ATTACHMENT`、すべて大文字）。`ATTACHMENT:` の行はプロンプト内で 1 行だけにし、URL はダブルクォーテーションで囲む必要があります。

  この形式を使わずに、URL をそのまま含めるだけでは認識されません。`ATTACHMENTS:`（複数形）のようなバリエーションも認識されません。
</Warning>

Devin セッション内でアップロードしたファイルを参照するには、次のようにします。

1. このエンドポイントを使って**ファイルをアップロードし**、URL を取得する
2. セッションの作成時やメッセージ送信時に、**プロンプト内にその URL を含める**
3. プロンプト内で `ATTACHMENT:"{file_url}"` を単独の行として記述し、**URL を正しい形式で記述する**

<div id="complete-example">
  ## 完全なサンプル
</div>

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

DEVIN_API_KEY = os.getenv("DEVIN_API_KEY")

# ステップ1: ファイルをアップロードする
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

# ステップ2: アップロードしたファイルを参照するセッションを作成する
session_response = requests.post(
    "https://api.devin.ai/v1/sessions",
    headers={"Authorization": f"Bearer {DEVIN_API_KEY}"},
    json={
        "prompt": f"""添付されたCSVファイルのデータを分析し、サマリーレポートを作成してください。
トレンドと主要なインサイトの特定に重点を置いてください。

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

print(session_response.json())
```

**重要:** `ATTACHMENT:` プレフィックスは、プロンプト内で単独で1行に記述し、URL は上記のとおり二重引用符で囲んでください：`ATTACHMENT:"{url}"`。複数ファイルを添付するには、ファイルごとに `ATTACHMENT:"{file_url}"` の行を1つずつ追加します。


## OpenAPI

````yaml ja/v1-openapi.yaml POST /v1/attachments
openapi: 3.1.0
info:
  description: Personal APIキーおよびService APIキーに対応するDevin v1 API
  title: Devin API v1
  version: 1.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v1/attachments:
    post:
      summary: 添付ファイルをアップロード
      description: Devin のセッションで使用できる添付ファイルをアップロードします。アップロードされた添付ファイルの URL を文字列として返します。
      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: 正常なレスポンス
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: バリデーションエラー
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: 個人用APIキー (apk_user_\*) またはサービス用APIキー (apk_\*)
      scheme: bearer
      type: http

````