> For the complete documentation index, see [llms.txt](https://apidocs.arionbanki.is/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.arionbanki.is/business-apis/documents-api/documents-api-quick-start.md).

# Documents API Quick Start

All the information you need to fetch data from the Documents API

## API authentication

First things first, follow the instructions in the link to get all the necessary prerequisites to fetch data from the documents API.

{% columns %}
{% column %}

#### Production

Fetching data from the production environment requires:

* **API key**
* **Búnaðarskilríki certificate**
* **Auth Token**
  {% endcolumn %}

{% column %}

#### Sandbox

Fetching data from the sandbox environment requires:

* **API key**
* **Sandbox Token**
  {% endcolumn %}
  {% endcolumns %}

{% columns %}
{% column %}
Here's a guide on how to get them.

{% content-ref url="/pages/0RJ5SYumtOLMmoli2EdC" %}
[Production](/business-apis/authentication/production.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Here's a more thorough guide.

{% content-ref url="/pages/0lWYnBPAgrudG7Q5Sw76" %}
[Sandbox](/business-apis/authentication/sandbox.md)
{% endcontent-ref %}
{% endcolumn %}
{% endcolumns %}

***

## Available methods

Here is what the Documents API offers. Clicking on a method delivers the API Reference for that endpoint.

{% columns %}
{% column %}

### Documents

[Query Documents](/business-apis/documents-api/documents-api-reference.md#get-api-v1-documents)

[Upload Document - XML or PDF](/business-apis/documents-api/documents-api-reference.md#post-api-v1-documents)

[Get Document by Id and owner](/business-apis/documents-api/documents-api-reference.md#get-api-v1-documents-ownerkennitala-documentid)

[Get Document types for sender](/business-apis/documents-api/documents-api-reference.md#get-api-v1-documents-senderkennitala-types)
{% endcolumn %}

{% column %}

### Cross-References

[Query Cross-References](/business-apis/documents-api/documents-api-reference.md#get-api-v1-crossreferences)

[Create Cross-References](/business-apis/documents-api/documents-api-reference.md#post-api-v1-crossreferences)

[Edit Cross-References](/business-apis/documents-api/documents-api-reference.md#put-api-v1-crossreferences)

[Delete Cross-Reference](/business-apis/documents-api/documents-api-reference.md#delete-api-v1-crossreferences-document-id-key-type-key)
{% endcolumn %}
{% endcolumns %}

***

## Calling the Documents API

Take a look at how you might call the **query documents** method using `curl`  or other popular programming languages, note that these examples are to connect to the production environment.

Note that if you're trying this endpoint for the first time, expect the results to be empty, because you haven't uploaded any documents, but with status code <mark style="color:$success;">200 OK.</mark>

What you need is:

* **Búnaðarskilríki Certificate** location and it's **password,** see [here](/business-apis/authentication/production.md#certificate).
* **API key** from the [developer portal](/business-apis/authentication/production.md#get-your-api-key)
* **Auth key** from the [authentication service.](/business-apis/authentication/production.md#authorization)
* A random **UUID** to use as a request id.
* **Sender Kennitala** - who sent the document.
* **Owner Kennitala** - who owns the document.

{% tabs %}
{% tab title="curl" %}
{% code fullWidth="false" %}

```bash
curl --cert <Directory of cert>/cert.pfx:<cert password> --cert-type P12 \
    -H "accept: application/json" \
    -H "X-Request-ID: <uuid for request>" \
    -H "Ocp-Apim-Subscription-Key: <API key>" \
    -H "Authorization: Bearer <auth key from the auth service>" \
    -X GET "https://apigw.arionbanki.is/documents/api/v1/documents?SenderKennitala=<sender kennitala>&OwnerKennitala=<owner kennitala>&DateFrom=2025-01-01&DateTo=2026-01-01&Ordering=DESC&ItemsPerPage=10&Page=1"

```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
import requests
import uuid
import ssl
import tempfile
import os
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption
from cryptography.hazmat.primitives.serialization.pkcs12 import load_pkcs12

CERT_PATH = "<directory of cert>/cert.pfx"
CERT_PASSWORD = "<cert password>"
SUBSCRIPTION_KEY = "<API key from Developer portal>"
BEARER_TOKEN = "<Auth Key from Auth service>"
SENDER_KENNITALA = "<sender kennitala>"
OWNER_KENNITALA = "<owner kennitala>"

# requests doesn't natively support .pfx — convert to PEM first or use ssl context
def load_pfx_as_pem_files(pfx_path: str, password: str):
    with open(pfx_path, "rb") as f:
        pfx_data = f.read()

    p12 = load_pkcs12(pfx_data, password.encode())

    cert_pem = p12.cert.certificate.public_bytes(Encoding.PEM)
    key_pem = p12.key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())

    cert_file = tempfile.NamedTemporaryFile(delete=False, suffix=".pem")
    key_file = tempfile.NamedTemporaryFile(delete=False, suffix=".pem")

    cert_file.write(cert_pem)
    key_file.write(key_pem)
    cert_file.close()
    key_file.close()

    return cert_file.name, key_file.name

cert_pem_path, key_pem_path = load_pfx_as_pem_files(CERT_PATH, CERT_PASSWORD)

response = requests.get(
    url=f"https://apigw.arionbanki.is/documents/api/v1/documents?SenderKennitala={SENDER_KENNITALA}&OwnerKennitala={OWNER_KENNITALA}&DateFrom=2025-01-01&DateTo=2026-01-01&Ordering=DESC&ItemsPerPage=10&Page=1",
    headers={
        "Accept": "application/json",
        "X-Request-ID": str(uuid.uuid4()),
        "Ocp-Apim-Subscription-Key": SUBSCRIPTION_KEY,
        "Authorization": f"Bearer {BEARER_TOKEN}",
    },
    cert=(cert_pem_path, key_pem_path),
)
print(response.json())
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import axios from "axios";
import https from "https";
import fs from "fs";
import { randomUUID } from "crypto";

const agent = new https.Agent({
  pfx: fs.readFileSync("/path/to/cert.pfx"),
  passphrase: "<your-cert-password>",
});

var OWNER_KENNITALA = "<owner kennitala>";
var SENDER_KENNITALA = "<sender kennitala>";

const response = await axios.get(
  `https://apigw.arionbanki.is/documents/api/v1/documents?SenderKennitala=${SENDER_KENNITALA}&OwnerKennitala=${OWNER_KENNITALA}&DateFrom=2025-01-01&DateTo=2026-01-01&Ordering=DESC&ItemsPerPage=10&Page=1`,
  {
    httpsAgent: agent,
    headers: {
      Accept: "application/json",
      "X-Request-ID": randomUUID(),
      "Ocp-Apim-Subscription-Key": "<your-subscription-key>",
      Authorization: "Bearer <your-bearer-token>",
    },
  }
);
console.log(JSON.stringify(response.data, null, 2));


```

{% endtab %}

{% tab title="C#" %}

```csharp
using System.Security.Cryptography.X509Certificates;

var certPath = "<Directory of cert>/cert.pfx";
var certPassword = "<cert password>";
var subscriptionKey = "<API key>";
var bearerToken = "<auth key from the auth service>";
var senderKennitala = "<sender kennitala>";
var ownerKennitala = "<owner kennitala>";

var cert = new X509Certificate2(certPath, certPassword);

var handler = new HttpClientHandler();
handler.ClientCertificates.Add(cert);

using var client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("X-Request-ID", Guid.NewGuid().ToString());
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {bearerToken}");

var url = $"https://apigw.arionbanki.is/documents/api/v1/documents?SenderKennitala={senderKennitala}&OwnerKennitala={ownerKennitala}&DateFrom=2025-01-01&DateTo=2026-01-01&Ordering=DESC&ItemsPerPage=10&Page=1";

var response = await client.GetAsync(url);
var body = await response.Content.ReadAsStringAsync();

Console.WriteLine($"Status: {response.StatusCode}");
Console.WriteLine(body);
```

{% endtab %}
{% endtabs %}

***

### API documentation

Look at the whole documentation to view all endpoints and possibilities how to use this service.

{% content-ref url="/pages/uhaVxRp9WuaPsZ8dK6xx" %}
[Documents API Reference](/business-apis/documents-api/documents-api-reference.md)
{% endcontent-ref %}

***

## Use Our Sample Clients

Check out our sample clients if you want an example of usage:

{% columns %}
{% column %}
Here's a guide on how to get Postman set up against our services:

{% content-ref url="/pages/Qf4oYxCJ7tayE0YVbEMa" %}
[Postman Examples](/business-apis/examples/postman-examples.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Here's an example of a .NET client if you prefer that;

{% content-ref url="/pages/R5GwZIHeTwiKK8nehodk" %}
[.NET Sample Clients](/business-apis/examples/.net-sample-clients.md)
{% endcontent-ref %}
{% endcolumn %}
{% endcolumns %}
