curl --request POST \
--url https://api-dev.narrative.io/workflows \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"specification": "document:\n dsl: '1.0.0'\n namespace: test\n name: test-workflow\n version: '1.0.0'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"\n",
"data_plane_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
"trigger_immediately": false,
"schedule_immediately": false,
"tags": [
"<string>"
]
}
EOFimport requests
url = "https://api-dev.narrative.io/workflows"
payload = {
"specification": "document:
dsl: '1.0.0'
namespace: test
name: test-workflow
version: '1.0.0'
do:
- createView:
call: CreateMaterializedViewIfNotExists
with:
nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"
- refreshView:
call: RefreshMaterializedView
with:
datasetName: workflow_output
- insertData:
call: ExecuteDml
with:
nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"
",
"data_plane_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
"trigger_immediately": False,
"schedule_immediately": False,
"tags": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
specification: 'document:\n dsl: \'1.0.0\'\n namespace: test\n name: test-workflow\n version: \'1.0.0\'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: "CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: "INSERT INTO company_data.workflow_input (track_id) VALUES (\'test\')"\n',
data_plane_id: 'd1e2f3a4-b5c6-7890-abcd-ef1234567890',
trigger_immediately: false,
schedule_immediately: false,
tags: ['<string>']
})
};
fetch('https://api-dev.narrative.io/workflows', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/workflows",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'specification' => 'document:
dsl: \'1.0.0\'
namespace: test
name: test-workflow
version: \'1.0.0\'
do:
- createView:
call: CreateMaterializedViewIfNotExists
with:
nql: "CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input"
- refreshView:
call: RefreshMaterializedView
with:
datasetName: workflow_output
- insertData:
call: ExecuteDml
with:
nql: "INSERT INTO company_data.workflow_input (track_id) VALUES (\'test\')"
',
'data_plane_id' => 'd1e2f3a4-b5c6-7890-abcd-ef1234567890',
'trigger_immediately' => false,
'schedule_immediately' => false,
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/workflows"
payload := strings.NewReader("{\n \"specification\": \"document:\\n dsl: '1.0.0'\\n namespace: test\\n name: test-workflow\\n version: '1.0.0'\\ndo:\\n - createView:\\n call: CreateMaterializedViewIfNotExists\\n with:\\n nql: \\\"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\\\"\\n - refreshView:\\n call: RefreshMaterializedView\\n with:\\n datasetName: workflow_output\\n - insertData:\\n call: ExecuteDml\\n with:\\n nql: \\\"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\\\"\\n\",\n \"data_plane_id\": \"d1e2f3a4-b5c6-7890-abcd-ef1234567890\",\n \"trigger_immediately\": false,\n \"schedule_immediately\": false,\n \"tags\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/workflows")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"specification\": \"document:\\n dsl: '1.0.0'\\n namespace: test\\n name: test-workflow\\n version: '1.0.0'\\ndo:\\n - createView:\\n call: CreateMaterializedViewIfNotExists\\n with:\\n nql: \\\"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\\\"\\n - refreshView:\\n call: RefreshMaterializedView\\n with:\\n datasetName: workflow_output\\n - insertData:\\n call: ExecuteDml\\n with:\\n nql: \\\"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\\\"\\n\",\n \"data_plane_id\": \"d1e2f3a4-b5c6-7890-abcd-ef1234567890\",\n \"trigger_immediately\": false,\n \"schedule_immediately\": false,\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/workflows")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"specification\": \"document:\\n dsl: '1.0.0'\\n namespace: test\\n name: test-workflow\\n version: '1.0.0'\\ndo:\\n - createView:\\n call: CreateMaterializedViewIfNotExists\\n with:\\n nql: \\\"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\\\"\\n - refreshView:\\n call: RefreshMaterializedView\\n with:\\n datasetName: workflow_output\\n - insertData:\\n call: ExecuteDml\\n with:\\n nql: \\\"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\\\"\\n\",\n \"data_plane_id\": \"d1e2f3a4-b5c6-7890-abcd-ef1234567890\",\n \"trigger_immediately\": false,\n \"schedule_immediately\": false,\n \"tags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "my-etl-workflow",
"specification": "document:\n dsl: '1.0.0'\n namespace: test\n name: test-workflow\n version: '1.0.0'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"\n",
"data_plane_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
"company_id": 100,
"created_at": "2025-01-15T10:30:00Z",
"created_by": 20,
"updated_at": "2025-01-15T10:30:00Z",
"status": "active",
"tags": [
"<string>"
],
"archived_at": null,
"run_id": "b7e3f1a2-4c5d-6e7f-8a9b-0c1d2e3f4a5b"
}{
"type": null,
"title": "Failed to Parse Query",
"status": 400,
"detail": "Invalid query format.",
"instance": "/nql/validate",
"log_id": "c06fea02-0950-45c6-aaff-07ab07c0d04c",
"debug": null
}{
"type": null,
"title": "Failed to Parse Query",
"status": 400,
"detail": "Invalid query format.",
"instance": "/nql/validate",
"log_id": "c06fea02-0950-45c6-aaff-07ab07c0d04c",
"debug": null
}Create a workflow
Create a new workflow from a YAML specification. The specification is parsed and validated before the workflow is persisted.
Optionally, the workflow can be scheduled and/or triggered immediately upon creation
using the trigger_immediately and schedule_immediately request fields.
curl --request POST \
--url https://api-dev.narrative.io/workflows \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"specification": "document:\n dsl: '1.0.0'\n namespace: test\n name: test-workflow\n version: '1.0.0'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"\n",
"data_plane_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
"trigger_immediately": false,
"schedule_immediately": false,
"tags": [
"<string>"
]
}
EOFimport requests
url = "https://api-dev.narrative.io/workflows"
payload = {
"specification": "document:
dsl: '1.0.0'
namespace: test
name: test-workflow
version: '1.0.0'
do:
- createView:
call: CreateMaterializedViewIfNotExists
with:
nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"
- refreshView:
call: RefreshMaterializedView
with:
datasetName: workflow_output
- insertData:
call: ExecuteDml
with:
nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"
",
"data_plane_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
"trigger_immediately": False,
"schedule_immediately": False,
"tags": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
specification: 'document:\n dsl: \'1.0.0\'\n namespace: test\n name: test-workflow\n version: \'1.0.0\'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: "CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: "INSERT INTO company_data.workflow_input (track_id) VALUES (\'test\')"\n',
data_plane_id: 'd1e2f3a4-b5c6-7890-abcd-ef1234567890',
trigger_immediately: false,
schedule_immediately: false,
tags: ['<string>']
})
};
fetch('https://api-dev.narrative.io/workflows', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/workflows",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'specification' => 'document:
dsl: \'1.0.0\'
namespace: test
name: test-workflow
version: \'1.0.0\'
do:
- createView:
call: CreateMaterializedViewIfNotExists
with:
nql: "CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input"
- refreshView:
call: RefreshMaterializedView
with:
datasetName: workflow_output
- insertData:
call: ExecuteDml
with:
nql: "INSERT INTO company_data.workflow_input (track_id) VALUES (\'test\')"
',
'data_plane_id' => 'd1e2f3a4-b5c6-7890-abcd-ef1234567890',
'trigger_immediately' => false,
'schedule_immediately' => false,
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/workflows"
payload := strings.NewReader("{\n \"specification\": \"document:\\n dsl: '1.0.0'\\n namespace: test\\n name: test-workflow\\n version: '1.0.0'\\ndo:\\n - createView:\\n call: CreateMaterializedViewIfNotExists\\n with:\\n nql: \\\"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\\\"\\n - refreshView:\\n call: RefreshMaterializedView\\n with:\\n datasetName: workflow_output\\n - insertData:\\n call: ExecuteDml\\n with:\\n nql: \\\"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\\\"\\n\",\n \"data_plane_id\": \"d1e2f3a4-b5c6-7890-abcd-ef1234567890\",\n \"trigger_immediately\": false,\n \"schedule_immediately\": false,\n \"tags\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/workflows")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"specification\": \"document:\\n dsl: '1.0.0'\\n namespace: test\\n name: test-workflow\\n version: '1.0.0'\\ndo:\\n - createView:\\n call: CreateMaterializedViewIfNotExists\\n with:\\n nql: \\\"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\\\"\\n - refreshView:\\n call: RefreshMaterializedView\\n with:\\n datasetName: workflow_output\\n - insertData:\\n call: ExecuteDml\\n with:\\n nql: \\\"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\\\"\\n\",\n \"data_plane_id\": \"d1e2f3a4-b5c6-7890-abcd-ef1234567890\",\n \"trigger_immediately\": false,\n \"schedule_immediately\": false,\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/workflows")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"specification\": \"document:\\n dsl: '1.0.0'\\n namespace: test\\n name: test-workflow\\n version: '1.0.0'\\ndo:\\n - createView:\\n call: CreateMaterializedViewIfNotExists\\n with:\\n nql: \\\"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\\\"\\n - refreshView:\\n call: RefreshMaterializedView\\n with:\\n datasetName: workflow_output\\n - insertData:\\n call: ExecuteDml\\n with:\\n nql: \\\"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\\\"\\n\",\n \"data_plane_id\": \"d1e2f3a4-b5c6-7890-abcd-ef1234567890\",\n \"trigger_immediately\": false,\n \"schedule_immediately\": false,\n \"tags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "my-etl-workflow",
"specification": "document:\n dsl: '1.0.0'\n namespace: test\n name: test-workflow\n version: '1.0.0'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"\n",
"data_plane_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
"company_id": 100,
"created_at": "2025-01-15T10:30:00Z",
"created_by": 20,
"updated_at": "2025-01-15T10:30:00Z",
"status": "active",
"tags": [
"<string>"
],
"archived_at": null,
"run_id": "b7e3f1a2-4c5d-6e7f-8a9b-0c1d2e3f4a5b"
}{
"type": null,
"title": "Failed to Parse Query",
"status": 400,
"detail": "Invalid query format.",
"instance": "/nql/validate",
"log_id": "c06fea02-0950-45c6-aaff-07ab07c0d04c",
"debug": null
}{
"type": null,
"title": "Failed to Parse Query",
"status": 400,
"detail": "Invalid query format.",
"instance": "/nql/validate",
"log_id": "c06fea02-0950-45c6-aaff-07ab07c0d04c",
"debug": null
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The workflow specification in YAML format.
"document:\n dsl: '1.0.0'\n namespace: test\n name: test-workflow\n version: '1.0.0'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"\n"
The data plane to associate the workflow with.
"d1e2f3a4-b5c6-7890-abcd-ef1234567890"
If true, the workflow will be triggered immediately after creation.
false
If true, the workflow schedule will be created immediately after creation.
false
Tags that describe the workflow.
1 - 128Response
The created workflow.
Unique identifier for a workflow.
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"
The name of the workflow, extracted from the specification.
"my-etl-workflow"
The workflow specification in YAML format.
"document:\n dsl: '1.0.0'\n namespace: test\n name: test-workflow\n version: '1.0.0'\ndo:\n - createView:\n call: CreateMaterializedViewIfNotExists\n with:\n nql: \"CREATE MATERIALIZED VIEW workflow_output AS SELECT track_id FROM company_data.workflow_input\"\n - refreshView:\n call: RefreshMaterializedView\n with:\n datasetName: workflow_output\n - insertData:\n call: ExecuteDml\n with:\n nql: \"INSERT INTO company_data.workflow_input (track_id) VALUES ('test')\"\n"
The data plane this workflow is associated with.
"d1e2f3a4-b5c6-7890-abcd-ef1234567890"
The company that owns this workflow.
100
ISO-8601 timestamp of when the workflow was created.
"2025-01-15T10:30:00Z"
The ID of the user who created this workflow.
20
ISO-8601 timestamp of when the workflow was last updated.
"2025-01-15T10:30:00Z"
The current status of the workflow.
active, archived "active"
Tags that describe the workflow.
1 - 128ISO-8601 timestamp of when the workflow was archived, or null if active.
null
The run ID if the workflow was triggered immediately upon creation.
"b7e3f1a2-4c5d-6e7f-8a9b-0c1d2e3f4a5b"
Was this page helpful?

