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

# Ladda ner dokument

> Ladda ner ett dokument med labbrapport via fil-ID

Ladda ner ett labbrapportdokument med dess fil-ID. Returnerar filens råa bytes med rätt `Content-Type`-header. Dokument-ID:n hämtas från arrayen `documents` i svaret från [Hämta labbresultat](https://docs.anivahealth.com/sv/api/appointments/get-results.md).

Kräver scopet `results_view`.

> [!NOTE]
>
> Åtkomst valideras mot profilen som äger dokumentet. Ett dokument som du laddat upp med [Ladda upp dokument](https://docs.anivahealth.com/sv/api/documents/upload-document.md) valideras mot den profilgrupp som det laddades upp under.

## Förfrågan

### Sökvägsparametrar

**id** `string` *required*

Fil-ID (UUID) från arrayen `documents` i svaret med resultat för bokningen.

## Svar

Vid lyckat anrop returnerar API:et `200 OK` med filens bytes och fyra headers. Varje header innehåller ett fält från arrayen `documents`:

| Header | Fält | Exempel |
| - | - | - |
| `Content-Type` | `content_type` | `application/pdf` |
| `Content-Disposition` | `file_name` | `attachment; filename="20260405 - Quade Befund - 7642001234.pdf"` |
| `ETag` | `etag` (inom citattecken) | `"56104b36f860cfd5b41efc716fdf7b6f"` |
| `Original-File-Name` | `original_file_name` | `7642001234_B0012_FA_E.pdf` |

`Original-File-Name` är procentkodad UTF-8, eftersom en header inte kan innehålla alla tecken som ett uppladdat filnamn kan ha. Avkoda den med `decodeURIComponent` eller motsvarande.

`ETag` och `If-None-Match` är standardheaders för HTTP-cachning (RFC 9110). Skicka den `etag` du har i `If-None-Match` för att hoppa över en oförändrad fil. API:et svarar då `304 Not Modified` utan body.

## Felsvar

| Status | Beskrivning |
| - | - |
| `304` | Oförändrad – etag i `If-None-Match` matchar fortfarande filen. Ingen body. |
| `400` | Ogiltigt ID-format – det angivna värdet är inte ett giltigt UUID. |
| `403` | Åtkomst nekad – din API-nyckel har inte åtkomst till den här åtgärden eller så ligger dokumentet utanför din åtkomstkontext. |
| `404` | Dokumentet hittades inte. |
| `500` | Internt serverfel. |

```bash cURL theme={null}
curl --request GET \
  --url https://anivahealth.com/api/v1/documents/f8a1b2c3-d4e5-4f6a-7b8c-9d0e1f2a3b4c \
  --header 'x-api-key: YOUR_API_KEY' \
  --output lab-report.pdf
```

```text 200 theme={null}
(Binary file content — save the response to a file)
```

```json 404 theme={null}
{
  "error": "Document not found"
}
```


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