# API overview

> Base URL, authentication, request and response conventions, and a first call.

Source: https://docs.ligament.ai/developers/

The Ligament API lets your own code read and change the same records, workflows and app definitions that people use in the app. Use it to sync records with another system, build a dashboard, run a nightly export or give an AI agent controlled access to your workspace.

This page covers what every call has in common. The full list of endpoints is in the [REST API reference](https://docs.ligament.ai/reference/rest-api/index.md), and the same API is published as an OpenAPI document at [/openapi.json](https://docs.ligament.ai/openapi.json).

## Base URL

The API lives on the same origin as the app, under `/api`:

```plaintext
https://app.ligament.ai/api
```

## Authentication

Send an API key as a Bearer token on every request:

```plaintext
Authorization: Bearer <your key>
```

You create keys in the app under **Settings › API keys** (see [API keys and scopes](https://docs.ligament.ai/developers/api-keys/index.md)). The key is shown once, when you create it. Keep it in a secret store or an environment variable; the examples in these docs read it from `$LIGAMENT_API_KEY`.

The app itself calls the same endpoints with a signed-in browser session instead of a key. The two are not interchangeable:

| Question | API key | Signed-in session |
| --- | --- | --- |
| Who it acts as | The person who created the key, capped at their current role | The signed-in person |
| What limits it | The key’s scopes, then that person’s access | That person’s role and access |
| Where it works | Every endpoint that declares a scope | Every endpoint, including the session-only ones |

A few areas only accept a signed-in session: managing API keys, SSO providers, the security policy and OIDC clients among them. A key gets `403 session_required` there. The [scopes reference](https://docs.ligament.ai/reference/scopes/index.md#session-only) lists them.

## Requests and responses

Request and response bodies are JSON. Send `Content-Type: application/json` on `POST`, `PUT` and `PATCH`. Timestamps are ISO 8601 in UTC (`2026-11-30T13:57:30.540Z`).

Errors are JSON too, with an HTTP status that tells you what kind of problem it is. Most permission errors carry a machine-readable `code` and a `fix` you can show to a person or feed back to an agent. See [Errors](https://docs.ligament.ai/developers/errors/index.md).

## A first call: list records

Records are addressed by entity key, for example `incident`, `person` or `case`. This lists the newest incident in the workspace:

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=1" \
  -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

The response has the rows, the total number of matching records and what to send for the next page (trimmed to a few fields here):

```json
{
  "rows": [
    {
      "id": "cmx3c1hkc010fxjg0ona7p9j5",
      "number": "INC0000050",
      "title": "Verification API: elevated latency on document checks",
      "priority": "high",
      "state": "new",
      "createdAt": "2026-11-30T13:57:30.540Z",
      "updatedAt": "2026-11-30T14:30:03.676Z"
    }
  ],
  "total": 39,
  "nextCursor": "MjAyNi0xMS0zMFQxMzo1NzozMC41NDBafGNteDNjMWhrYzAxMGZ4amcwb25hN3A5ajU"
}
```

Each row has the record’s fields plus `id`, `state`, `createdAt`, `updatedAt`, `createdBy` and `updatedBy`. Fields the key’s creator isn’t allowed to see are left out. [Lists, filters and pagination](https://docs.ligament.ai/developers/pagination/index.md) covers filtering, sorting, search and paging.

To create a record, `POST` the field values to the same path:

```sh
curl -s -X POST "https://app.ligament.ai/api/records/incident" \
  -H "Authorization: Bearer $LIGAMENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Printer on 3rd floor offline", "priority": "medium"}'
```

A successful create answers `201 Created` with the new record:

```json
{"record":{"id":"cmx6au3qf00kd6x6suwxls72s","state":"new","title":"Printer on 3rd floor offline","number":"INC0000119","priority":"medium","time_worked_hours":null}}
```

The workspace fills in defaults and numbering (`state`, `number`) as it would for a record created in the app.

## Which workspace a key works in

A key belongs to the workspace you were working in when you created it, and it only ever sees that workspace. There’s no workspace parameter on API calls. If your organisation has subsidiaries, create a key in each workspace your integration needs.

To check what a key acts as, call `GET /api/access/whoami` (needs `records:read`):

```json
{
  "userId": "vtvYBRvkNm4bYx6I0D9xqXS1lxzj7rBJ",
  "role": "admin",
  "admin": true,
  "keyId": "cmx6aqk0b00ef6x6sdme04cmc",
  "scopes": ["records:read", "records:write:incident"],
  "evaluator": "v2",
  "accessVersion": 468,
  "canExplainOthers": true
}
```

`role` is the role the key acts with: its creator’s current role, at most `admin`.

## Other ways in

-   The [MCP server](https://docs.ligament.ai/developers/mcp/index.md) at `https://app.ligament.ai/api/mcp` gives AI clients the same records, access and spec tools over JSON-RPC.
-   The [CLI](https://docs.ligament.ai/developers/cli/index.md) wraps the API for scripts and terminals.
-   [Inbound hooks and run callbacks](https://docs.ligament.ai/developers/webhooks/index.md) cover calls that come from other systems into your workspace, and callbacks your workspace sends when a workflow run finishes.
