curl --request PUT \
--url https://api-dev.narrative.io/attributes/{attribute_name_or_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "price",
"description": "The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes",
"display_name": "Price",
"type": "object",
"collaborators": {
"view": {
"type": "inclusion",
"company_ids": [
12345,
67890
]
},
"map": {
"type": "inclusion",
"company_ids": [
12345
]
}
}
}
'import requests
url = "https://api-dev.narrative.io/attributes/{attribute_name_or_id}"
payload = {
"name": "price",
"description": "The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes",
"display_name": "Price",
"type": "object",
"collaborators": {
"view": {
"type": "inclusion",
"company_ids": [12345, 67890]
},
"map": {
"type": "inclusion",
"company_ids": [12345]
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'price',
description: 'The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes',
display_name: 'Price',
type: 'object',
collaborators: {
view: {type: 'inclusion', company_ids: [12345, 67890]},
map: {type: 'inclusion', company_ids: [12345]}
}
})
};
fetch('https://api-dev.narrative.io/attributes/{attribute_name_or_id}', 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/attributes/{attribute_name_or_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'price',
'description' => 'The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes',
'display_name' => 'Price',
'type' => 'object',
'collaborators' => [
'view' => [
'type' => 'inclusion',
'company_ids' => [
12345,
67890
]
],
'map' => [
'type' => 'inclusion',
'company_ids' => [
12345
]
]
]
]),
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/attributes/{attribute_name_or_id}"
payload := strings.NewReader("{\n \"name\": \"price\",\n \"description\": \"The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes\",\n \"display_name\": \"Price\",\n \"type\": \"object\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345,\n 67890\n ]\n },\n \"map\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345\n ]\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api-dev.narrative.io/attributes/{attribute_name_or_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"price\",\n \"description\": \"The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes\",\n \"display_name\": \"Price\",\n \"type\": \"object\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345,\n 67890\n ]\n },\n \"map\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/attributes/{attribute_name_or_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"price\",\n \"description\": \"The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes\",\n \"display_name\": \"Price\",\n \"type\": \"object\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345,\n 67890\n ]\n },\n \"map\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 123456789,
"name": "price",
"description": "The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes",
"display_name": "Price",
"type": "object",
"company_id": 12345,
"collaborators": {
"view": {
"type": "inclusion",
"company_ids": [
12345,
67890
]
},
"map": {
"type": "inclusion",
"company_ids": [
12345
]
}
},
"tags": [
"ecommerce",
"transaction"
]
}Update an attribute
Update an attribute. Only the company that owns an attribute may update it.
curl --request PUT \
--url https://api-dev.narrative.io/attributes/{attribute_name_or_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "price",
"description": "The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes",
"display_name": "Price",
"type": "object",
"collaborators": {
"view": {
"type": "inclusion",
"company_ids": [
12345,
67890
]
},
"map": {
"type": "inclusion",
"company_ids": [
12345
]
}
}
}
'import requests
url = "https://api-dev.narrative.io/attributes/{attribute_name_or_id}"
payload = {
"name": "price",
"description": "The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes",
"display_name": "Price",
"type": "object",
"collaborators": {
"view": {
"type": "inclusion",
"company_ids": [12345, 67890]
},
"map": {
"type": "inclusion",
"company_ids": [12345]
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'price',
description: 'The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes',
display_name: 'Price',
type: 'object',
collaborators: {
view: {type: 'inclusion', company_ids: [12345, 67890]},
map: {type: 'inclusion', company_ids: [12345]}
}
})
};
fetch('https://api-dev.narrative.io/attributes/{attribute_name_or_id}', 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/attributes/{attribute_name_or_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'price',
'description' => 'The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes',
'display_name' => 'Price',
'type' => 'object',
'collaborators' => [
'view' => [
'type' => 'inclusion',
'company_ids' => [
12345,
67890
]
],
'map' => [
'type' => 'inclusion',
'company_ids' => [
12345
]
]
]
]),
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/attributes/{attribute_name_or_id}"
payload := strings.NewReader("{\n \"name\": \"price\",\n \"description\": \"The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes\",\n \"display_name\": \"Price\",\n \"type\": \"object\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345,\n 67890\n ]\n },\n \"map\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345\n ]\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api-dev.narrative.io/attributes/{attribute_name_or_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"price\",\n \"description\": \"The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes\",\n \"display_name\": \"Price\",\n \"type\": \"object\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345,\n 67890\n ]\n },\n \"map\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/attributes/{attribute_name_or_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"price\",\n \"description\": \"The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes\",\n \"display_name\": \"Price\",\n \"type\": \"object\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345,\n 67890\n ]\n },\n \"map\": {\n \"type\": \"inclusion\",\n \"company_ids\": [\n 12345\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 123456789,
"name": "price",
"description": "The price of an order, product, or a price component. Currency field accepts ISO 4217 currency codes",
"display_name": "Price",
"type": "object",
"company_id": 12345,
"collaborators": {
"view": {
"type": "inclusion",
"company_ids": [
12345,
67890
]
},
"map": {
"type": "inclusion",
"company_ids": [
12345
]
}
},
"tags": [
"ecommerce",
"transaction"
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Either an attribute name or an attribute id Unique identifier
Body
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
An short identifier for the attribute to be used when it is referenced in validations.
Attribute names must consist of only alphanumeric characters or underscores and be < 255 characters long.
A public-facing descriptive name for the attribute.
Defines which companies have access to view and map this attribute
Show child attributes
Show child attributes
An array with elements of any data type.
array - Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
Show child attributes
Show child attributes
A description of the type of data the attribute represents, including collection methodology, assumptions, etc.
A raw Spark SQL expression determining whether a value for the given column is valid or not.
If more than one validation is specified then all the validation must evaluate to true for the column value to be considered valid.
If validations is not specified or empty then all rows will match the access rule.
E.g. for an attribute with the following definition:
{
"name": "unique_id",
"type": "object",
"properties": {
"identifier_value": {
"type": "string"
},
"identifier_type": {
"type": "string"
},
"timestamp": {
"type": "timestamptz"
}
},
"required": [
"value"
]
}
Valid validations include:
- Is the ID type lowercased?
"identifier_type": {
"type": "string",
"validations": [
"lower($this.identifier_type) = $this.identifier_type"
]
}
- Was the row collected within the last 90 days?
"timestamp": {
"type": "timestamptz",
"validations": [
"$this.timestamp > date_sub(current_date(), 90)"
]
}
Response
OK
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
An owned attribute response includes additional fields for attributes owned by the requesting company.
Unique identifier for the attribute.
A public-facing descriptive name for the attribute.
An short identifier for the attribute to be used when it is referenced in validations.
Attribute names must consist of only alphanumeric characters or underscores and be < 255 characters long.
List of tags associated with the attribute
An array with elements of any data type.
array - Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
Show child attributes
Show child attributes
The ID of the company that owns this attribute
Defines which companies have access to view and map this attribute
Show child attributes
Show child attributes
A description of the type of data the attribute represents, including collection methodology, assumptions, etc.
A raw Spark SQL expression determining whether a value for the given column is valid or not.
If more than one validation is specified then all the validation must evaluate to true for the column value to be considered valid.
If validations is not specified or empty then all rows will match the access rule.
E.g. for an attribute with the following definition:
{
"name": "unique_id",
"type": "object",
"properties": {
"identifier_value": {
"type": "string"
},
"identifier_type": {
"type": "string"
},
"timestamp": {
"type": "timestamptz"
}
},
"required": [
"value"
]
}
Valid validations include:
- Is the ID type lowercased?
"identifier_type": {
"type": "string",
"validations": [
"lower($this.identifier_type) = $this.identifier_type"
]
}
- Was the row collected within the last 90 days?
"timestamp": {
"type": "timestamptz",
"validations": [
"$this.timestamp > date_sub(current_date(), 90)"
]
}
Was this page helpful?

