# Get started

> Create a personal API key in the hub, check it with GET /v1/access and send your first text to Redact.

This guide takes you from a personal API key to your first call to Redact, with a call to Chat as the alternative. You need a terminal with curl.

## Before you start

- You have an account in an organisation that has API access with komplai, and your administrator has assigned you the tool you want to call (in the hub: **Organisation › People › Tool access**). When you can create a key, the hub's menu shows **APIs and integrations**. If it does not, ask your administrator.
- A system that runs without a person, such as a robot, uses an organisation integration key that komplai issues instead. With that key, start at step 2. [Organisation integration keys](https://developers.komplai.dk/authentication#organisation-integration-keys) explains how you get one.
- Use test data until your organisation's processing of personal data is approved. Step 2 shows which applies to your key. See [Test data](https://developers.komplai.dk/test-data).

## 1. Create a personal API key

1. [Sign in](https://hub.komplai.dk/login) to the hub, open **APIs and integrations** in the menu and choose **API keys**.
2. Choose **Create API key**.
3. Under **What will the key be used for?**, choose **Redact** and then **Continue**. This selects the scopes `access:read`, `redact:detect` and `redact:process`.
4. Under **Name the key**, enter the name of the system that will use it, choose a **Validity** of 7, 30, 90 or 365 days and choose **Continue**.
5. Under **Review access**, check the **Permissions** and choose **Create API key**.
6. Copy the key. The hub shows it only this once.

For Chat, choose **Chat and text** in step 3, and under **Review access** also tick `access:read` under **Account access**, so the key can make the call in step 2.

> **Treat the key as a password**
>
> Anyone who has the key can call the API as you, within its scopes. Keep it in a secret store, never in code, a URL, a ticket or an e-mail. If it leaks, revoke it under **API keys** at once.

The examples read the key from the environment variable `KOMPLAI_TOKEN`. This command reads it in a terminal without showing it or saving it in your shell history. Paste the key and press Enter:

```bash
read -rs KOMPLAI_TOKEN && export KOMPLAI_TOKEN
```

## 2. Check the key

GET /v1/access shows what the key reaches. It sends no text and runs no model.

```bash
curl https://api.komplai.dk/v1/access \
  -H "Authorization: Bearer $KOMPLAI_TOKEN"
```

A 200 answer means the key works. These fields tell you what you can do with it:

| Field | What it tells you |
| --- | --- |
| `scopes` | The scopes the key has. |
| `services[].service` | Each tool the key reaches, such as `redact` or `chat`. |
| `services[].processing.data_mode` | `synthetic`: use test data only. `personal`: personal data under the agreement in `agreement_reference`. |
| `services[].hosting.processing.layers` | For Redact: where each layer processes text. |
| `services[].limits.requests_per_minute` | Your request limit per minute for calls to the tool. |

[API keys and authentication](https://developers.komplai.dk/authentication) describes the whole answer. If the call fails:

- 401 [`api_key_required`](https://developers.komplai.dk/errors/api_key_required): the header is missing, often because `KOMPLAI_TOKEN` is empty.
- 401 [`invalid_api_key`](https://developers.komplai.dk/errors/invalid_api_key): the key is incomplete, expired or revoked, or you are no longer assigned the tool.
- 403 [`insufficient_scope`](https://developers.komplai.dk/errors/insufficient_scope): the key does not have `access:read`. Create a key that has it.

## 3. Make your first call

**Redact**

POST /v1/redact/detect finds personal data in a text without changing it. `mode` `ner` runs the rules and the NER model. Send a test text:

```bash
curl https://api.komplai.dk/v1/redact/detect \
  -H "Authorization: Bearer $KOMPLAI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "Ring til Mette Kjærgaard Holm på 21 34 56 78.", "mode": "ner"}'
```

```json
{
  "findings": [
    {
      "start": 9,
      "end": 29,
      "type": "person",
      "value": "Mette Kjærgaard Holm",
      "confidence": "high",
      "source": "ner"
    },
    {
      "start": 33,
      "end": 44,
      "type": "phone",
      "value": "21 34 56 78",
      "confidence": "medium",
      "source": "regex"
    }
  ],
  "truncated": false,
  "degraded": false
}
```

The NER model found the name and the rules found the phone number. `start` and `end` count UTF-16 code units in your text.

The rules run on komplai's servers in Germany (EU), and NER at the default place GET /v1/access marks, which is komplai's servers in Germany unless komplai has changed it. The text is held in memory while the call runs and is not stored. Your organisation's own redaction rules apply: a rule's match comes back with `source` and `type` set to `custom`.
**Chat**

POST /v1/chat/completions sends messages to a model and returns the whole answer. `processing` `komplai-local` runs the model on komplai's local infrastructure in Denmark, with no AI charge. The answer can take up to a minute while the shared queue is busy.

```bash
curl https://api.komplai.dk/v1/chat/completions \
  -H "Authorization: Bearer $KOMPLAI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"processing": "komplai-local", "messages": [{"role": "user", "content": "Hvor lang tid har jeg til at klage over en afgørelse om boligstøtte?"}], "max_tokens": 256}'
```

```json
{
  "id": "chatcmpl-8c1d5e3a-2f7b-4a9c-b6e0-3d4f5a6b7c8d",
  "object": "chat.completion",
  "created": 1792483200,
  "model": "qwen3.8-27b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Du har normalt 4 uger til at klage, regnet fra den dag du fik afgørelsen. Fristen står i afgørelsens klagevejledning."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 27,
    "completion_tokens": 33
  }
}
```

The answer is in `choices[0].message.content`, and `model` names the model that answered. Without `model` in the request, the call uses the model you chose in the hub, else your organisation's default. GET /v1/models?processing=komplai-local lists the models you can name. If your organisation does not allow local infrastructure through the API, the call answers 403 [`processing_choice_not_allowed`](https://developers.komplai.dk/errors/processing_choice_not_allowed).

## Next steps

- [Redact](https://developers.komplai.dk/tools/redact): pseudonymise text with POST /v1/redact, put the originals back and send long documents as text jobs.
- [API keys and authentication](https://developers.komplai.dk/authentication): scopes, renewal and revocation, and organisation integration keys.
- [Errors](https://developers.komplai.dk/errors) and [Limits](https://developers.komplai.dk/limits): what to do when a call fails or reaches a limit.
- [API reference](https://developers.komplai.dk/api): every operation, with samples in curl, PowerShell, Python, JavaScript and C#, and a console to try each call.

---

https://developers.komplai.dk/get-started
