# API logs

> Kontiga is document fraud detection by Bynn Intelligence for insurers, letting agents, lenders and HR screening teams: every document is compared with a proprietary library of more than 300 million original documents, gathered over 20 years.

Documentation index: https://kontiga.com/llms.txt

Section: Reference. URL: https://kontiga.com/docs/api-logs

Every request made with the workspace's keys, newest first: its time, method, path, status, error code, duration, key, mode and request id, on Kontiga's API and the compatible document API. Each request is kept 7 days with its request and its answer, every value withheld, so a failed call can be read and sent again with no data of yours in the log. The counts are kept 30 days.

Updated December 1, 2026

## Reading a failed request

- Every answer carries its request id in the `x-request-id` header. Read that request to see what was sent and what came back.
- A `4xx` is refused: the call can be fixed, and the answer's `error.fix` says what to change. A `5xx` failed on Kontiga's side: send it again with the same `Idempotency-Key`.
- The key is shown by its name, kind and last four characters. Its secret is never kept.
- Every value of yours reads `[withheld]`, a number `[number withheld]` and a true or false `[boolean withheld]`, so the shape keeps its types: the log keeps the names of the fields, headers and parameters and the shape of the bodies, never a value, and a name that is not a plain one reads `[name withheld]`. An id in a path is kept when it is one of Kontiga's (on the compatible API, a document's token or request code); anything else there reads `[withheld]`. The API's own words stay as sent, so a refused call reads back what was wrong: event types (and `*`), `format`, `mode`, `method`, `enabled`, a delivery's or an endpoint's `state`, a status class, `range`, `overlap`, `target` and Kontiga's own ids, in a body and in a query; in an answer also a list's `object`, `has_more` and `next_cursor`, an object's `state`, its times (`created_at` and the other `_at` keys) and its counts (`attempts`, `resent`, `duration_ms`, `last_status`). A header keeps a value only in a form that names no one: `Content-Type` and `Accept` as the media types the API takes and answers, `User-Agent` as the product names and versions of known clients and of plain lower-case names, `Kontiga-Mode` as `live` or `test`, `Origin` when a publishable key's list let it read the answer; any other header is its name. A body that is not JSON is its type and size. What Kontiga answered stays readable: a refused call's error code, message and the fields it named, and the id of what a call made. The `curl` form reads the key from `$KONTIGA_API_KEY` and leaves the withheld values for you to fill in, with a first line that says what goes where. A message of Kontiga's that repeats a value you sent reads `[message withheld: it repeats a value sent]`, its code kept.
- Where a call came from is its country (`request.country`, null when not known), never its address. `about` is the object a call was about (the id in its path, or the one a create made).
- An error's message that repeats a value the call sent (a name or an address in an unknown event type, say) reads `[message withheld: it repeats a value sent]`; its code is kept. A path that matches no route keeps its first two segments and the length of the rest.
- A call made in the console is in the audit log, not here: this log holds the calls made with keys. A revoked or expired key's calls are not logged.
- A key reads the requests of its own mode's keys: a test key sees no live request.
- Every request is counted. A refused one (`429`, or a `503` while Kontiga sheds load) is kept as a request at most 5 times a second for each key, and a workspace keeps up to 256 MiB of bodies a day; past that, requests are kept without their bodies.

## List API requests

Each request made with the workspace's keys, newest first: time, method, path, status, the error's code, duration, key, mode and request id. Each request is kept 7 days and the counts 30, with no personal data.

`GET /v1/request_logs`. Who may: Owner, Admin and Developer. CLI: `kontiga logs list [--key-id <key_id>] [--mode <live|test>] [--status <2xx|4xx|5xx>] [--path </v1/...>] [--range <1h|24h|7d|30d>] [--request-id <req_...>] [--from-at <iso>] [--to-at <iso>] [--limit <n>] [--cursor <c_...>]`. MCP tool: `list_api_logs`.

**Parameters**
- `key_id` (id (key_)): Only requests made with this key.
- `mode` (enum): Live or test requests: never both in one list. Left out, the call's own mode (a key's; the console's switch). A key reads its own mode's only. One of `live`, `test`.
- `status` (enum): Only answers of this class: `2xx` succeeded, `4xx` refused, `5xx` failed.
- `path` (string): Only requests whose route starts with this, such as `/v1/cases`, or one object's requests by its path with its whole id, such as `/v1/documents/doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081`. At most 200 characters.
- `range` (enum, default "24h"): How far back to read: `1h`, `24h`, `7d` or `30d`. The requests themselves go back 7 days; the counts, the median and the columns 30.
- `request_id` (id (req_)): One request by its id, as the `x-request-id` header gave it, or the requests whose id starts with `req_` and at least 8 of its hex characters.
- `limit` (integer, default 50): How many to answer, a whole number from 1 to 200.
- `cursor` (id (c_)): The `next_cursor` of the page before. A page read with a cursor holds its requests only (`items`, `next_cursor`, `has_more`, `from`, `to`): the counts, the median, the routes and the columns come on the first page.
- `from_at` (string): Only requests from this time on, inside the range: a bucket's `at`.
- `to_at` (string): Only requests before this time: a bucket's `to`.

