# Discover the queryable LangWatchQL schema

Lists the LangWatchQL analytics views this key may query, with each column's type, description, the permissions that unlock it, and whether this caller holds them — plus each view's grain, join keys, partition-pruning time column, freshness and a runnable example query. It also lists, under `functions`, every function name a query may call.

Under `appFunctions` it lists the app functions a projection may call, each with its signature, the type and encoding of the value it returns, how many distinct keys one run may read, and the permissions it needs.

Scoped to the projects the credential can read and their permissions: a column or app function this key cannot read in every one of them is listed with `available: false` rather than hidden, so a caller can see what a wider key would unlock.

Any LangWatch API key — project, organization or personal — reaches every project it can read `analytics:view` on: an organization or personal key spans its projects, a project key its one. Rows from more than one project come back flagged with the `MULTI_PROJECT_RESULT` diagnostic — to read a single project, filter inside the statement with `WHERE TenantId = '<project id>'`.

> Page: https://langwatch.ai/docs/api-reference/query/discover-the-queryable-langwatchql-schema
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/query/discover-the-queryable-langwatchql-schema.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`GET https://app.langwatch.ai/api/v1/query/schema`

## Authentication

### project_api_key

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Request example

```bash
curl --request GET \
  --url 'https://app.langwatch.ai/api/v1/query/schema' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY"
```

## Responses

### 200

