### Get Access Rule by ID (V2) cURL Request Source: https://api.narrative.dev Use this cURL command to make a GET request to retrieve an access rule. Replace `{access_rule_id}` with the actual ID and `` with your authorization token. ```curl curl --request GET \ --url https://api-dev.narrative.io/v2/access-rules/{access_rule_id} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Access Rule V2 JSON Response Source: https://api.narrative.dev This is an example of a successful JSON response when retrieving an access rule. It contains details about the rule's configuration, schema, and collaborators. ```json { "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, "mappings": [ { "attribute_id": 42, "attribute_name": "id", "properties": [ "id.type", "id.value" ] } ] } ``` -------------------------------- ### Get Access Rule by ID (V2) Source: https://api.narrative.dev Retrieves a specific access rule using its unique identifier. This endpoint is part of the V2 API. ```APIDOC ## GET /v2/access-rules/{access_rule_id} ### Description Retrieves a specific access rule by its ID. ### Method GET ### Endpoint /v2/access-rules/{access_rule_id} ### Parameters #### Path Parameters - **access_rule_id** (integer) - Required - Access rule identifier. #### Request Headers - **Authorization** (string) - Required - Bearer authentication header of the form `Bearer `, where `` is your auth token. ### Response #### Success Response (200) - **name** (string) - The name of the access rule. - **id** (integer) - The unique identifier of the access rule. - **company_id** (integer) - The ID of the company associated with the access rule. - **company_name** (string) - The name of the company. - **company_slug** (string) - The slug of the company. - **display_name** (string) - The display name of the access rule. - **description** (string) - A description of the access rule. - **image** (string) - URL to an image associated with the access rule. - **status** (string) - The current status of the access rule (e.g., 'active'). - **tags** (array) - An array of tags associated with the access rule. - **nql** (string) - The NQL query associated with the access rule. - **schema** (object) - The schema defining the data structure for the access rule. - **collaborators** (object) - Information about collaborators for the access rule. - **price_cpm_usd** (number) - The cost per million impressions in USD. - **metadata** (object) - Metadata about the access rule, including creation and update times. - **dataset_ids** (array) - An array of dataset IDs associated with the access rule. - **type** (string) - The type of the access rule (e.g., 'owned'). - **is_owned** (boolean) - Indicates if the access rule is owned. - **mappings** (array) - Mappings associated with the access rule. ### Request Example ```json { "example": "request body" } ``` ### Response Example ```json { "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, "mappings": [ { "attribute_id": 42, "attribute_name": "id", "properties": [ "id.type", "id.value" ] } ] } ``` ``` -------------------------------- ### Update an Access Rule by id (V2) Source: https://api.narrative.dev Updates an existing access rule identified by its unique ID. This operation allows modification of various attributes of the access rule, including its name, status, pricing, metadata, and mappings. ```APIDOC ## PUT /access_rules/{id} ### Description Updates an existing access rule identified by its unique ID. ### Method PUT ### Endpoint `/access_rules/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - Unique identifier for the access rule. #### Request Body - **company_id** (integer) - Required - The id of an existing company. Example: `345` - **company_name** (string) - Required - Name of the company that owns this rule. - **status** (enum) - Required - Indicates the status of the access rule. Available options: `active` - **price_cpm_usd** (number) - 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. - **metadata** (object) - Required - An NQL policy describing which columns of which datasets are targeted by an access rule - **type** (enum) - Required - Indicates the ownership of the access rule. Available options: `owned` - **mappings** (object[]) - Required - Attributes that are mapped to columns referenced by this access rule. For each mapped attribute, `properties` lists the attribute property paths that are exposed by the rule. - **name** (string) - Optional - It should be unique. Also should not intersect with Dataset names. Must be <= 256 characters and consist of only alphanumeric characters and underscores. - **company_slug** (string) - Optional - Unique slug assigned to company. - **display_name** (string) - Optional - Display Name must be non-empty and less than 1000 chars. - **description** (string) - Optional - A human-friendly description of the access rule. - **image** (string) - Optional - Image url must be < 1000 characters, start from https://, ends with one of: jpg, apng, jpeg, jfif, pjpeg, webp, pjp, svg, avif, png, gif, bmp, tiff - **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. - **nql** (string) - Optional - NQL query of access rule. - **schema** (object) - Optional - Schema describing a structure of View (Access Rule) - **collaborators** (object) - Optional - Describes who can view or query a resource - **dataset_ids** (integer[]) - Optional - All datasets that were used to form the data. - **is_owned** (boolean) - Optional - Indicates if the query is owned by the user's own company. ### Response #### Success Response (200) - **Option 1** - **Option 2** ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.