Skip to main content
POST
/
v2
/
access-rules
Create a new Access Rule
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
}
'
{
  "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",
      "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"
    },
    {
      "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",
      "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"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string
required

It should be unique. Also should not intersect with Dataset names. Must be <= 256 characters and consist of only alphanumeric characters and underscores.

nql
string
required

NQL query of access rule.

collaborators
object
required

Describes who can view or query a resource

price_cpm_usd
number<double>
required

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.

display_name
string

Optional. Display Name must be non-empty and less than 1000 chars.

description
string

A human-friendly description of the access rule.

tags
string[]

Optional. _nio_access_rule will be added even if not presented. Access Rule tag must be non-empty and less than 256 chars.

Response

200 - application/json

OK

records
object[]
required
Example:
{
"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",
"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
}
prev_page
integer<int64>

The number of previous page (if exists). Also can refer to the latest existing page if non-existing page was requested.

Example:

1

current_page
integer<int64>

The number of requested page.

Example:

1

next_page
integer<int64>

The number of next page (if exists).

Example:

42

total_records
integer<int64>

Total amount of accessible Access Rules

Example:

15000

total_pages
integer<int64>

Total amount of pages.

Example:

10