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

# API Overview

> Integrate LexQ policy execution into your application via REST API.

## Base URLs

LexQ exposes two separate APIs with different base URLs:

| API | Base URL | Purpose |
| - | - | - |
| **Management API** | `https://api.lexq.io/api/v1/partners` | Policy lifecycle (create, test, deploy) |
| **Execution API** | `https://api.lexq.io/api/v1/execution` | Runtime policy evaluation (your app calls this) |

> [!WARNING]
>
> Do not mix the two base URLs. Management endpoints return 404 on the Execution base URL and vice versa.

## Authentication

LexQ uses **API Key** authentication. Include your key in every request:

```bash theme={null}
x-api-key: YOUR_API_KEY
```

API keys are created and managed in the Console under **Management → API Keys**.

> [!WARNING]
>
> An API key acts on behalf of your organization within its [scope](https://docs.lexq.io/api/authentication.md#scope). Never expose one in client-side code or public repositories.

## Request Format

All request and response bodies use JSON. Set the `Content-Type` header:

```
Content-Type: application/json
```

## Response Format

Every response follows a consistent envelope:

```json Success theme={null}
{
  "result": "SUCCESS",
  "data": { ... }
}
```

```json Error theme={null}
{
  "result": "ERROR",
  "errorCode": "P-001",
  "message": "Policy group not found."
}
```

> [!WARNING]
>
> The top-level field is `result` (value: `"SUCCESS"` or `"ERROR"`), **not** `success: true/false`. Always check `result === "SUCCESS"` in your integration code.

## Error Codes

Error codes follow a prefix convention:

| Prefix | Domain |
| - | - |
| `C-xxx` | Common (input validation, not found, rate limit) |
| `A-xxx` | Auth (credentials, API key, sessions) |
| `P-xxx` | Policy Engine (groups, versions, rules, deployments) |
| `I-xxx` | Idempotency |
| `S-xxx` | System / Crypto |
| `B-xxx` | Billing (subscription, payment, quota) |
| `M-xxx` | Member & Account |
| `AN-xxx` | Analytics & Simulation |
| `ACT-xxx` | Action validation (parameters, operator/method, rounding) |
| `FD-xxx` | Fact Definition |
| `FL-xxx` | Failure Log |
| `WH-xxx` | Webhook Subscription |

See the [full error reference](https://docs.lexq.io/api/errors.md) for details.

## Rate Limits

Rate limits apply **per organization** (across all API keys for the same tenant), based on your plan's **Max TPS** setting:

| Plan | Max TPS |
| - | - |
| Free | 10 |
| Growth | 100 |
| Pro | 500 |
| Enterprise | Custom |

Requests over your plan's Max TPS receive HTTP `429 Too Many Requests` with code `C-007`. Wait a second and retry.

For execution endpoints, a [batch or composite call](https://docs.lexq.io/api/execution.md#batch-execution) counts as one request against TPS, however many fact sets or groups it holds. Billing still counts each one.

Dry runs, Dry Run Compare, and single decision replays don't count against TPS. They have their own per-minute and daily limits; see [Dry Run Limits](https://docs.lexq.io/guides/dry-run.md#limits).

> [!TIP]
>
> Issuing additional API keys does not raise your limit: every key in your organization shares it. Upgrade your plan to raise the limit.

## Idempotency

For execution endpoints, you can include an `Idempotency-Key` header to prevent duplicate processing:

```bash theme={null}
Idempotency-Key: unique-request-id-123
```

Duplicate requests with the same key return the original response without re-executing the policy.

## Pagination

List endpoints return paginated results:

```json theme={null}
{
  "result": "SUCCESS",
  "data": {
    "content": [ ... ],
    "totalElements": 42,
    "totalPages": 3,
    "pageNo": 0,
    "pageSize": 20,
    "last": false
  }
}
```

Use the `page` (0-indexed) and `size` query parameters to navigate pages. The response reports them back as `pageNo` and `pageSize`.

## Next Steps

> [card] [Authentication](https://docs.lexq.io/api/authentication.md)
>
> API key management and security best practices.

> [card] [Policy Execution](https://docs.lexq.io/api/execution.md)
>
> Execute policies against live traffic.


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