> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.athenaintel.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.athenaintel.com/_mcp/server.

# Query Semantic Model

POST https://api.athenaintel.com/api/v0/semantic-model/{asset_id}/query
Content-Type: application/json

Execute a metric query against a semantic model. Specify measures, optional dimensions, filters, and time dimensions. Returns structured data rows.

Reference: https://docs.athenaintel.com/api-reference/semantic-model/query

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Path parameters

- `asset_id` (string, required)

### Body (application/json)

This endpoint expects a SemanticModelQueryRequestIn.

- `measures` (list of string, required) — List of measure identifiers, e.g. ["orders.total_revenue"]
- `dimensions` (list of string, optional, nullable) — Optional dimension identifiers for grouping
- `filters` (list of map from string to any, optional, nullable) — Optional filters
- `limit` (integer, optional, default: 100) — Maximum rows to return (default 100). When the result was cut at this limit the response sets "truncated": true.
- `order` (list of SemanticModelQueryRequestInOrderItems, optional, nullable) — Optional ordering as \[member, direction] pairs applied before "limit", e.g. \[\["orders.count", "desc"]] for a server-side top-N. Direction must be "asc" or "desc". Entries may also be given as \{"member": "orders.count", "direction": "desc"} objects.
- `time_dimensions` (list of map from string to any, optional, nullable) — Optional Cube time dimension configs, e.g. \[\{"dimension": "orders.created\_at", "granularity": "month", "dateRange": \["2026-01-01", "2026-06-30"]}]. The camelCase spelling "timeDimensions" (Cube's own, and the one the rest of Athena uses) is accepted as well.

## Response

### 200

Successful Response

- `data` (list of map from string to any, required) — Query result rows
- `row_count` (integer, required) — Number of rows returned
- `as_of_kind` (string, optional, nullable) — 'snapshot' when 'data_as_of' comes from the source tables' Iceberg snapshots (lakehouse-backed models); 'query_time' when the data is as current as the moment the warehouse answered ('queried_at').
- `data_as_of` (string, optional, nullable) — ISO-8601 UTC time the data is current as of. For a lakehouse-backed model: the oldest last-commit time across the model's source tables. Null for models over other engines (Snowflake, Databricks, BigQuery, Postgres), which expose no snapshot, and for rows the engine served from a cache computed before a source table's latest commit — use 'queried_at' instead.
- `elapsed_ms` (integer, optional, default: 0) — Server-side execution time in milliseconds (semantic layer + engine, excluding network) — surface it to show how fast the engine answered
- `queried_at` (string, optional, nullable) — ISO-8601 UTC time the engine computed the result (an earlier time when it was served from the engine's cache).
- `schema_hash` (string, optional, nullable) — Hash of the deployed semantic model definition that computed the rows (the same value the model's citations record); null for a model that was never deployed.
- `schema_version` (integer, optional, nullable) — Deployment number of the semantic model definition that computed the rows; null for a model that was never deployed.
- `source_snapshots` (list of SemanticModelSourceSnapshotOut, optional, nullable) — For a lakehouse-backed model, the Iceberg snapshot of each source table the returned rows reflect; empty for models over other engines and when the rows were computed before a source table's latest commit.
- `truncated` (boolean, optional, default: false) — True when the query produced more rows than 'limit' and the result was cut; raise 'limit' or add filters to see the rest

## Errors

### 401 Unauthorized Error

Unauthorized

- `message` (string, required)

### 403 Forbidden Error

Forbidden

- `any`

### 404 Not Found Error

Not Found

- `message` (string, required)

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

### 502 Bad Gateway Error

Bad Gateway

- `message` (string, required)

## Types

### SemanticModelQueryRequestInOrderItems

### SemanticModelSourceSnapshotOut

One source table's Iceberg state when a semantic model query ran.

- `namespace` (string, required) — Lakehouse namespace of the table
- `table` (string, required) — Table name
- `table_uuid` (string, required) — Iceberg table UUID (stable identity)
- `committed_at` (string, optional, nullable) — ISO-8601 UTC commit time of that snapshot
- `snapshot_id` (string, optional, nullable) — Current Iceberg snapshot id; null for a table never written

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### SemanticModelOrderEntry

Object form of an order entry; normalized to a [member, direction] pair.

- `member` (string, required) — Measure or dimension to sort by
- `direction` (string, optional, default: asc) — "asc" or "desc"

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "measures": [
    "orders.count",
    "orders.total_revenue"
  ]
}
```

**Response**

```json
{
  "data": [
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {}
  ],
  "row_count": 1,
  "as_of_kind": "snapshot",
  "data_as_of": "2024-06-15T00:00:00Z",
  "elapsed_ms": 123,
  "queried_at": "2024-06-15T12:34:56Z",
  "schema_hash": "a1b2c3d4e5f67890",
  "schema_version": 42,
  "source_snapshots": [
    {
      "namespace": "sales_data",
      "table": "orders",
      "table_uuid": "123e4567-e89b-12d3-a456-426614174000",
      "committed_at": "2024-06-14T23:59:59Z",
      "snapshot_id": "snapshot-20240614-235959"
    }
  ],
  "truncated": false
}
```

**SDK Code**

```python
import requests

url = "https://api.athenaintel.com/api/v0/semantic-model/asset_id/query"

payload = { "measures": ["orders.count", "orders.total_revenue"] }
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.athenaintel.com/api/v0/semantic-model/asset_id/query';
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"measures":["orders.count","orders.total_revenue"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.athenaintel.com/api/v0/semantic-model/asset_id/query"

	payload := strings.NewReader("{\n  \"measures\": [\n    \"orders.count\",\n    \"orders.total_revenue\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.athenaintel.com/api/v0/semantic-model/asset_id/query")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"measures\": [\n    \"orders.count\",\n    \"orders.total_revenue\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.athenaintel.com/api/v0/semantic-model/asset_id/query")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"measures\": [\n    \"orders.count\",\n    \"orders.total_revenue\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.athenaintel.com/api/v0/semantic-model/asset_id/query', [
  'body' => '{
  "measures": [
    "orders.count",
    "orders.total_revenue"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.athenaintel.com/api/v0/semantic-model/asset_id/query");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"measures\": [\n    \"orders.count\",\n    \"orders.total_revenue\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["measures": ["orders.count", "orders.total_revenue"]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.athenaintel.com/api/v0/semantic-model/asset_id/query")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```