# Get the Analytics Query Grammar

`GET https://api.suger.cloud/ai/org/{orgId}/analytics/grammar`

Gets the grammar of an analytics query, as types with a line for each part and each op, and worked example queries over the datasets the caller can query. Write a query in it, naming only what GetAnalyticsDataset lists, and check it with DescribeAnalyticsQuery before running it.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgId` | path | string | yes | Organization ID |

## Responses

### 200 — The grammar

Content-Type: `application/json` · Schema: `AnalyticsQueryGrammar`

**`AnalyticsQueryGrammar`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `grammar` | string | yes | The grammar of a query, as types: a line for the query, each part it names and each op, with what each means. |
| `examples` | array<object> | yes |  |

### 401 — No valid token

Content-Type: `application/json` · Schema: `AiErrorResponse`

**`AiErrorResponse`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | string | yes | Error message |

### 403 — Not a member of the organization

Content-Type: `application/json` · Schema: `AiErrorResponse`

**`AiErrorResponse`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | string | yes | Error message |

### 500 — ANALYTICS_UNAVAILABLE: an unexpected failure

Content-Type: `application/json` · Schema: `AnalyticsError`

**`AnalyticsError`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | object | yes |  |

### 503 — ANALYTICS_UNAVAILABLE: analytics is not configured or not ready

Content-Type: `application/json` · Schema: `AnalyticsError`

**`AnalyticsError`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | object | yes |  |

## Example

_Generated from this operation's schema. Values are placeholders — substitute your own ids, and set `SUGER_TOKEN` to a bearer token from the [OAuth client-credentials exchange](https://doc.fours.com/settings/oauth-app/)._

### Request

```bash
curl -X GET 'https://api.suger.cloud/ai/org/{orgId}/analytics/grammar' \
  -H "Authorization: Bearer $SUGER_TOKEN"
```

### Response — 200

```json
{
  "grammar": "string",
  "examples": [
    {
      "description": "string",
      "query": {}
    }
  ]
}
```

### Error — 401

```json
{
  "error": "string"
}
```

---

API reference: https://doc.fours.com/api/
