# Get

Fetch a single attachment's metadata and bytes by ID. Bytes come back base64-encoded inside the JSON response — decode them to write to disk.





Returns the attachment record (metadata + raw bytes) for the given ID. Bytes are base64-encoded inside the JSON `data` field so the whole response is a single JSON document — no separate streaming endpoint.

```http
GET /api/public/v1/attachments/{attachment_id}
```

## Path parameters [#path-parameters]

<TypeTable
  type="{
  attachment_id: {
    type: &#x22;string&#x22;,
    required: true,
    description: &#x22;The ID returned from POST /attachments or surfaced on an assistant message's `attachment_ids` array.&#x22;
  }
}"
/>

## Example [#example]

<Tabs items="[&#x22;bash&#x22;, &#x22;TypeScript&#x22;, &#x22;Ruby&#x22;, &#x22;Python&#x22;, &#x22;Go&#x22;]">
  <Tab value="bash">
    ```bash
    # Fetch the JSON envelope and write the decoded bytes to disk
    curl -s https://api.nairi.ai/api/public/v1/attachments/$ATTACHMENT_ID \
      -H "Authorization: Bearer $NAIRI_API_KEY" \
      | jq -r .data | base64 -d > out.bin
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    const res = await fetch(
      `https://api.nairi.ai/api/public/v1/attachments/${attachmentId}`,
      { headers: { Authorization: `Bearer ${process.env.NAIRI_API_KEY}` } },
    );
    const att = (await res.json()) as {
      id: string;
      filename: string;
      data: string; // base64
    };
    const bytes = Buffer.from(att.data, "base64");
    ```
  </Tab>

  <Tab value="Ruby">
    ```ruby
    require "net/http"
    require "json"
    require "uri"
    require "base64"

    uri = URI("https://api.nairi.ai/api/public/v1/attachments/#{attachment_id}")
    req = Net::HTTP::Get.new(uri)
    req["Authorization"] = "Bearer #{ENV['NAIRI_API_KEY']}"

    res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
    att = JSON.parse(res.body)
    bytes = Base64.decode64(att["data"])
    ```
  </Tab>

  <Tab value="Python">
    ```python
    import base64
    import os
    import requests

    res = requests.get(
        f"https://api.nairi.ai/api/public/v1/attachments/{attachment_id}",
        headers={"Authorization": f"Bearer {os.environ['NAIRI_API_KEY']}"},
    )
    att = res.json()
    data = base64.b64decode(att["data"])
    ```
  </Tab>

  <Tab value="Go">
    ```go
    package main

    import (
    	"encoding/base64"
    	"encoding/json"
    	"fmt"
    	"net/http"
    	"os"
    )

    func main() {
    	req, _ := http.NewRequest("GET",
    		"https://api.nairi.ai/api/public/v1/attachments/"+os.Args[1], nil)
    	req.Header.Set("Authorization", "Bearer "+os.Getenv("NAIRI_API_KEY"))
    	res, _ := http.DefaultClient.Do(req)
    	defer res.Body.Close()
    	var att struct {
    		ID, Filename, Data string
    	}
    	json.NewDecoder(res.Body).Decode(&att)
    	bytes, _ := base64.StdEncoding.DecodeString(att.Data)
    	fmt.Printf("got %d bytes (%s)\n", len(bytes), att.Filename)
    }
    ```
  </Tab>
</Tabs>

## Response [#response]

```json
{
  "id": "att_01KRK1V46BXS73CSNK2VR35NPJ",
  "organization_id": "org_01KQ...",
  "type": "temporary",
  "data": "iVBORw0KGgoAAAANSUhEUgAAA...",
  "filename": "screenshot.png",
  "created_at": "2026-05-27T08:31:14Z",
  "updated_at": "2026-05-27T08:31:14Z"
}
```

<Callout type="info">
  Attachments are scoped to the org that uploaded them. Trying to fetch an ID belonging to a different org returns `404 attachment not found`.
</Callout>