**Returns** page of API requests: The requests that match, newest first. The first page (no cursor) also has how many matched in all, how many succeeded, were refused and failed, their median time, the routes called, and the range's requests over time by result; a page read with a cursor has its requests only.

API:

```bash
curl -X GET "https://api.kontiga.com/v1/request_logs?status=4xx&range=24h" \
  -H "Authorization: Bearer $KONTIGA_API_KEY"
```

CLI:

```bash
kontiga logs list --status 4xx --range 24h
```

MCP tool `list_api_logs`:

```json
{
  "name": "list_api_logs",
  "arguments": {
    "status": "4xx",
    "range": "24h"
  }
}
```

TypeScript:

```typescript
import Kontiga from "@kontiga/sdk";

const kontiga = new Kontiga(); // reads KONTIGA_API_KEY
const result = await kontiga.apiLogs.list({
  status: "4xx",
  range: "24h",
});
```

Python:

```python
from kontiga import Kontiga

kontiga = Kontiga()  # reads KONTIGA_API_KEY
result = kontiga.api_logs.list(status="4xx", range="24h")
```

Go:

```go
client := kontiga.NewClient() // reads KONTIGA_API_KEY
result, err := client.ApiLogs.List(ctx, &kontiga.ApiLogsListParams{
	Status: "4xx",
	Range:  "24h",
})
if err != nil {
	return err
}
```

Java:

```java
Kontiga kontiga = Kontiga.fromEnv(); // reads KONTIGA_API_KEY
var result = kontiga.apiLogs().list(ApiLogsListParams.builder()
    .status("4xx")
    .range("24h")
    .build());
```

.NET:

```csharp
var kontiga = new KontigaClient(); // reads KONTIGA_API_KEY
var result = await kontiga.ApiLogs.ListAsync(new ApiLogsListOptions
{
    Status = "4xx",
    Range = "24h",
});
```

PHP:

```php
$kontiga = new \Kontiga\Client(); // reads KONTIGA_API_KEY
$result = $kontiga->apiLogs->list([
    'status' => '4xx',
    'range' => '24h',
]);
```

Ruby:

```ruby
require "kontiga"

kontiga = Kontiga::Client.new # reads KONTIGA_API_KEY
result = kontiga.api_logs.list(status: "4xx", range: "24h")
```

Rust:

```rust
let kontiga = kontiga::Client::from_env()?; // reads KONTIGA_API_KEY
let result = kontiga
    .api_logs()
    .list(kontiga::api_logs::ListParams {
        status: "4xx".into(),
        range: "24h".into(),
        ..Default::default()
    })
    .await?;
```

Response, 200 OK:

```json
{
  "object": "list",
  "items": [
    {
      "id": "req_5e2a9c71d4b83f06a1c7e9d2",
      "at": "2026-11-26T09:38:12Z",
      "method": "POST",
      "path": "/v1/cases/case_7Kq2Xw9/outcomes",
      "route": "/v1/cases/{case_id}/outcomes",
      "api": "kontiga",
      "status": 403,
      "error_code": "forbidden_scope",
      "duration_ms": 41,
      "key": {
        "id": "key_2Wq7Hc4",
        "name": "Onboarding service",
        "kind": "restricted",
        "mode": "live",
        "prefix": "kt_live_",
        "last4": "7Q2K"
      },
      "mode": "live",
      "replay": false,
      "object": "request_log",
      "about": { "id": "case_7Kq2Xw9", "label": "Case", "href": "/console/cases/case_7Kq2Xw9" }
    },
    {
      "id": "req_9b4d1e6a2c7f08e35d1a4b9c",
      "at": "2026-11-26T09:37:55Z",
      "method": "GET",
      "path": "/v1/cases/case_7Kq2Xw9",
      "route": "/v1/cases/{case_id}",
      "api": "kontiga",
      "status": 200,
      "error_code": null,
      "duration_ms": 63,
      "key": {
        "id": "key_2Wq7Hc4",
        "name": "Onboarding service",
        "kind": "restricted",
        "mode": "live",
        "prefix": "kt_live_",
        "last4": "7Q2K"
      },
      "mode": "live",
      "replay": false,
      "object": "request_log",
      "about": { "id": "case_7Kq2Xw9", "label": "Case", "href": "/console/cases/case_7Kq2Xw9" }
    }
  ],
  "total": 2602,
  "succeeded": 2580,
  "refused": 19,
  "failed": 3,
  "median_ms": 58,
  "routes": [
    { "route": "/v1/documents/{document_id}", "count": 1259 },
    { "route": "/v1/cases/{case_id}", "count": 611 }
  ],
  "buckets": [
    { "at": "2026-11-26T08:00:00Z", "to": "2026-11-26T09:00:00Z", "succeeded": 131, "refused": 4, "failed": 0 },
    { "at": "2026-11-26T09:00:00Z", "to": "2026-11-26T09:42:00Z", "succeeded": 88, "refused": 1, "failed": 1 }
  ],
  "next_cursor": "c_179568347500000000000000004891327652918604528173",
  "has_more": true,
  "from": "2026-11-25T09:42:00Z",
  "to": "2026-11-26T09:42:00Z"
}
```

