curl --request POST \
--url https://api-dev.narrative.io/v2/access-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "example_access_rule",
"display_name": "Example Access Rule",
"description": "This is an example access rule.",
"image_url": "http://example.com/image.png",
"status": "active",
"tags": [
"tag1",
"tag2"
],
"nql": "SELECT tar.\"maid\" FROM company_data.\"11370\" tar",
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"price_cpm_usd": 10
}
'import requests
url = "https://api-dev.narrative.io/v2/access-rules"
payload = {
"name": "example_access_rule",
"display_name": "Example Access Rule",
"description": "This is an example access rule.",
"image_url": "http://example.com/image.png",
"status": "active",
"tags": ["tag1", "tag2"],
"nql": "SELECT tar.\"maid\" FROM company_data.\"11370\" tar",
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [789]
},
"view": { "type": "all" }
},
"price_cpm_usd": 10
}
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: 'example_access_rule',
display_name: 'Example Access Rule',
description: 'This is an example access rule.',
image_url: 'http://example.com/image.png',
status: 'active',
tags: ['tag1', 'tag2'],
nql: 'SELECT tar."maid" FROM company_data."11370" tar',
collaborators: {query: {type: 'inclusion', company_ids: [789]}, view: {type: 'all'}},
price_cpm_usd: 10
})
};
fetch('https://api-dev.narrative.io/v2/access-rules', 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/access-rules",
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' => 'example_access_rule',
'display_name' => 'Example Access Rule',
'description' => 'This is an example access rule.',
'image_url' => 'http://example.com/image.png',
'status' => 'active',
'tags' => [
'tag1',
'tag2'
],
'nql' => 'SELECT tar."maid" FROM company_data."11370" tar',
'collaborators' => [
'query' => [
'type' => 'inclusion',
'company_ids' => [
789
]
],
'view' => [
'type' => 'all'
]
],
'price_cpm_usd' => 10
]),
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/access-rules"
payload := strings.NewReader("{\n \"name\": \"example_access_rule\",\n \"display_name\": \"Example Access Rule\",\n \"description\": \"This is an example access rule.\",\n \"image_url\": \"http://example.com/image.png\",\n \"status\": \"active\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"nql\": \"SELECT tar.\\\"maid\\\" FROM company_data.\\\"11370\\\" tar\",\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"price_cpm_usd\": 10\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/access-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"example_access_rule\",\n \"display_name\": \"Example Access Rule\",\n \"description\": \"This is an example access rule.\",\n \"image_url\": \"http://example.com/image.png\",\n \"status\": \"active\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"nql\": \"SELECT tar.\\\"maid\\\" FROM company_data.\\\"11370\\\" tar\",\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"price_cpm_usd\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/access-rules")
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\": \"example_access_rule\",\n \"display_name\": \"Example Access Rule\",\n \"description\": \"This is an example access rule.\",\n \"image_url\": \"http://example.com/image.png\",\n \"status\": \"active\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"nql\": \"SELECT tar.\\\"maid\\\" FROM company_data.\\\"11370\\\" tar\",\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"price_cpm_usd\": 10\n}"
response = http.request(request)
puts response.read_body{
"prev_page": null,
"current_page": 1,
"next_page": null,
"total_records": 2,
"total_pages": 1,
"records": [
{
"name": "name",
"id": 2,
"company_id": 42,
"company_name": "company name",
"company_slug": "company_slug",
"data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
"display_name": "access rule",
"description": "description",
"image": "https://google.com/1.jpg",
"tags": [
"tag"
],
"schema": {
"type": "object",
"properties": {
"id": {
"order": 1,
"display_name": "id of field",
"type": "string"
}
},
"required": [
"id"
]
},
"price_cpm_usd": 42,
"metadata": {
"created_at": "2007-12-03T10:15:30",
"updated_at": "2008-12-03T10:15:30"
},
"type": "explicit_share",
"mappings": [
{
"attribute_id": 42,
"attribute_name": "id",
"properties": [
"id.type",
"id.value"
]
}
]
},
{
"name": "access_rule_ebc86610_0907_4374_8fc9_be360f0ff8d0",
"id": 1,
"company_id": 1,
"company_name": "company",
"company_slug": "company_slug_60a4e678_1d56_48a7_8b8b_4e1d689b11a6",
"data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
"display_name": "display name",
"description": "description",
"image": "https://narrative.test/1.png",
"status": "active",
"tags": [
"_nio_access_rule"
],
"nql": "select company_data.\"1\".columnA from company_data.\"1\" WHERE columnA = columnB",
"schema": {
"type": "object",
"properties": {
"columnA": {
"display_name": "columnA",
"type": "string"
}
},
"required": [
"columnA"
]
},
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"price_cpm_usd": 1000,
"metadata": {
"created_at": "2023-12-14T21:36:51.847901",
"updated_at": "2023-12-14T21:36:51.847901"
},
"dataset_ids": [
42
],
"type": "owned",
"mappings": [
{
"attribute_id": 42,
"attribute_name": "id",
"properties": [
"id.type",
"id.value"
]
}
]
}
]
}{
"title": "Unsupported Type Error: DECIMAL",
"status": 422,
"detail": "Column 'decimal_value' has type DECIMAL, which is not supported as an output column of a materialized view. CAST the column to a supported type such as DOUBLE, BIGINT, VARCHAR, BOOLEAN, or TIMESTAMP.",
"instance": "/v2/accessrules/create",
"log_id": "c904b703-d41e-4372-9276-9f4bdc8ad031",
"debug": {
"column": "decimal_value",
"type_name": "DECIMAL"
}
}Create a new Access Rule
Creates a new access rule based on the provided NQL query.
curl --request POST \
--url https://api-dev.narrative.io/v2/access-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "example_access_rule",
"display_name": "Example Access Rule",
"description": "This is an example access rule.",
"image_url": "http://example.com/image.png",
"status": "active",
"tags": [
"tag1",
"tag2"
],
"nql": "SELECT tar.\"maid\" FROM company_data.\"11370\" tar",
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"price_cpm_usd": 10
}
'import requests
url = "https://api-dev.narrative.io/v2/access-rules"
payload = {
"name": "example_access_rule",
"display_name": "Example Access Rule",
"description": "This is an example access rule.",
"image_url": "http://example.com/image.png",
"status": "active",
"tags": ["tag1", "tag2"],
"nql": "SELECT tar.\"maid\" FROM company_data.\"11370\" tar",
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [789]
},
"view": { "type": "all" }
},
"price_cpm_usd": 10
}
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: 'example_access_rule',
display_name: 'Example Access Rule',
description: 'This is an example access rule.',
image_url: 'http://example.com/image.png',
status: 'active',
tags: ['tag1', 'tag2'],
nql: 'SELECT tar."maid" FROM company_data."11370" tar',
collaborators: {query: {type: 'inclusion', company_ids: [789]}, view: {type: 'all'}},
price_cpm_usd: 10
})
};
fetch('https://api-dev.narrative.io/v2/access-rules', 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/access-rules",
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' => 'example_access_rule',
'display_name' => 'Example Access Rule',
'description' => 'This is an example access rule.',
'image_url' => 'http://example.com/image.png',
'status' => 'active',
'tags' => [
'tag1',
'tag2'
],
'nql' => 'SELECT tar."maid" FROM company_data."11370" tar',
'collaborators' => [
'query' => [
'type' => 'inclusion',
'company_ids' => [
789
]
],
'view' => [
'type' => 'all'
]
],
'price_cpm_usd' => 10
]),
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/access-rules"
payload := strings.NewReader("{\n \"name\": \"example_access_rule\",\n \"display_name\": \"Example Access Rule\",\n \"description\": \"This is an example access rule.\",\n \"image_url\": \"http://example.com/image.png\",\n \"status\": \"active\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"nql\": \"SELECT tar.\\\"maid\\\" FROM company_data.\\\"11370\\\" tar\",\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"price_cpm_usd\": 10\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/access-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"example_access_rule\",\n \"display_name\": \"Example Access Rule\",\n \"description\": \"This is an example access rule.\",\n \"image_url\": \"http://example.com/image.png\",\n \"status\": \"active\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"nql\": \"SELECT tar.\\\"maid\\\" FROM company_data.\\\"11370\\\" tar\",\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"price_cpm_usd\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/access-rules")
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\": \"example_access_rule\",\n \"display_name\": \"Example Access Rule\",\n \"description\": \"This is an example access rule.\",\n \"image_url\": \"http://example.com/image.png\",\n \"status\": \"active\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"nql\": \"SELECT tar.\\\"maid\\\" FROM company_data.\\\"11370\\\" tar\",\n \"collaborators\": {\n \"query\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 789\n ]\n },\n \"view\": {\n \"type\": \"all\"\n }\n },\n \"price_cpm_usd\": 10\n}"
response = http.request(request)
puts response.read_body{
"prev_page": null,
"current_page": 1,
"next_page": null,
"total_records": 2,
"total_pages": 1,
"records": [
{
"name": "name",
"id": 2,
"company_id": 42,
"company_name": "company name",
"company_slug": "company_slug",
"data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
"display_name": "access rule",
"description": "description",
"image": "https://google.com/1.jpg",
"tags": [
"tag"
],
"schema": {
"type": "object",
"properties": {
"id": {
"order": 1,
"display_name": "id of field",
"type": "string"
}
},
"required": [
"id"
]
},
"price_cpm_usd": 42,
"metadata": {
"created_at": "2007-12-03T10:15:30",
"updated_at": "2008-12-03T10:15:30"
},
"type": "explicit_share",
"mappings": [
{
"attribute_id": 42,
"attribute_name": "id",
"properties": [
"id.type",
"id.value"
]
}
]
},
{
"name": "access_rule_ebc86610_0907_4374_8fc9_be360f0ff8d0",
"id": 1,
"company_id": 1,
"company_name": "company",
"company_slug": "company_slug_60a4e678_1d56_48a7_8b8b_4e1d689b11a6",
"data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
"display_name": "display name",
"description": "description",
"image": "https://narrative.test/1.png",
"status": "active",
"tags": [
"_nio_access_rule"
],
"nql": "select company_data.\"1\".columnA from company_data.\"1\" WHERE columnA = columnB",
"schema": {
"type": "object",
"properties": {
"columnA": {
"display_name": "columnA",
"type": "string"
}
},
"required": [
"columnA"
]
},
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"price_cpm_usd": 1000,
"metadata": {
"created_at": "2023-12-14T21:36:51.847901",
"updated_at": "2023-12-14T21:36:51.847901"
},
"dataset_ids": [
42
],
"type": "owned",
"mappings": [
{
"attribute_id": 42,
"attribute_name": "id",
"properties": [
"id.type",
"id.value"
]
}
]
}
]
}{
"title": "Unsupported Type Error: DECIMAL",
"status": 422,
"detail": "Column 'decimal_value' has type DECIMAL, which is not supported as an output column of a materialized view. CAST the column to a supported type such as DOUBLE, BIGINT, VARCHAR, BOOLEAN, or TIMESTAMP.",
"instance": "/v2/accessrules/create",
"log_id": "c904b703-d41e-4372-9276-9f4bdc8ad031",
"debug": {
"column": "decimal_value",
"type_name": "DECIMAL"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
It should be unique. Also should not intersect with Dataset names. Must be <= 256 characters and consist of only alphanumeric characters and underscores.
NQL query of access rule.
Describes who can view or query a resource
Show child attributes
Show child attributes
How much to charge for a row which matches this access rule. Cost per mille (CPM), more commonly called “cost per thousand,” is how much a buyer pays for 1,000 records.
Optional. Display Name must be non-empty and less than 1000 chars.
A human-friendly description of the access rule.
Optional. _nio_access_rule will be added even if not presented. Access Rule tag must be non-empty and less than 256 chars.
Response
OK
- Option 1
- Option 2
Show child attributes
Show child attributes
{
"name": "access_rule_ebc86610_0907_4374_8fc9_be360f0ff8d0",
"id": 1,
"company_id": 1,
"company_name": "company",
"company_slug": "company_slug_60a4e678_1d56_48a7_8b8b_4e1d689b11a6",
"data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
"display_name": "display name",
"description": "description",
"image": "https://narrative.test/1.png",
"status": "active",
"tags": ["_nio_access_rule"],
"nql": "select company_data.\"1\".columnA from company_data.\"1\" WHERE columnA = columnB",
"schema": {
"type": "object",
"properties": {
"columnA": {
"display_name": "columnA",
"type": "string"
}
},
"required": ["columnA"]
},
"collaborators": {
"query": { "type": "inclusion", "company_ids": [789] },
"view": { "type": "all" }
},
"price_cpm_usd": 1000.054,
"metadata": {
"created_at": "2023-12-14T21:36:51.847901",
"updated_at": "2023-12-14T21:36:51.847901"
},
"dataset_ids": [42],
"type": "owned",
"is_owned": true,
"mappings": [
{
"attribute_id": 42,
"attribute_name": "id",
"properties": ["id.type", "id.value"]
}
]
}
The number of previous page (if exists). Also can refer to the latest existing page if non-existing page was requested.
1
The number of requested page.
1
The number of next page (if exists).
42
Total amount of accessible Access Rules
15000
Total amount of pages.
10
Was this page helpful?

