curl --request POST \
--url https://api-dev.narrative.io/v2/views \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "view 1",
"display_name": "View One",
"tags": [
"tag1",
"tag2"
],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"nql": "SELECT age FROM narrative.rosetta_stone"
}
'import requests
url = "https://api-dev.narrative.io/v2/views"
payload = {
"name": "view 1",
"display_name": "View One",
"tags": ["tag1", "tag2"],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [789]
},
"view": { "type": "all" }
},
"nql": "SELECT age FROM narrative.rosetta_stone"
}
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({
name: 'view 1',
display_name: 'View One',
tags: ['tag1', 'tag2'],
collaborators: {query: {type: 'inclusion', company_ids: [789]}, view: {type: 'all'}},
nql: 'SELECT age FROM narrative.rosetta_stone'
})
};
fetch('https://api-dev.narrative.io/v2/views', 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/v2/views",
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([
'name' => 'view 1',
'display_name' => 'View One',
'tags' => [
'tag1',
'tag2'
],
'collaborators' => [
'query' => [
'type' => 'inclusion',
'company_ids' => [
789
]
],
'view' => [
'type' => 'all'
]
],
'nql' => 'SELECT age FROM narrative.rosetta_stone'
]),
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/v2/views"
payload := strings.NewReader("{\n \"name\": \"view 1\",\n \"display_name\": \"View One\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"nql\": \"SELECT age FROM narrative.rosetta_stone\"\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/v2/views")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"view 1\",\n \"display_name\": \"View One\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"nql\": \"SELECT age FROM narrative.rosetta_stone\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/views")
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 \"name\": \"view 1\",\n \"display_name\": \"View One\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"nql\": \"SELECT age FROM narrative.rosetta_stone\"\n}"
response = http.request(request)
puts response.read_body{
"name": "view1",
"id": "7409b999-2a9a-40cd-89dc-8430d85e0391",
"display_name": "Query One",
"owner": {
"company_id": 456,
"company_name": "ExampleCorp",
"company_slug": "examplecorp"
},
"tags": [
"tag1",
"tag2"
],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"is_owned": true,
"metadata": {
"created_at": "2024-04-12T19:57:05.012908",
"created_by_user_id": 321,
"updated_at": "2024-04-12T20:03:48.031825",
"updated_by_user_id": 321
},
"nql": "SELECT age FROM narrative.rosetta_stone",
"schema": {
"type": "object",
"properties": {
"age": {
"display_name": "age",
"type": "double"
}
},
"required": [
"id"
]
}
}Create a view
Any number of properties can be updated on the same request. If a property is not sent on the payload, the value won’t be updated.
curl --request POST \
--url https://api-dev.narrative.io/v2/views \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "view 1",
"display_name": "View One",
"tags": [
"tag1",
"tag2"
],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"nql": "SELECT age FROM narrative.rosetta_stone"
}
'import requests
url = "https://api-dev.narrative.io/v2/views"
payload = {
"name": "view 1",
"display_name": "View One",
"tags": ["tag1", "tag2"],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [789]
},
"view": { "type": "all" }
},
"nql": "SELECT age FROM narrative.rosetta_stone"
}
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({
name: 'view 1',
display_name: 'View One',
tags: ['tag1', 'tag2'],
collaborators: {query: {type: 'inclusion', company_ids: [789]}, view: {type: 'all'}},
nql: 'SELECT age FROM narrative.rosetta_stone'
})
};
fetch('https://api-dev.narrative.io/v2/views', 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/v2/views",
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([
'name' => 'view 1',
'display_name' => 'View One',
'tags' => [
'tag1',
'tag2'
],
'collaborators' => [
'query' => [
'type' => 'inclusion',
'company_ids' => [
789
]
],
'view' => [
'type' => 'all'
]
],
'nql' => 'SELECT age FROM narrative.rosetta_stone'
]),
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/v2/views"
payload := strings.NewReader("{\n \"name\": \"view 1\",\n \"display_name\": \"View One\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"nql\": \"SELECT age FROM narrative.rosetta_stone\"\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/v2/views")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"view 1\",\n \"display_name\": \"View One\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"nql\": \"SELECT age FROM narrative.rosetta_stone\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/views")
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 \"name\": \"view 1\",\n \"display_name\": \"View One\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"nql\": \"SELECT age FROM narrative.rosetta_stone\"\n}"
response = http.request(request)
puts response.read_body{
"name": "view1",
"id": "7409b999-2a9a-40cd-89dc-8430d85e0391",
"display_name": "Query One",
"owner": {
"company_id": 456,
"company_name": "ExampleCorp",
"company_slug": "examplecorp"
},
"tags": [
"tag1",
"tag2"
],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"is_owned": true,
"metadata": {
"created_at": "2024-04-12T19:57:05.012908",
"created_by_user_id": 321,
"updated_at": "2024-04-12T20:03:48.031825",
"updated_by_user_id": 321
},
"nql": "SELECT age FROM narrative.rosetta_stone",
"schema": {
"type": "object",
"properties": {
"age": {
"display_name": "age",
"type": "double"
}
},
"required": [
"id"
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
It should be unique. Must be <= 256 characters and consist of only alphanumeric characters and underscores.
Describes who can view or query a resource
Show child attributes
Show child attributes
Optional. Display Name must be non-empty and less than 1000 chars.
Optional. Each tag must be less than 256 chars.
Response
OK
- Option 1
- Option 2
It should be unique. Must be <= 256 characters and consist of only alphanumeric characters and underscores.
Describes who can view or query a resource
Show child attributes
Show child attributes
Information about the owner of the view
Show child attributes
Show child attributes
Metadata about when and by whom a view was created/updated
Show child attributes
Show child attributes
Optional. Display Name must be non-empty and less than 1000 chars.
Optional. Each tag must be less than 256 chars.
Whether the requestor owns the view.
NQL schema for the view.
Was this page helpful?