## Read an API request

One request by its request id: what was sent and what came back, the key masked and every value withheld, the error in plain words with what to change, and the call as a curl command.

`GET /v1/request_logs/{request_id}`. Who may: Owner, Admin and Developer. CLI: `kontiga logs get <request_id>`. MCP tool: `get_api_log`.

**Parameters**
- `request_id` (id (req_), required): The request's id, from the `x-request-id` header of its answer. In the path.

**Returns** API request: The request and its answer, the error explained, and a curl command that reads the key from its environment variable.

API:

```bash
curl -X GET https://api.kontiga.com/v1/request_logs/req_5e2a9c71d4b83f06a1c7e9d2 \
  -H "Authorization: Bearer $KONTIGA_API_KEY"
```

CLI:

```bash
kontiga logs get req_5e2a9c71d4b83f06a1c7e9d2
```

MCP tool `get_api_log`:

```json
{
  "name": "get_api_log",
  "arguments": {
    "request_id": "req_5e2a9c71d4b83f06a1c7e9d2"
  }
}
```

TypeScript:

```typescript
import Kontiga from "@kontiga/sdk";

const kontiga = new Kontiga(); // reads KONTIGA_API_KEY
const result = await kontiga.apiLogs.get("req_5e2a9c71d4b83f06a1c7e9d2");
```

Python:

```python
from kontiga import Kontiga

kontiga = Kontiga()  # reads KONTIGA_API_KEY
result = kontiga.api_logs.get("req_5e2a9c71d4b83f06a1c7e9d2")
```

Go:

```go
client := kontiga.NewClient() // reads KONTIGA_API_KEY
result, err := client.ApiLogs.Get(ctx, "req_5e2a9c71d4b83f06a1c7e9d2")
if err != nil {
	return err
}
```

Java:

```java
Kontiga kontiga = Kontiga.fromEnv(); // reads KONTIGA_API_KEY
var result = kontiga.apiLogs().get("req_5e2a9c71d4b83f06a1c7e9d2");
```

.NET:

```csharp
var kontiga = new KontigaClient(); // reads KONTIGA_API_KEY
var result = await kontiga.ApiLogs.GetAsync("req_5e2a9c71d4b83f06a1c7e9d2");
```

PHP:

```php
$kontiga = new \Kontiga\Client(); // reads KONTIGA_API_KEY
$result = $kontiga->apiLogs->get('req_5e2a9c71d4b83f06a1c7e9d2');
```

Ruby:

```ruby
require "kontiga"

kontiga = Kontiga::Client.new # reads KONTIGA_API_KEY
result = kontiga.api_logs.get("req_5e2a9c71d4b83f06a1c7e9d2")
```

Rust:

```rust
let kontiga = kontiga::Client::from_env()?; // reads KONTIGA_API_KEY
let result = kontiga
    .api_logs()
    .get("req_5e2a9c71d4b83f06a1c7e9d2".into())
    .await?;
```

Response, 200 OK:

```json
{
  "id": "req_5e2a9c71d4b83f06a1c7e9d2",
  "at": "2026-11-26T09:38:12Z",
  "method": "POST",
  "path": "/v1/cases/case_7Kq2Xw9/outcomes",
  "route": "/v1/cases/{case_id}/outcomes",
  "api": "kontiga",
  "status": 403,
  "error_code": "forbidden_scope",
  "duration_ms": 41,
  "mode": "live",
  "request": {
    "url": "https://api.kontiga.com/v1/cases/case_7Kq2Xw9/outcomes",
    "headers": [
      ["authorization", "Bearer kt_live_…7Q2K"],
      ["content-type", "application/json"],
      ["idempotency-key", "decide-APP-20418"]
    ],
    "body": "{\"outcome\":\"[withheld]\",\"note\":\"[withheld]\"}",
    "country": "SE",
    "user_agent": "kontiga-node/1.4.0",
    "origin": null,
    "idempotency_key": "decide-APP-20418"
  },
  "response": {
    "headers": [["x-request-id", "req_5e2a9c71d4b83f06a1c7e9d2"]],
    "body": "{\"error\":{\"code\":\"[withheld]\",\"message\":\"[withheld]\"}}"
  },
  "error": {
    "code": "forbidden_scope",
    "message": "This key may not decide cases.",
    "meaning": "The key works, but its scopes do not include deciding cases.",
    "fix": "Add cases:write to the key's scopes in Developers > API keys, or call with a key that has it.",
    "issues": []
  },
  "curl": "curl -X POST https://api.kontiga.com/v1/cases/case_7Kq2Xw9/outcomes -H \"Authorization: Bearer $KONTIGA_API_KEY\" -H \"Content-Type: application/json\" -d '{\"outcome\":\"[withheld]\",\"note\":\"[withheld]\"}'"
}
```
