# Download (https://docs.capy.ai/api-reference/attachments/download)

`GET https://api.capy.ai/api/v1/threads/{threadId}/attachments/{fileId}/download`

## Authorization

Send an API key as a bearer token: `Authorization: Bearer $CAPY_API_KEY`. See https://docs.capy.ai/api-reference/authentication.md.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `threadId` | path | string | yes |  |
| `fileId` | path | string | yes |  |

## Responses

- `200` AttachmentDownload: `AttachmentDownloadEncoded`
- `401` capy/Unauthorized: `capy_UnauthorizedEncoded`
- `403` capy/Forbidden: `capy_ForbiddenEncoded \| capy_ForbiddenEncoded`
- `404` capy/ThreadNotFound | capy/FileNotFound: `capy_ThreadNotFoundEncoded \| capy_FileNotFoundEncoded`
- `429` capy/RateLimited: `capy_RateLimitedEncoded`

## Example

```bash
curl -X GET "https://api.capy.ai/api/v1/threads/{threadId}/attachments/{fileId}/download" \
  -H "Authorization: Bearer $CAPY_API_KEY"
```

## Referenced schemas

```json
{
  "AttachmentDownloadEncoded": {
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "description": "A presigned GET for the file's bytes. Send it without an Authorization header; the signature is the credential."
      },
      "expiresAt": {
        "type": "string"
      }
    },
    "required": [
      "url",
      "expiresAt"
    ],
    "additionalProperties": false
  },
  "capy_UnauthorizedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Unauthorized"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ForbiddenEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Forbidden"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ThreadNotFoundEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/ThreadNotFound"
        ]
      },
      "threadId": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "threadId"
    ],
    "additionalProperties": false
  },
  "capy_FileNotFoundEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/FileNotFound"
        ]
      },
      "fileId": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "fileId"
    ],
    "additionalProperties": false
  },
  "capy_RateLimitedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/RateLimited"
        ]
      },
      "retryAfterSeconds": {
        "type": "integer"
      }
    },
    "required": [
      "_tag",
      "retryAfterSeconds"
    ],
    "additionalProperties": false
  }
}
```

Full document: https://docs.capy.ai/openapi.json