> For the complete documentation index, see [llms.txt](https://docs.luciq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luciq.ai/references/api-access/endpoints.md).

# Endpoints

Reference for the Luciq Query API endpoints: run and validate queries, list entities, and check your rate limits and monthly quota usage.

#### `POST` /v1/query

Run one query and return the columnar result. Counts against your monthly quota.

**First Example:** Top 10 failing network endpoints per hour

{% tabs %}
{% tab title="Curl" %}

```bash
curl -s https://api.luciq.ai/v1/query \
  -H "Authorization: Bearer $LUCIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "application": "my-application",
  "environment": "production",
  "entity": "networks",
  "select": [
    {
      "metric": "failure_rate"
    }
  ],
  "group_by": [
    {
      "time_bucket": "hour"
    },
    {
      "column": "endpoint_label"
    }
  ],
  "top_n": {
    "by": "failure_rate",
    "dir": "desc",
    "n": 10
  },
  "time_range": {
    "last": "24h"
  },
  "limit": 500
}'

```

{% endtab %}

{% tab title="Python" %}

```python
import os, requests

resp = requests.post(
    "https://api.luciq.ai/v1/query",
    headers={"Authorization": f"Bearer {os.environ['LUCIQ_API_KEY']}"},
    json={
    "application": "my-application",
    "environment": "production",
    "entity": "networks",
    "select": [
        {
            "metric": "failure_rate"
        }
    ],
    "group_by": [
        {
            "time_bucket": "hour"
        },
        {
            "column": "endpoint_label"
        }
    ],
    "top_n": {
        "by": "failure_rate",
        "dir": "desc",
        "n": 10
    },
    "time_range": {
        "last": "24h"
    },
    "limit": 500
},
)
resp.raise_for_status()
data = resp.json()
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "json"

uri = URI("https://api.luciq.ai/v1/query")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV["LUCIQ_API_KEY"]}"
req["Content-Type"] = "application/json"
req.body = <<~JSON
  {
    "application": "my-application",
    "environment": "production",
    "entity": "networks",
    "select": [
      {
        "metric": "failure_rate"
      }
    ],
    "group_by": [
      {
        "time_bucket": "hour"
      },
      {
        "column": "endpoint_label"
      }
    ],
    "top_n": {
      "by": "failure_rate",
      "dir": "desc",
      "n": 10
    },
    "time_range": {
      "last": "24h"
    },
    "limit": 500
  }
JSON

res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const resp = await fetch("https://api.luciq.ai/v1/query", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.LUCIQ_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "application": "my-application",
  "environment": "production",
  "entity": "networks",
  "select": [
    {
      "metric": "failure_rate"
    }
  ],
  "group_by": [
    {
      "time_bucket": "hour"
    },
    {
      "column": "endpoint_label"
    }
  ],
  "top_n": {
    "by": "failure_rate",
    "dir": "desc",
    "n": 10
  },
  "time_range": {
    "last": "24h"
  },
  "limit": 500
}),
});
const data = await resp.json();
```

{% endtab %}
{% endtabs %}

**Second Example:** Sessions on the latest release, split by OS

{% tabs %}
{% tab title="Curl" %}

```bash
curl -s https://api.luciq.ai/v1/query \
  -H "Authorization: Bearer $LUCIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "application": "my-application",
  "environment": "production",
  "entity": "sessions",
  "select": [
    {
      "metric": "count"
    }
  ],
  "conditions": [
    {
      "column": "app_version",
      "op": "eq",
      "value": {
        "latest": true
      }
    }
  ],
  "group_by": [
    {
      "column": "os_version"
    }
  ],
  "time_range": {
    "last": "7d"
  }
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import os, requests

resp = requests.post(
    "https://api.luciq.ai/v1/query",
    headers={"Authorization": f"Bearer {os.environ['LUCIQ_API_KEY']}"},
    json={
        "application": "my-application",
        "environment": "production",
        "entity": "sessions",
        "select": [
            {
                "metric": "count"
            }
        ],
        "conditions": [
            {
                "column": "app_version",
                "op": "eq",
                "value": {
                    "latest": True
                }
            }
        ],
        "group_by": [
            {
                "column": "os_version"
            }
        ],
        "time_range": {
            "last": "7d"
        }
    },
)
resp.raise_for_status()
data = resp.json()
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "json"

uri = URI("https://api.luciq.ai/v1/query")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV["LUCIQ_API_KEY"]}"
req["Content-Type"] = "application/json"
req.body = <<~JSON
  {
    "application": "my-application",
    "environment": "production",
    "entity": "sessions",
    "select": [
      {
        "metric": "count"
      }
    ],
    "conditions": [
      {
        "column": "app_version",
        "op": "eq",
        "value": {
          "latest": true
        }
      }
    ],
    "group_by": [
      {
        "column": "os_version"
      }
    ],
    "time_range": {
      "last": "7d"
    }
  }
JSON

res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const resp = await fetch("https://api.luciq.ai/v1/query", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.LUCIQ_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "application": "my-application",
    "environment": "production",
    "entity": "sessions",
    "select": [
      {
        "metric": "count"
      }
    ],
    "conditions": [
      {
        "column": "app_version",
        "op": "eq",
        "value": {
          "latest": true
        }
      }
    ],
    "group_by": [
      {
        "column": "os_version"
      }
    ],
    "time_range": {
      "last": "7d"
    }
  }),
});
const data = await resp.json();
```

{% endtab %}
{% endtabs %}

#### `POST` /v1/query/validate

Checks a query's structure (entity, columns, operators, metrics, time range, shape) without running it. `budget_exceeded` and timeouts only appear on a real run.

Counts toward the per-minute and per-hour limits, not the monthly quota.

`Body: QueryRequest. Returns { "valid": true }, or the same error shape as /v1/query.`

#### `GET` /v1/entities

The catalog surface visible to your key: entities, their typed columns, the operators each column accepts, and the metrics available. This is what a query builder is built on.

`Takes no parameters, it authenticates the key and returns the full catalog the key can see.`

The catalog includes the `spans` entity. A `spans` query needs a `parent` and a `parent_uuid` condition. See [Spans](https://docs.luciq.ai/references/api-access/building-a-query.md#spans).

#### `POST` /v1/rate\_limit

Your current rate-window state. Reads counters without consuming them, and stays reachable even while you're being limited, so a client can back off before hitting `429`.

{% tabs %}
{% tab title="Curl" %}

```bash
curl -s https://api.luciq.ai/v1/rate_limit \
  -H "Authorization: Bearer $LUCIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "application": "my-application",
  "environment": "production"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import os, requests

resp = requests.post(
    "https://api.luciq.ai/v1/rate_limit",
    headers={"Authorization": f"Bearer {os.environ['LUCIQ_API_KEY']}"},
    json={
        "application": "my-application",
        "environment": "production"
    },
)
resp.raise_for_status()
data = resp.json()
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "json"

uri = URI("https://api.luciq.ai/v1/rate_limit")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV["LUCIQ_API_KEY"]}"
req["Content-Type"] = "application/json"
req.body = <<~JSON
  {
    "application": "my-application",
    "environment": "production"
  }
JSON

res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const resp = await fetch("https://api.luciq.ai/v1/rate_limit", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.LUCIQ_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "application": "my-application",
    "environment": "production"
  }),
});
const data = await resp.json();
```

{% endtab %}
{% endtabs %}

```json
{
  "requests": {
    "per_minute": { "limit": 60, "remaining": 57, "resets_at": … },
    "per_hour":   { "limit": 1000, "remaining": 912, "resets_at": … }
  }
}
```

#### Usage headers <a href="#usage-headers" id="usage-headers"></a>

Each query response tells you where you stand:

* `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset`, `RateLimit-Policy`: your per-minute and per-hour limits. Present on every response.
* `X-Query-Id`: quote it when you contact support.

{% hint style="info" %}

#### Good to know

* The OpenAPI spec is at `GET /v1/openapi.json` (no key needed).
* There is no batch endpoint. Run queries in parallel (up to 8 at once per app).
* `GET /v1/entities` returns an `ETag`. Send `If-None-Match` to get `304` when nothing changed.
* Request bodies are limited to 1 MiB, unknown fields are rejected, and each query times out after 30 seconds.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.luciq.ai/references/api-access/endpoints.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
