curl --request POST \
--url https://api-dev.narrative.io/mappings/companies/{company_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"attribute_id": 123,
"dataset_id": 456,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "product.brand",
"expression": "itemBrand"
},
{
"path": "product.category",
"expression": "itemCategory"
},
{
"path": "product.id.type",
"expression": "'SKU'"
},
{
"path": "product.id.value",
"expression": "itemID"
}
]
}
}
EOFimport requests
url = "https://api-dev.narrative.io/mappings/companies/{company_id}"
payload = {
"attribute_id": 123,
"dataset_id": 456,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "product.brand",
"expression": "itemBrand"
},
{
"path": "product.category",
"expression": "itemCategory"
},
{
"path": "product.id.type",
"expression": "'SKU'"
},
{
"path": "product.id.value",
"expression": "itemID"
}
]
}
}
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({
attribute_id: 123,
dataset_id: 456,
mapping: {
type: 'object_mapping',
property_mappings: [
{path: 'product.brand', expression: 'itemBrand'},
{path: 'product.category', expression: 'itemCategory'},
{path: 'product.id.type', expression: '\'SKU\''},
{path: 'product.id.value', expression: 'itemID'}
]
}
})
};
fetch('https://api-dev.narrative.io/mappings/companies/{company_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/mappings/companies/{company_id}",
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([
'attribute_id' => 123,
'dataset_id' => 456,
'mapping' => [
'type' => 'object_mapping',
'property_mappings' => [
[
'path' => 'product.brand',
'expression' => 'itemBrand'
],
[
'path' => 'product.category',
'expression' => 'itemCategory'
],
[
'path' => 'product.id.type',
'expression' => '\'SKU\''
],
[
'path' => 'product.id.value',
'expression' => 'itemID'
]
]
]
]),
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/mappings/companies/{company_id}"
payload := strings.NewReader("{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\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/mappings/companies/{company_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/mappings/companies/{company_id}")
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 \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "ea9dddd2-e3ee-40b5-b03e-c3cd37c8a7f0",
"attribute_id": 1,
"created_at": "2021-12-10T00:00:00Z",
"dataset_id": 3,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "foo",
"expression": "upper(`US Kennel ID`)",
"dependencies": {
"properties": [
"US Kennel ID"
]
}
},
{
"path": "bar.baz.qux",
"expression": "weight * 10000",
"dependencies": {
"properties": [
"weight"
]
}
}
]
},
"status": "active",
"updated_at": "2021-12-10T00:00:01Z",
"created_by": 1,
"updated_by": 1,
"company_id": 100,
"scope": "global",
"source": "admin",
"derived_from": "ea9dddd2-e3ee-40b5-b03e-c3cd37c8a6f0"
}Create a mapping
Create a mapping between an attribute and one of the company’s datasets. The created mapping is
owned by the company and has global scope.
Supports mapping types: cached_mapping, object_mapping, and value_mapping.
curl --request POST \
--url https://api-dev.narrative.io/mappings/companies/{company_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"attribute_id": 123,
"dataset_id": 456,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "product.brand",
"expression": "itemBrand"
},
{
"path": "product.category",
"expression": "itemCategory"
},
{
"path": "product.id.type",
"expression": "'SKU'"
},
{
"path": "product.id.value",
"expression": "itemID"
}
]
}
}
EOFimport requests
url = "https://api-dev.narrative.io/mappings/companies/{company_id}"
payload = {
"attribute_id": 123,
"dataset_id": 456,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "product.brand",
"expression": "itemBrand"
},
{
"path": "product.category",
"expression": "itemCategory"
},
{
"path": "product.id.type",
"expression": "'SKU'"
},
{
"path": "product.id.value",
"expression": "itemID"
}
]
}
}
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({
attribute_id: 123,
dataset_id: 456,
mapping: {
type: 'object_mapping',
property_mappings: [
{path: 'product.brand', expression: 'itemBrand'},
{path: 'product.category', expression: 'itemCategory'},
{path: 'product.id.type', expression: '\'SKU\''},
{path: 'product.id.value', expression: 'itemID'}
]
}
})
};
fetch('https://api-dev.narrative.io/mappings/companies/{company_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/mappings/companies/{company_id}",
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([
'attribute_id' => 123,
'dataset_id' => 456,
'mapping' => [
'type' => 'object_mapping',
'property_mappings' => [
[
'path' => 'product.brand',
'expression' => 'itemBrand'
],
[
'path' => 'product.category',
'expression' => 'itemCategory'
],
[
'path' => 'product.id.type',
'expression' => '\'SKU\''
],
[
'path' => 'product.id.value',
'expression' => 'itemID'
]
]
]
]),
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/mappings/companies/{company_id}"
payload := strings.NewReader("{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\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/mappings/companies/{company_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/mappings/companies/{company_id}")
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 \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "ea9dddd2-e3ee-40b5-b03e-c3cd37c8a7f0",
"attribute_id": 1,
"created_at": "2021-12-10T00:00:00Z",
"dataset_id": 3,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "foo",
"expression": "upper(`US Kennel ID`)",
"dependencies": {
"properties": [
"US Kennel ID"
]
}
},
{
"path": "bar.baz.qux",
"expression": "weight * 10000",
"dependencies": {
"properties": [
"weight"
]
}
}
]
},
"status": "active",
"updated_at": "2021-12-10T00:00:01Z",
"created_by": 1,
"updated_by": 1,
"company_id": 100,
"scope": "global",
"source": "admin",
"derived_from": "ea9dddd2-e3ee-40b5-b03e-c3cd37c8a6f0"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The id of an existing company
Query Parameters
Skip validation of the mapping expressions against the query engine. Structural validation of the request still runs. The flag is enabled by being present; any value is ignored.
Body
The target attribute's ID.
The source dataset's ID.
Mapping definition for create/update requests. Dependencies are computed server-side and not provided by the client.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Status to create the mapping in. Defaults to active when omitted. Narrower than
MappingStatus — a mapping cannot be created already archived.
active, pending, null Free-form labels on the mapping. Null and an empty array both mean no tags; nio:-prefixed tags
are reserved for Narrative.
["nio:rosetta"]
Optional source for the mapping. Null or omitted defaults to company.
Only company and rosetta_stone are allowed for user-created mappings.
company, rosetta_stone, null Response
Ok
Unique identifier for a mapping.
"ea9dddd2-e3ee-40b5-b03e-c3cd37c8a6f0"
The target attribute's ID.
ISO-8601 timestamp indicating when the mapping was created.
"2021-08-26T21:06:07.710357Z"
The source dataset's ID.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
The status of the mapping.
active- Active mappings can be usedarchived- Archived/Deleted mappings - mapping no longer in usepending- Pending mappings need to be accepted before they can be usedrejected- Proposed mappings the owner turned down. Can still be accepted later
active, archived, pending, rejected ISO-8601 timestamp indicating when the mapping was last updated.
"2021-08-26T21:06:07.710357Z"
Unique id from a user who created it.
20
Unique id from a user who updated it.
20
The scope of the mapping.
global- Mappings available to allprivate- Company private mappings
global, private The source of the mapping.
company- Company private mappingadmin- Admin created/promoted mappingsystem- System (Automated/ML) mappingslineage- Lineage-derived mappings (editable without admin)rosetta_stone- Rosetta Stone mappings (editable without admin)derived- Mappings produced by a derivation rule
company, admin, system, lineage, rosetta_stone, derived The company that owns the mapping. Null for platform-wide mappings.
345
Free-form labels on the mapping. Null and an empty array both mean no tags; nio:-prefixed tags
are reserved for Narrative.
["nio:rosetta"]
The mapping this one was derived from. Null when the mapping was authored directly.
"ea9dddd2-e3ee-40b5-b03e-c3cd37c8a6f0"
Was this page helpful?

