---
title: "Query Validation"
method: POST
path: "/api/query/_validate"
tags: ["Query"]
---

# Query Validation

`POST /api/query/_validate`

## Request

- Base URL: `https://api.lytics.io`
- URL: `https://api.lytics.io/api/query/_validate`
- Auth: API key in header `Authorization`

Upload a query for syntax validation only.

Optionally, a *segments=true* parameter can be passed that
will validate this query both for syntax, as well as checking
that it doesn't invalidate existing segments.  If a segment
uses a field that this query is about to remove/alter such
that the segment is no longer valid, this will warn.

```sh

# validate query syntax
curl -s -XPOST "https://api.lytics.io/api/query/_validate" \
   -H "Authorization: $LIOKEY" \
   -H "Content-Type: text/plain" \
   --data-binary @your_file.lql

# validate query syntax AND segments still valid
curl -s -XPOST "https://api.lytics.io/api/query/_validate?segments=true" \
   -H "Authorization: $LIOKEY" \
   -H "Content-Type: text/plain" \
   --data-binary @your_file.lql

```

## Query parameters

- `account_id` string
- `version` string

## Response `200`

OK

- QueryModel
  - `status` string
  - `data` object
    - `id` string
    - `updated` string
    - `created` string
    - `text` string

---

[API](https://skmtc.dev/lytics/apis/v1-lytics-api.md) - [All operations](https://skmtc.dev/lytics/apis/v1-lytics-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lytics/apis/v1-lytics-api/revisions/339fd1d88486?raw)