The views and columns this key may query, with the permissions that unlock each one.

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "database": {"type":"string"},
    "functions": {"readOnly":true,"type":"array","items":{"type":"string"}},
    "views": {
      "readOnly": true,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {"type":"string"},
          "description": {"type":"string"},
          "grain": {"type":"string"},
          "joinKeys": {"readOnly":true,"type":"array","items":{"type":"string"}},
          "timeColumn": {"type":["string","null"]},
          "freshness": {"type":"string"},
          "columns": {
            "readOnly": true,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {"type":"string"},
                "type": {"type":"string"},
                "description": {"type":"string"},
                "unit": {"type":["string","null"]},
                "gates": {
                  "readOnly": true,
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {"type":"string","enum":["input","output","costs"]},
                      {
                        "type": "string",
                        "enum": [
                          "organization:view",
                          "organization:manage",
                          "organization:delete",
                          "project:view",
                          "project:create",
                          "project:update",
                          "project:delete",
                          "project:manage",
                          "team:view",
                          "team:manage",
                          "analytics:view",
                          "analytics:create",
                          "analytics:update",
                          "analytics:delete",
                          "analytics:manage",
                          "cost:view",
                          "traces:view",
                          "traces:create",
                          "traces:update",
                          "traces:share",
                          "scenarios:view",
                          "scenarios:create",
                          "scenarios:update",
                          "scenarios:delete",
                          "scenarios:manage",
                          "annotations:view",
                          "annotations:create",
                          "annotations:update",
                          "annotations:delete",
                          "annotations:manage",
                          "evaluations:view",
                          "evaluations:create",
                          "evaluations:update",
                          "evaluations:delete",
                          "evaluations:manage",
                          "datasets:view",
                          "datasets:create",
                          "datasets:update",
                          "datasets:delete",
                          "datasets:manage",
                          "triggers:view",
                          "triggers:create",
                          "triggers:update",
                          "triggers:delete",
                          "triggers:manage",
                          "workflows:view",
                          "workflows:create",
                          "workflows:update",
                          "workflows:delete",
                          "workflows:manage",
                          "experiments:view",
                          "experiments:create",
                          "experiments:update",
                          "experiments:delete",
                          "experiments:manage",
                          "prompts:view",
                          "prompts:create",
                          "prompts:update",
                          "prompts:delete",
                          "prompts:manage",
                          "secrets:view",
                          "secrets:create",
                          "secrets:update",
                          "secrets:delete",
                          "secrets:manage",
                          "playground:view",
                          "playground:create",
                          "playground:update",
                          "playground:delete",
                          "playground:manage",
                          "ops:view",
                          "ops:manage",
                          "auditLog:view",
                          "virtualKeys:view",
                          "virtualKeys:create",
                          "virtualKeys:update",
                          "virtualKeys:delete",
                          "virtualKeys:rotate",
                          "virtualKeys:manage",
                          "virtualKeys:viewOtherPersonal",
                          "gatewayBudgets:view",
                          "gatewayBudgets:create",
                          "gatewayBudgets:update",
                          "gatewayBudgets:delete",
                          "gatewayBudgets:manage",
                          "gatewayProviders:view",
                          "gatewayProviders:update",
                          "gatewayProviders:manage",
                          "routingPolicies:view",
                          "routingPolicies:manage",
                          "gatewayGuardrails:view",
                          "gatewayGuardrails:attach",
                          "gatewayGuardrails:detach",
                          "gatewayGuardrails:manage",
                          "gatewayLogs:view",
                          "gatewayUsage:view",
                          "gatewayCacheRules:view",
                          "gatewayCacheRules:create",
                          "gatewayCacheRules:update",
                          "gatewayCacheRules:delete",
                          "gatewayCacheRules:manage",
                          "governance:view",
                          "governance:manage",
                          "ingestionSources:view",
                          "ingestionSources:create",
                          "ingestionSources:update",
                          "ingestionSources:delete",
                          "ingestionSources:manage",
                          "anomalyRules:view",
                          "anomalyRules:create",
                          "anomalyRules:update",
                          "anomalyRules:delete",
                          "anomalyRules:manage",
                          "complianceExport:view",
                          "activityMonitor:view",
                          "aiTools:view",
                          "aiTools:manage",
                          "webhookEndpoints:view",
                          "webhookEndpoints:manage",
                          "gatewaySpend:view",
                          "gatewaySpend:manage",
                          "langy:view",
                          "langy:create",
                          "langy:update",
                          "langy:delete",
                          "langy:manage",
                          "agentCache:view",
                          "agentCache:manage",
                          "featureFlags:manageExperiments",
                          "governanceCost:view",
                          "sso:view",
                          "sso:manage",
                          "agents:deploy",
                          "evaluators:deploy",
                          "subscription:upgrade",
                          "subscription:manage",
                          "seatRequests:view",
                          "seatRequests:manage",
                          "members:view",
                          "braids:manage",
                          "spans:braided",
                          "gatewayA2aTargets:view",
                          "gatewayA2aTargets:manage",
                          "opsRead:view",
                          "opsCopy:create"
                        ]
                      }
                    ]
                  }
                },
                "available": {"type":"boolean"}
              },
              "required": ["name","type","description","unit","gates","available"],
              "additionalProperties": false
            }
          },
          "exampleSql": {"type":"string"}
        },
        "required": [
          "name",
          "description",
          "grain",
          "joinKeys",
          "timeColumn",
          "freshness",
          "columns",
          "exampleSql"
        ],
        "additionalProperties": false
      }
    },
    "appFunctions": {
      "readOnly": true,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {"type":"string"},
          "signature": {"type":"string"},
          "description": {"type":"string"},
          "returns": {"type":"string"},
          "encoding": {"type":"string"},
          "keyKind": {"type":"string"},
          "kind": {"type":"string","enum":["extraction","eval"]},
          "cap": {"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},
          "gates": {
            "readOnly": true,
            "type": "array",
            "items": {
              "anyOf": [
                {"type":"string","enum":["input","output","costs"]},
                {
                  "type": "string",
                  "enum": [
                    "organization:view",
                    "organization:manage",
                    "organization:delete",
                    "project:view",
                    "project:create",
                    "project:update",
                    "project:delete",
                    "project:manage",
                    "team:view",
                    "team:manage",
                    "analytics:view",
                    "analytics:create",
                    "analytics:update",
                    "analytics:delete",
                    "analytics:manage",
                    "cost:view",
                    "traces:view",
                    "traces:create",
                    "traces:update",
                    "traces:share",
                    "scenarios:view",
                    "scenarios:create",
                    "scenarios:update",
                    "scenarios:delete",
                    "scenarios:manage",
                    "annotations:view",
                    "annotations:create",
                    "annotations:update",
                    "annotations:delete",
                    "annotations:manage",
                    "evaluations:view",
                    "evaluations:create",
                    "evaluations:update",
                    "evaluations:delete",
                    "evaluations:manage",
                    "datasets:view",
                    "datasets:create",
                    "datasets:update",
                    "datasets:delete",
                    "datasets:manage",
                    "triggers:view",
                    "triggers:create",
                    "triggers:update",
                    "triggers:delete",
                    "triggers:manage",
                    "workflows:view",
                    "workflows:create",
                    "workflows:update",
                    "workflows:delete",
                    "workflows:manage",
                    "experiments:view",
                    "experiments:create",
                    "experiments:update",
                    "experiments:delete",
                    "experiments:manage",
                    "prompts:view",
                    "prompts:create",
                    "prompts:update",
                    "prompts:delete",
                    "prompts:manage",
                    "secrets:view",
                    "secrets:create",
                    "secrets:update",
                    "secrets:delete",
                    "secrets:manage",
                    "playground:view",
                    "playground:create",
                    "playground:update",
                    "playground:delete",
                    "playground:manage",
                    "ops:view",
                    "ops:manage",
                    "auditLog:view",
                    "virtualKeys:view",
                    "virtualKeys:create",
                    "virtualKeys:update",
                    "virtualKeys:delete",
                    "virtualKeys:rotate",
                    "virtualKeys:manage",
                    "virtualKeys:viewOtherPersonal",
                    "gatewayBudgets:view",
                    "gatewayBudgets:create",
                    "gatewayBudgets:update",
                    "gatewayBudgets:delete",
                    "gatewayBudgets:manage",
                    "gatewayProviders:view",
                    "gatewayProviders:update",
                    "gatewayProviders:manage",
                    "routingPolicies:view",
                    "routingPolicies:manage",
                    "gatewayGuardrails:view",
                    "gatewayGuardrails:attach",
                    "gatewayGuardrails:detach",
                    "gatewayGuardrails:manage",
                    "gatewayLogs:view",
                    "gatewayUsage:view",
                    "gatewayCacheRules:view",
                    "gatewayCacheRules:create",
                    "gatewayCacheRules:update",
                    "gatewayCacheRules:delete",
                    "gatewayCacheRules:manage",
                    "governance:view",
                    "governance:manage",
                    "ingestionSources:view",
                    "ingestionSources:create",
                    "ingestionSources:update",
                    "ingestionSources:delete",
                    "ingestionSources:manage",
                    "anomalyRules:view",
                    "anomalyRules:create",
                    "anomalyRules:update",
                    "anomalyRules:delete",
                    "anomalyRules:manage",
                    "complianceExport:view",
                    "activityMonitor:view",
                    "aiTools:view",
                    "aiTools:manage",
                    "webhookEndpoints:view",
                    "webhookEndpoints:manage",
                    "gatewaySpend:view",
                    "gatewaySpend:manage",
                    "langy:view",
                    "langy:create",
                    "langy:update",
                    "langy:delete",
                    "langy:manage",
                    "agentCache:view",
                    "agentCache:manage",
                    "featureFlags:manageExperiments",
                    "governanceCost:view",
                    "sso:view",
                    "sso:manage",
                    "agents:deploy",
                    "evaluators:deploy",
                    "subscription:upgrade",
                    "subscription:manage",
                    "seatRequests:view",
                    "seatRequests:manage",
                    "members:view",
                    "braids:manage",
                    "spans:braided",
                    "gatewayA2aTargets:view",
                    "gatewayA2aTargets:manage",
                    "opsRead:view",
                    "opsCopy:create"
                  ]
                }
              ]
            }
          },
          "available": {"type":"boolean"},
          "exampleSql": {"type":"string"}
        },
        "required": [
          "name",
          "signature",
          "description",
          "returns",
          "encoding",
          "keyKind",
          "kind",
          "cap",
          "gates",
          "available",
          "exampleSql"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": ["database","functions","views","appFunctions"],
  "additionalProperties": false
}
```

### 400

Bad Request

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "type": {"type":"string"},
    "code": {"type":"string"},
    "message": {"type":"string"},
    "retryable": {"type":"boolean"},
    "meta": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {}
    },
    "trace_id": {"type":"string"},
    "span_id": {"type":"string"},
    "trace": {
      "type": "object",
      "properties": {
        "traceId": {"type":"string"},
        "spanId": {"type":"string"},
        "traceUrl": {"type":"string"},
        "logsUrl": {"type":"string"}
      }
    },
    "tips": {"type":"array","items":{"type":"string"}},
    "docs_url": {"type":"string"},
    "fault": {
      "type": "string",
      "enum": ["customer","platform","provider","presumed_platform"]
    },
    "reasons": {"type":"array","items":{}}
  },
  "required": ["type","code","message","retryable"]
}
```

### 401

Unauthorized

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "type": {"type":"string"},
    "code": {"type":"string"},
    "message": {"type":"string"},
    "retryable": {"type":"boolean"},
    "meta": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {}
    },
    "trace_id": {"type":"string"},
    "span_id": {"type":"string"},
    "trace": {
      "type": "object",
      "properties": {
        "traceId": {"type":"string"},
        "spanId": {"type":"string"},
        "traceUrl": {"type":"string"},
        "logsUrl": {"type":"string"}
      }
    },
    "tips": {"type":"array","items":{"type":"string"}},
    "docs_url": {"type":"string"},
    "fault": {
      "type": "string",
      "enum": ["customer","platform","provider","presumed_platform"]
    },
    "reasons": {"type":"array","items":{}}
  },
  "required": ["type","code","message","retryable"]
}
```

### 403

Forbidden

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "type": {"type":"string"},
    "code": {"type":"string"},
    "message": {"type":"string"},
    "retryable": {"type":"boolean"},
    "meta": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {}
    },
    "trace_id": {"type":"string"},
    "span_id": {"type":"string"},
    "trace": {
      "type": "object",
      "properties": {
        "traceId": {"type":"string"},
        "spanId": {"type":"string"},
        "traceUrl": {"type":"string"},
        "logsUrl": {"type":"string"}
      }
    },
    "tips": {"type":"array","items":{"type":"string"}},
    "docs_url": {"type":"string"},
    "fault": {
      "type": "string",
      "enum": ["customer","platform","provider","presumed_platform"]
    },
    "reasons": {"type":"array","items":{}}
  },
  "required": ["type","code","message","retryable"]
}
```

### 500

Internal Server Error

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "type": {"type":"string"},
    "code": {"type":"string"},
    "message": {"type":"string"},
    "retryable": {"type":"boolean"},
    "meta": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {}
    },
    "trace_id": {"type":"string"},
    "span_id": {"type":"string"},
    "trace": {
      "type": "object",
      "properties": {
        "traceId": {"type":"string"},
        "spanId": {"type":"string"},
        "traceUrl": {"type":"string"},
        "logsUrl": {"type":"string"}
      }
    },
    "tips": {"type":"array","items":{"type":"string"}},
    "docs_url": {"type":"string"},
    "fault": {
      "type": "string",
      "enum": ["customer","platform","provider","presumed_platform"]
    },
    "reasons": {"type":"array","items":{}}
  },
  "required": ["type","code","message","retryable"]
}
```

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
