---
title: "Get the RQL schema"
description: "Returns what an RQL query can name: every entity with its fields, types and relations, every function with its arguments, the aggregates and the special functions. It holds no project data, so it is the same for every caller. The SQL editor's Entities panel reads the same catalog."
---

**GET** `https://api.respan.ai/api/query/schema/`

Returns what an RQL query can name: every entity with its fields, types and relations, every function with its arguments, the aggregates and the special functions. It holds no project data, so it is the same for every caller. The SQL editor's Entities panel reads the same catalog.

## Servers

`https://api.respan.ai`: Respan API Server

## Authentication

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


## Examples

### Query catalog

Trimmed from a live call on 2026-11-23: one entity with four of its fields, and the first entries of each list.

#### Response


```json
{
  "body": {
    "entities": [
      {
        "name": "spans",
        "time": "timestamp",
        "has_spans": false,
        "is_searchable": true,
        "fields": [
          {
            "name": "project_id",
            "type": "string"
          },
          {
            "name": "unique_id",
            "type": "string"
          },
          {
            "name": "trace_unique_id",
            "type": "string"
          },
          {
            "name": "span_unique_id",
            "type": "string"
          }
        ],
        "relations": [
          {
            "name": "trace",
            "entity": "traces",
            "is_by_name": false
          }
        ]
      }
    ],
    "functions": [
      {
        "name": "if",
        "params": [
          "boolean",
          "any",
          "any"
        ],
        "optional": 0,
        "rest": null,
        "returns": {
          "shared_by_arguments_from": 2
        }
      },
      {
        "name": "coalesce",
        "params": [
          "any"
        ],
        "optional": 0,
        "rest": "any",
        "returns": {
          "shared_by_arguments_from": 1
        }
      }
    ],
    "aggregates": [
      {
        "name": "count",
        "least": 0,
        "most": 1
      },
      {
        "name": "count_distinct",
        "least": 1,
        "most": null
      },
      {
        "name": "sum",
        "least": 1,
        "most": 1
      }
    ],
    "special": [
      {
        "name": "bucket",
        "call": "bucket(time, interval?) | bucket(number, width)",
        "description": "The start of the bucket a value falls in. Without an interval, about a hundred buckets over the window."
      }
    ]
  }
}
```


## Responses

### 200

