Create a product
curl --request POST \
--url https://api-dev.narrative.io/admin/products \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sku": "general-storage",
"sku_type": {
"category": "storage"
},
"payable_company_id": 1,
"name": "name",
"cloud_platform": {
"platform": "aws",
"region": "us-east-1"
},
"unit": "bytes",
"default_rate": {
"type": "per_unit",
"unit_price": {
"type": "test-price",
"currency": "USD",
"price_in_micro_cents": 1
}
},
"status": "active"
}
'import requests
url = "https://api-dev.narrative.io/admin/products"
payload = {
"sku": "general-storage",
"sku_type": { "category": "storage" },
"payable_company_id": 1,
"name": "name",
"cloud_platform": {
"platform": "aws",
"region": "us-east-1"
},
"unit": "bytes",
"default_rate": {
"type": "per_unit",
"unit_price": {
"type": "test-price",
"currency": "USD",
"price_in_micro_cents": 1
}
},
"status": "active"
}
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({
sku: 'general-storage',
sku_type: {category: 'storage'},
payable_company_id: 1,
name: 'name',
cloud_platform: {platform: 'aws', region: 'us-east-1'},
unit: 'bytes',
default_rate: {
type: 'per_unit',
unit_price: {type: 'test-price', currency: 'USD', price_in_micro_cents: 1}
},
status: 'active'
})
};
fetch('https://api-dev.narrative.io/admin/products', 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/admin/products",
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([
'sku' => 'general-storage',
'sku_type' => [
'category' => 'storage'
],
'payable_company_id' => 1,
'name' => 'name',
'cloud_platform' => [
'platform' => 'aws',
'region' => 'us-east-1'
],
'unit' => 'bytes',
'default_rate' => [
'type' => 'per_unit',
'unit_price' => [
'type' => 'test-price',
'currency' => 'USD',
'price_in_micro_cents' => 1
]
],
'status' => 'active'
]),
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/admin/products"
payload := strings.NewReader("{\n \"sku\": \"general-storage\",\n \"sku_type\": {\n \"category\": \"storage\"\n },\n \"payable_company_id\": 1,\n \"name\": \"name\",\n \"cloud_platform\": {\n \"platform\": \"aws\",\n \"region\": \"us-east-1\"\n },\n \"unit\": \"bytes\",\n \"default_rate\": {\n \"type\": \"per_unit\",\n \"unit_price\": {\n \"type\": \"test-price\",\n \"currency\": \"USD\",\n \"price_in_micro_cents\": 1\n }\n },\n \"status\": \"active\"\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/admin/products")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sku\": \"general-storage\",\n \"sku_type\": {\n \"category\": \"storage\"\n },\n \"payable_company_id\": 1,\n \"name\": \"name\",\n \"cloud_platform\": {\n \"platform\": \"aws\",\n \"region\": \"us-east-1\"\n },\n \"unit\": \"bytes\",\n \"default_rate\": {\n \"type\": \"per_unit\",\n \"unit_price\": {\n \"type\": \"test-price\",\n \"currency\": \"USD\",\n \"price_in_micro_cents\": 1\n }\n },\n \"status\": \"active\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/admin/products")
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 \"sku\": \"general-storage\",\n \"sku_type\": {\n \"category\": \"storage\"\n },\n \"payable_company_id\": 1,\n \"name\": \"name\",\n \"cloud_platform\": {\n \"platform\": \"aws\",\n \"region\": \"us-east-1\"\n },\n \"unit\": \"bytes\",\n \"default_rate\": {\n \"type\": \"per_unit\",\n \"unit_price\": {\n \"type\": \"test-price\",\n \"currency\": \"USD\",\n \"price_in_micro_cents\": 1\n }\n },\n \"status\": \"active\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cd98bbb6-1086-4aea-9b5f-8ba39671a659",
"sku": "general-storage",
"sku_type": {
"category": "storage"
},
"payable_company_id": 1,
"name": "name",
"cloud_platform": {
"region": "us-east-1",
"platform": "aws"
},
"unit": "bytes",
"default_rate": {
"type": "per_unit",
"unit_price": {
"value": 1,
"expressed_in": "cents",
"currency": "USD"
}
},
"status": "active",
"created_at": "2023-02-13T12:55:24.104Z",
"created_by_user_id": 1,
"updated_at": "2023-02-13T12:55:24.104Z",
"updated_by_user_id": 1
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Products
Create a product
Create a new product.
POST
/
admin
/
products
Create a product
curl --request POST \
--url https://api-dev.narrative.io/admin/products \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sku": "general-storage",
"sku_type": {
"category": "storage"
},
"payable_company_id": 1,
"name": "name",
"cloud_platform": {
"platform": "aws",
"region": "us-east-1"
},
"unit": "bytes",
"default_rate": {
"type": "per_unit",
"unit_price": {
"type": "test-price",
"currency": "USD",
"price_in_micro_cents": 1
}
},
"status": "active"
}
'import requests
url = "https://api-dev.narrative.io/admin/products"
payload = {
"sku": "general-storage",
"sku_type": { "category": "storage" },
"payable_company_id": 1,
"name": "name",
"cloud_platform": {
"platform": "aws",
"region": "us-east-1"
},
"unit": "bytes",
"default_rate": {
"type": "per_unit",
"unit_price": {
"type": "test-price",
"currency": "USD",
"price_in_micro_cents": 1
}
},
"status": "active"
}
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({
sku: 'general-storage',
sku_type: {category: 'storage'},
payable_company_id: 1,
name: 'name',
cloud_platform: {platform: 'aws', region: 'us-east-1'},
unit: 'bytes',
default_rate: {
type: 'per_unit',
unit_price: {type: 'test-price', currency: 'USD', price_in_micro_cents: 1}
},
status: 'active'
})
};
fetch('https://api-dev.narrative.io/admin/products', 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/admin/products",
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([
'sku' => 'general-storage',
'sku_type' => [
'category' => 'storage'
],
'payable_company_id' => 1,
'name' => 'name',
'cloud_platform' => [
'platform' => 'aws',
'region' => 'us-east-1'
],
'unit' => 'bytes',
'default_rate' => [
'type' => 'per_unit',
'unit_price' => [
'type' => 'test-price',
'currency' => 'USD',
'price_in_micro_cents' => 1
]
],
'status' => 'active'
]),
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/admin/products"
payload := strings.NewReader("{\n \"sku\": \"general-storage\",\n \"sku_type\": {\n \"category\": \"storage\"\n },\n \"payable_company_id\": 1,\n \"name\": \"name\",\n \"cloud_platform\": {\n \"platform\": \"aws\",\n \"region\": \"us-east-1\"\n },\n \"unit\": \"bytes\",\n \"default_rate\": {\n \"type\": \"per_unit\",\n \"unit_price\": {\n \"type\": \"test-price\",\n \"currency\": \"USD\",\n \"price_in_micro_cents\": 1\n }\n },\n \"status\": \"active\"\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/admin/products")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sku\": \"general-storage\",\n \"sku_type\": {\n \"category\": \"storage\"\n },\n \"payable_company_id\": 1,\n \"name\": \"name\",\n \"cloud_platform\": {\n \"platform\": \"aws\",\n \"region\": \"us-east-1\"\n },\n \"unit\": \"bytes\",\n \"default_rate\": {\n \"type\": \"per_unit\",\n \"unit_price\": {\n \"type\": \"test-price\",\n \"currency\": \"USD\",\n \"price_in_micro_cents\": 1\n }\n },\n \"status\": \"active\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/admin/products")
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 \"sku\": \"general-storage\",\n \"sku_type\": {\n \"category\": \"storage\"\n },\n \"payable_company_id\": 1,\n \"name\": \"name\",\n \"cloud_platform\": {\n \"platform\": \"aws\",\n \"region\": \"us-east-1\"\n },\n \"unit\": \"bytes\",\n \"default_rate\": {\n \"type\": \"per_unit\",\n \"unit_price\": {\n \"type\": \"test-price\",\n \"currency\": \"USD\",\n \"price_in_micro_cents\": 1\n }\n },\n \"status\": \"active\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cd98bbb6-1086-4aea-9b5f-8ba39671a659",
"sku": "general-storage",
"sku_type": {
"category": "storage"
},
"payable_company_id": 1,
"name": "name",
"cloud_platform": {
"region": "us-east-1",
"platform": "aws"
},
"unit": "bytes",
"default_rate": {
"type": "per_unit",
"unit_price": {
"value": 1,
"expressed_in": "cents",
"currency": "USD"
}
},
"status": "active",
"created_at": "2023-02-13T12:55:24.104Z",
"created_by_user_id": 1,
"updated_at": "2023-02-13T12:55:24.104Z",
"updated_by_user_id": 1
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
SKU for product
Sku Type (json object, category filed is mandatory)
Show child attributes
Show child attributes
Payable company id
Product name
Product rate
Show child attributes
Show child attributes
Available options:
active, archived Optional description of a product
Cloud Platform (json object)
Show child attributes
Show child attributes
Response
OK
UUID
SKU for product
Sku Type (json object, category filed is mandatory)
Show child attributes
Show child attributes
Payable company id
Product rate
Show child attributes
Show child attributes
Available options:
active, archived Cloud Platform (json object)
Show child attributes
Show child attributes
Example:
123
Example:
123
Was this page helpful?
⌘I

