Skip to main content
POST
/
v2
/
views
Create a view
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"
}
'
{
  "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

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. Must be <= 256 characters and consist of only alphanumeric characters and underscores.

collaborators
object
required

Describes who can view or query a resource

nql
string
required
display_name
string

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

tags
string[]

Optional. Each tag must be less than 256 chars.

Response

200 - application/json

OK

id
string<uuid>
required
name
string
required

It should be unique. Must be <= 256 characters and consist of only alphanumeric characters and underscores.

collaborators
object
required

Describes who can view or query a resource

owner
object
required

Information about the owner of the view

metadata
object
required

Metadata about when and by whom a view was created/updated

nql
string
required
display_name
string

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

tags
string[]

Optional. Each tag must be less than 256 chars.

is_owned
boolean

Whether the requestor owns the view.

schema
object

NQL schema for the view.