The query catalog.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Reference: `#/components/schemas/RqlSchema` |
| `entities` | `array<object>` | Required in parent | Every entity a query can read from. |
| `entities[]` | `object` | Array item | - |
| `entities[].name` | `string` | Optional | - |
| `entities[].time` | `string` | Optional | The entity's time field, which the time range applies to. |
| `entities[].has_spans` | `boolean` | Optional | Whether `any_span` and `span_count` work on the entity. |
| `entities[].is_searchable` | `boolean` | Optional | Whether `search(text)` works on the entity. |
| `entities[].fields` | `array<object>` | Optional | - |
| `entities[].fields[]` | `object` | Array item | - |
| `entities[].fields[].name` | `string` | Required in parent | - |
| `entities[].fields[].type` | `string` | Required in parent | - |
| `entities[].fields[].is_lookup` | `boolean` | Optional | - |
| `entities[].relations` | `array<object>` | Optional | - |
| `entities[].relations[]` | `object` | Array item | - |
| `entities[].relations[].name` | `string` | Optional | Prefix used in a query, as in `trace.name`. |
| `entities[].relations[].entity` | `string` | Optional | - |
| `entities[].relations[].is_by_name` | `boolean` | Optional | - |
| `functions` | `array<object>` | Required in parent | - |
| `functions[]` | `object` | Array item | - |
| `functions[].name` | `string` | Optional | - |
| `functions[].params` | `array<string>` | Optional | - |
| `functions[].params[]` | `string` | Array item | - |
| `functions[].optional` | `integer` | Optional | - |
| `functions[].rest` | `string or null` | Optional | - |
| `functions[].returns` | `string or object` | Optional | A type name, or how the return type follows the arguments. |
| `functions[].returns (oneOf 1)` | `string` | Schema variant | - |
| `functions[].returns (oneOf 2)` | `object` | Schema variant | Additional properties are allowed |
| `aggregates` | `array<object>` | Required in parent | - |
| `aggregates[]` | `object` | Array item | - |
| `aggregates[].name` | `string` | Optional | - |
| `aggregates[].least` | `integer` | Optional | Fewest arguments. |
| `aggregates[].most` | `integer or null` | Optional | Most arguments. Null means no limit. |
| `special` | `array<object>` | Required in parent | - |
| `special[]` | `object` | Array item | - |
| `special[].name` | `string` | Optional | - |
| `special[].call` | `string` | Optional | - |
| `special[].description` | `string` | Optional | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "$ref": "#/components/schemas/RqlSchema"
}
```

</details>

### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Get the RQL schema",
  "operationId": "getRqlSchema",
  "tags": [
    "Query"
  ],
  "description": "Returns what an RQL query can name: every entity with its fields, types and relations, every function with its arguments, the aggregates and the special functions. It holds no project data, so it is the same for every caller. The SQL editor's Entities panel reads the same catalog.",
  "responses": {
    "200": {
      "description": "The query catalog.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/RqlSchema"
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    }
  },
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "x-fern-examples": [
    {
      "name": "Query catalog",
      "description": "Trimmed from a live call on 2026-11-23: one entity with four of its fields, and the first entries of each list.",
      "response": {
        "body": {
          "entities": [
            {
              "name": "spans",
              "time": "timestamp",
              "has_spans": false,
              "is_searchable": true,
              "fields": [
                {
                  "name": "project_id",
                  "type": "string"
                },
                {
                  "name": "unique_id",
                  "type": "string"
                },
                {
                  "name": "trace_unique_id",
                  "type": "string"
                },
                {
                  "name": "span_unique_id",
                  "type": "string"
                }
              ],
              "relations": [
                {
                  "name": "trace",
                  "entity": "traces",
                  "is_by_name": false
                }
              ]
            }
          ],
          "functions": [
            {
              "name": "if",
              "params": [
                "boolean",
                "any",
                "any"
              ],
              "optional": 0,
              "rest": null,
              "returns": {
                "shared_by_arguments_from": 2
              }
            },
            {
              "name": "coalesce",
              "params": [
                "any"
              ],
              "optional": 0,
              "rest": "any",
              "returns": {
                "shared_by_arguments_from": 1
              }
            }
          ],
          "aggregates": [
            {
              "name": "count",
              "least": 0,
              "most": 1
            },
            {
              "name": "count_distinct",
              "least": 1,
              "most": null
            },
            {
              "name": "sum",
              "least": 1,
              "most": 1
            }
          ],
          "special": [
            {
              "name": "bucket",
              "call": "bucket(time, interval?) | bucket(number, width)",
              "description": "The start of the bucket a value falls in. Without an interval, about a hundred buckets over the window."
            }
          ]
        }
      }
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "schemas": {
    "RqlSchema": {
      "type": "object",
      "required": [
        "entities",
        "functions",
        "aggregates",
        "special"
      ],
      "properties": {
        "entities": {
          "type": "array",
          "description": "Every entity a query can read from.",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "time": {
                "type": "string",
                "description": "The entity's time field, which the time range applies to."
              },
              "has_spans": {
                "type": "boolean",
                "description": "Whether `any_span` and `span_count` work on the entity."
              },
              "is_searchable": {
                "type": "boolean",
                "description": "Whether `search(text)` works on the entity."
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "type"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "is_lookup": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "relations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Prefix used in a query, as in `trace.name`."
                    },
                    "entity": {
                      "type": "string"
                    },
                    "is_by_name": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "functions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "params": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "optional": {
                "type": "integer"
              },
              "rest": {
                "type": "string",
                "nullable": true
              },
              "returns": {
                "description": "A type name, or how the return type follows the arguments.",
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "additionalProperties": true
                  }
                ]
              }
            }
          }
        },
        "aggregates": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "least": {
                "type": "integer",
                "description": "Fewest arguments."
              },
              "most": {
                "type": "integer",
                "nullable": true,
                "description": "Most arguments. Null means no limit."
              }
            }
          }
        },
        "special": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "call": {
                "type": "string"
              },
              "description": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
