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

> ## Agent Instructions
> Use Stable documentation by default. Honor an explicit Beta request or a URL under /docs/beta/. If the requested version conflicts with the installed CLI package or API origin, clarify the target before writing integration code.
> Pages under /docs/beta/ document Beta; other product pages document Stable. Keep the CLI package, commands, API origin, and credentials within the selected version. State the documentation version in your answer.
> For MCP search, always pass version: Stable or version: Beta. Unfiltered search mixes both versions. For filesystem reads, keep Beta queries under /beta/ and exclude /beta/ from Stable queries; discover paths before reading them.
> The public docs base is https://photon.codes/docs. Convert MCP page paths to public URLs under that base, preserving /beta/ when present. Read https://photon.codes/docs/skill.md for version selection and https://photon.codes/docs/llms.txt for the version indexes.

# Upload attachment

> Upload attachment: uploadAttachment in the TypeScript, Python and Rust clients.

`POST /v1/projects/{id}/attachments`

Uploads a file and returns its Attachment once ready to download.

<Tabs>
  <Tab title="TypeScript">
    ```typescript TypeScript theme={null}
    photon.projects.uploadAttachment(input: UploadAttachmentInput, options?: RequestOptions): Promise<UploadAttachmentOutput>
    ```
  </Tab>

  <Tab title="Python">
    ```python Python theme={null}
    photon.projects.upload_attachment(input: UploadAttachmentInput) -> models.Attachment
    ```
  </Tab>

  <Tab title="Rust">
    ```rust Rust theme={null}
    client.upload_attachment(id: String, content_length: String, content_type: String, idempotency_key: String, body: &bytes::Bytes).await -> Result<ResponseValue<UploadAttachmentResponse>, Error<UploadAttachmentError>>
    ```
  </Tab>
</Tabs>

<RequestExample>
  ```typescript TypeScript theme={null}
  import { Photon } from "@photon-ai/api";

  const photon = new Photon({
    headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
  });
  const result = await photon.projects.uploadAttachment({
    path: {
      id: "id",
    },
    headers: {
      "content-length": "18",
      "content-type": "text/plain",
      "idempotency-key": "idempotency-key",
    },
    body: new Blob(["Hello from Photon."], { type: "text/plain" }),
  });
  ```

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

  from photon_api import Photon
  from photon_api.rpc_generated import UploadAttachmentInput

  photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
  result = photon.projects.upload_attachment(
      UploadAttachmentInput.model_validate({
          "path": {
              "id": "id",
          },
          "headers": {
              "content-length": "18",
              "content-type": "text/plain",
              "idempotency-key": "idempotency-key",
          },
          "body": b"Hello from Photon.",
      })
  )
  ```

  ```rust Rust theme={null}
  use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};

  let token = std::env::var("PHOTON_API_TOKEN")?;
  let client = PhotonClientBuilder::new()
      .credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
      .build()?;
  let result = client
      .upload_attachment(
          "id".to_owned(),
          "18".to_owned(),
          "text/plain".to_owned(),
          "idempotency-key".to_owned(),
          &"Hello from Photon.".into(),
      )
      .await
      .map_err(|error| format!("{error:?}"))?
      .into_inner();
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "contentType": "string",
    "createdAt": "2026-01-01T00:00:00Z",
    "filename": "string",
    "id": "string",
    "metadata": {},
    "projectId": "string",
    "sizeBytes": 1,
    "updatedAt": "2026-01-01T00:00:00Z"
  }
  ```

  ```json 201 theme={null}
  {
    "contentType": "string",
    "createdAt": "2026-01-01T00:00:00Z",
    "filename": "string",
    "id": "string",
    "metadata": {},
    "projectId": "string",
    "sizeBytes": 1,
    "updatedAt": "2026-01-01T00:00:00Z"
  }
  ```
</ResponseExample>

## Parameters

<ParamField path="id" type={"string"} required />

<ParamField header="content-length" type={"string"} required />

<ParamField header="content-type" type={"string"} required />

<ParamField header="idempotency-key" type={"string"} required>
  Reuse the same key and request for retries.
</ParamField>

## Returns

**`200`** The attachment upload had already been committed. Attachment

<ResponseField name="contentType" type={"string"} required />

<ResponseField name="createdAt" type={"string (date-time)"} required />

<ResponseField name="filename" type={"string"} />

<ResponseField name="id" type={"string"} required />

<ResponseField name="metadata" type={"object"} />

<ResponseField name="projectId" type={"string"} required />

<ResponseField name="sizeBytes" type={"integer"} required />

<ResponseField name="updatedAt" type={"string (date-time)"} required />

**`201`** The attachment was uploaded and committed. Attachment

Headers: `Location`. The raw response carries these headers; see [Raw responses](/docs/beta/api-client/raw-responses).

<ResponseField name="contentType" type={"string"} required />

<ResponseField name="createdAt" type={"string (date-time)"} required />

<ResponseField name="filename" type={"string"} />

<ResponseField name="id" type={"string"} required />

<ResponseField name="metadata" type={"object"} />

<ResponseField name="projectId" type={"string"} required />

<ResponseField name="sizeBytes" type={"integer"} required />

<ResponseField name="updatedAt" type={"string (date-time)"} required />


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