curl --request POST \
--url https://api-dev.narrative.io/nql/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"nql": "CREATE MATERIALIZED VIEW \"dataset_name\" AS SELECT \"company_data\".\"1\".x AS xx, \"company_data\".\"1\".y AS yy, \"company_data\".\"1\".z AS zz, \"company_data\".\"1\".x + \"company_data\".\"1\".y + \"company_data\".\"1\".z AS xyz_sum FROM \"company_data\".\"1\""
}
'{
"id": "7352a290-dea9-4932-b7d3-66723e145259",
"company_id": 1,
"completed_at": null,
"created_at": "2025-04-14T17:33:24.941123Z",
"failures": [],
"idempotency_key": "3c7afdbb-1b2a-458b-a8bf-ac7b7942cb6c",
"input": {
"compiled_select": "SELECT\n *\nFROM\n (VALUES\n (1, 2)) `t` (`a`, `b`)",
"create_as_view": false,
"dataset": {
"id": 23499,
"company_id": 1,
"created_at": "2025-04-14T17:33:23.500965Z",
"data_plane": {
"type": "owned",
"id": "f79cbdae-4848-47ca-95e8-69588364d185",
"company_id": 1,
"created_at": "2016-01-01T00:00:00Z",
"description": "...",
"display_name": "Narrative Data Collaboration Platform (us-east-1)",
"external_id": "704349335716",
"platform": {
"type": "platform_aws",
"account_id": "704349335716",
"region": {
"type": "region_aws",
"id": "us-east-1"
}
},
"status": "active",
"updated_at": "2024-01-12T00:00:00Z",
"collaborators": {
"participants": {
"type": "all"
}
}
},
"display_name": "test_gui",
"is_narrative_managed": true,
"materialized_view_config": {
"nql": "SELECT 1 AS a, 2 AS b"
},
"name": "test_gui",
"retention_policy": {
"type": "retain_everything"
},
"schema": {
"file_config": {
"type": "json"
},
"type": "object",
"properties": {
"a": {
"display_name": "a",
"type": "long"
},
"b": {
"display_name": "b",
"type": "long"
}
}
},
"status": "pending",
"tags": [
"_nio_materialized_view"
],
"updated_at": "2025-04-14T17:33:23.500965Z",
"write_mode": "append"
},
"nql": "SELECT 1 AS a, 2 AS b"
},
"request_source": {
"type": "api_user",
"company_id": 1,
"user_id": 1414
},
"result": null,
"state": "pending",
"updated_at": "2025-04-14T17:33:24.941123Z"
}The run endpoint in the NQL API allows users to execute their NQL queries. This endpoint processes the query and performs the specified operations within the specified data plane. Depending on the NQL provided, the run endpoint can create materialized views or generate forecasts.
curl --request POST \
--url https://api-dev.narrative.io/nql/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"nql": "CREATE MATERIALIZED VIEW \"dataset_name\" AS SELECT \"company_data\".\"1\".x AS xx, \"company_data\".\"1\".y AS yy, \"company_data\".\"1\".z AS zz, \"company_data\".\"1\".x + \"company_data\".\"1\".y + \"company_data\".\"1\".z AS xyz_sum FROM \"company_data\".\"1\""
}
'{
"id": "7352a290-dea9-4932-b7d3-66723e145259",
"company_id": 1,
"completed_at": null,
"created_at": "2025-04-14T17:33:24.941123Z",
"failures": [],
"idempotency_key": "3c7afdbb-1b2a-458b-a8bf-ac7b7942cb6c",
"input": {
"compiled_select": "SELECT\n *\nFROM\n (VALUES\n (1, 2)) `t` (`a`, `b`)",
"create_as_view": false,
"dataset": {
"id": 23499,
"company_id": 1,
"created_at": "2025-04-14T17:33:23.500965Z",
"data_plane": {
"type": "owned",
"id": "f79cbdae-4848-47ca-95e8-69588364d185",
"company_id": 1,
"created_at": "2016-01-01T00:00:00Z",
"description": "...",
"display_name": "Narrative Data Collaboration Platform (us-east-1)",
"external_id": "704349335716",
"platform": {
"type": "platform_aws",
"account_id": "704349335716",
"region": {
"type": "region_aws",
"id": "us-east-1"
}
},
"status": "active",
"updated_at": "2024-01-12T00:00:00Z",
"collaborators": {
"participants": {
"type": "all"
}
}
},
"display_name": "test_gui",
"is_narrative_managed": true,
"materialized_view_config": {
"nql": "SELECT 1 AS a, 2 AS b"
},
"name": "test_gui",
"retention_policy": {
"type": "retain_everything"
},
"schema": {
"file_config": {
"type": "json"
},
"type": "object",
"properties": {
"a": {
"display_name": "a",
"type": "long"
},
"b": {
"display_name": "b",
"type": "long"
}
}
},
"status": "pending",
"tags": [
"_nio_materialized_view"
],
"updated_at": "2025-04-14T17:33:23.500965Z",
"write_mode": "append"
},
"nql": "SELECT 1 AS a, 2 AS b"
},
"request_source": {
"type": "api_user",
"company_id": 1,
"user_id": 1414
},
"result": null,
"state": "pending",
"updated_at": "2025-04-14T17:33:24.941123Z"
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
A NQL query.
A dataplane represent where you would run the query. Your query get compiled to the SQL dialect that your data engine understands. If you leave it blank, your query will target Narrative's dataplane on AWS using Apache Spark. We currently support Snowflake and we plan to support other dataplanes in the future. See https://next.narrative.io/products/narrative-anywhere for more details.
Created
Unique identifier for the job.
Company that ran the job.
The timestamp representing when the job finished.
The timestamp representing when the job was created.
causes of job failure
Show child attributes
The unique ID associated with the job.
Show child attributes
{
"type": "api_user",
"company_id": 1,
"user_id": 1248
}failed, cancelled, completed, pending, running The timestamp representing when the job was updated.
The query and it's compiled sql sent to the executor.
Show child attributes
Show child attributes