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

# Get Document

> Get a presigned download URL for a specific application document

Returns a short-lived presigned URL for downloading a specific document from an application.

```
GET /api/external/applications/{id}/documents/{docId}
```

## Authentication

Requires an API key with `applications:read` scope. The application must belong to the organization associated with the API key.

```bash theme={null}
Authorization: Bearer klara_{client_id}.{secret}
```

## Path parameters

<ParamField path="id" type="string" required>
  UUID of the application.
</ParamField>

<ParamField path="docId" type="string" required>
  UUID of the document.
</ParamField>

## Response

Returns `200 OK` with a presigned download URL.

<ResponseField name="url" type="string">
  Presigned S3 URL valid for 1 hour. Use this to download the file directly.
</ResponseField>

<ResponseField name="file_name" type="string">
  Original file name.
</ResponseField>

<ResponseField name="file_type" type="string">
  MIME type of the file (e.g., `application/pdf`, `image/jpeg`).
</ResponseField>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  # Get the download URL
  curl "https://app.klara-ai.com/api/external/applications/550e8400.../documents/770e8400..." \
    -H "Authorization: Bearer klara_abc123def456.your-secret-here"

  # Then download the file
  curl -o document.pdf "https://s3.amazonaws.com/..."
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://app.klara-ai.com/api/external/applications/550e8400.../documents/770e8400...',
    {
      headers: {
        'Authorization': 'Bearer klara_abc123def456.your-secret-here'
      }
    }
  );

  const { url, file_name, file_type } = await response.json();

  // Download the file using the presigned URL
  const fileResponse = await fetch(url);
  const fileBuffer = await fileResponse.arrayBuffer();
  ```

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

  response = requests.get(
      'https://app.klara-ai.com/api/external/applications/550e8400.../documents/770e8400...',
      headers={'Authorization': 'Bearer klara_abc123def456.your-secret-here'}
  )

  data = response.json()

  # Download the file using the presigned URL
  file_response = requests.get(data['url'])
  with open(data['file_name'], 'wb') as f:
      f.write(file_response.content)
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "url": "https://s3.amazonaws.com/bucket/org-id/applications/app-id/1706123456-passport-scan.pdf?X-Amz-...",
  "file_name": "passport-scan.pdf",
  "file_type": "application/pdf"
}
```

<Warning>
  Download URLs expire after **1 hour**. If the URL has expired, request a new one by calling this endpoint again.
</Warning>

## Errors

| Status | Error                                                | Cause                                                             |
| ------ | ---------------------------------------------------- | ----------------------------------------------------------------- |
| `401`  | `Invalid API key`                                    | API key is invalid, expired, or inactive                          |
| `401`  | `API key missing required scopes: applications:read` | Key lacks the required scope                                      |
| `404`  | `Application not found`                              | Application does not exist or belongs to a different organization |
| `404`  | `Document not found`                                 | Document does not exist or does not belong to this application    |
| `500`  | `Internal server error`                              | An unexpected error occurred                                      |
