curl --request PUT \
--url https://api-dev.narrative.io/data-shops/subscriptions/{subscription_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"budget": {
"amount": {
"value": 250,
"currency": "USD"
},
"period": {
"type": "calendar_monthly"
}
},
"description": "subscription description",
"details": {
"type": "marketplace",
"data_rules": {
"attributes": [
{
"attribute_id": 32,
"fields": [
{
"field": "customer_v1.id.type",
"filter": {
"type": "include",
"list": [
"idfa"
]
},
"exported": true
},
{
"field": "customer_v1.id.value",
"exported": true
},
{
"field": "customer_v1.name.full_name",
"exported": true
}
],
"optional": false
},
{
"attribute_id": 45,
"fields": [
{
"field": "event_timestamp_v2",
"filter": {
"recency": "P180D"
},
"exported": true
}
],
"optional": true
},
{
"attribute_id": 30,
"fields": [
{
"field": "product_v2.name",
"exported": true
}
],
"optional": true
}
],
"deduplication": {
"period": "P90D",
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"event_timestamp_v2"
]
}
]
},
"frequency_filter": {
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"event_timestamp_v2"
]
}
],
"min_inclusive": 2,
"max_inclusive": 5
}
},
"pricing": {
"micro_cents_usd": 1000000000
}
},
"name": "subscription name",
"cadence": "monthly"
}
'import requests
url = "https://api-dev.narrative.io/data-shops/subscriptions/{subscription_id}"
payload = {
"budget": {
"amount": {
"value": 250,
"currency": "USD"
},
"period": { "type": "calendar_monthly" }
},
"description": "subscription description",
"details": {
"type": "marketplace",
"data_rules": {
"attributes": [
{
"attribute_id": 32,
"fields": [
{
"field": "customer_v1.id.type",
"filter": {
"type": "include",
"list": ["idfa"]
},
"exported": True
},
{
"field": "customer_v1.id.value",
"exported": True
},
{
"field": "customer_v1.name.full_name",
"exported": True
}
],
"optional": False
},
{
"attribute_id": 45,
"fields": [
{
"field": "event_timestamp_v2",
"filter": { "recency": "P180D" },
"exported": True
}
],
"optional": True
},
{
"attribute_id": 30,
"fields": [
{
"field": "product_v2.name",
"exported": True
}
],
"optional": True
}
],
"deduplication": {
"period": "P90D",
"attribute_references": [
{
"attribute_id": 123,
"column_names": ["event_timestamp_v2"]
}
]
},
"frequency_filter": {
"attribute_references": [
{
"attribute_id": 123,
"column_names": ["event_timestamp_v2"]
}
],
"min_inclusive": 2,
"max_inclusive": 5
}
},
"pricing": { "micro_cents_usd": 1000000000 }
},
"name": "subscription name",
"cadence": "monthly"
}
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({
budget: {amount: {value: 250, currency: 'USD'}, period: {type: 'calendar_monthly'}},
description: 'subscription description',
details: {
type: 'marketplace',
data_rules: {
attributes: [
{
attribute_id: 32,
fields: [
{
field: 'customer_v1.id.type',
filter: {type: 'include', list: ['idfa']},
exported: true
},
{field: 'customer_v1.id.value', exported: true},
{field: 'customer_v1.name.full_name', exported: true}
],
optional: false
},
{
attribute_id: 45,
fields: [{field: 'event_timestamp_v2', filter: {recency: 'P180D'}, exported: true}],
optional: true
},
{
attribute_id: 30,
fields: [{field: 'product_v2.name', exported: true}],
optional: true
}
],
deduplication: {
period: 'P90D',
attribute_references: [{attribute_id: 123, column_names: ['event_timestamp_v2']}]
},
frequency_filter: {
attribute_references: [{attribute_id: 123, column_names: ['event_timestamp_v2']}],
min_inclusive: 2,
max_inclusive: 5
}
},
pricing: {micro_cents_usd: 1000000000}
},
name: 'subscription name',
cadence: 'monthly'
})
};
fetch('https://api-dev.narrative.io/data-shops/subscriptions/{subscription_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/data-shops/subscriptions/{subscription_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([
'budget' => [
'amount' => [
'value' => 250,
'currency' => 'USD'
],
'period' => [
'type' => 'calendar_monthly'
]
],
'description' => 'subscription description',
'details' => [
'type' => 'marketplace',
'data_rules' => [
'attributes' => [
[
'attribute_id' => 32,
'fields' => [
[
'field' => 'customer_v1.id.type',
'filter' => [
'type' => 'include',
'list' => [
'idfa'
]
],
'exported' => true
],
[
'field' => 'customer_v1.id.value',
'exported' => true
],
[
'field' => 'customer_v1.name.full_name',
'exported' => true
]
],
'optional' => false
],
[
'attribute_id' => 45,
'fields' => [
[
'field' => 'event_timestamp_v2',
'filter' => [
'recency' => 'P180D'
],
'exported' => true
]
],
'optional' => true
],
[
'attribute_id' => 30,
'fields' => [
[
'field' => 'product_v2.name',
'exported' => true
]
],
'optional' => true
]
],
'deduplication' => [
'period' => 'P90D',
'attribute_references' => [
[
'attribute_id' => 123,
'column_names' => [
'event_timestamp_v2'
]
]
]
],
'frequency_filter' => [
'attribute_references' => [
[
'attribute_id' => 123,
'column_names' => [
'event_timestamp_v2'
]
]
],
'min_inclusive' => 2,
'max_inclusive' => 5
]
],
'pricing' => [
'micro_cents_usd' => 1000000000
]
],
'name' => 'subscription name',
'cadence' => 'monthly'
]),
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/data-shops/subscriptions/{subscription_id}"
payload := strings.NewReader("{\n \"budget\": {\n \"amount\": {\n \"value\": 250,\n \"currency\": \"USD\"\n },\n \"period\": {\n \"type\": \"calendar_monthly\"\n }\n },\n \"description\": \"subscription description\",\n \"details\": {\n \"type\": \"marketplace\",\n \"data_rules\": {\n \"attributes\": [\n {\n \"attribute_id\": 32,\n \"fields\": [\n {\n \"field\": \"customer_v1.id.type\",\n \"filter\": {\n \"type\": \"include\",\n \"list\": [\n \"idfa\"\n ]\n },\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.id.value\",\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.name.full_name\",\n \"exported\": true\n }\n ],\n \"optional\": false\n },\n {\n \"attribute_id\": 45,\n \"fields\": [\n {\n \"field\": \"event_timestamp_v2\",\n \"filter\": {\n \"recency\": \"P180D\"\n },\n \"exported\": true\n }\n ],\n \"optional\": true\n },\n {\n \"attribute_id\": 30,\n \"fields\": [\n {\n \"field\": \"product_v2.name\",\n \"exported\": true\n }\n ],\n \"optional\": true\n }\n ],\n \"deduplication\": {\n \"period\": \"P90D\",\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ]\n },\n \"frequency_filter\": {\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ],\n \"min_inclusive\": 2,\n \"max_inclusive\": 5\n }\n },\n \"pricing\": {\n \"micro_cents_usd\": 1000000000\n }\n },\n \"name\": \"subscription name\",\n \"cadence\": \"monthly\"\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/data-shops/subscriptions/{subscription_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"budget\": {\n \"amount\": {\n \"value\": 250,\n \"currency\": \"USD\"\n },\n \"period\": {\n \"type\": \"calendar_monthly\"\n }\n },\n \"description\": \"subscription description\",\n \"details\": {\n \"type\": \"marketplace\",\n \"data_rules\": {\n \"attributes\": [\n {\n \"attribute_id\": 32,\n \"fields\": [\n {\n \"field\": \"customer_v1.id.type\",\n \"filter\": {\n \"type\": \"include\",\n \"list\": [\n \"idfa\"\n ]\n },\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.id.value\",\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.name.full_name\",\n \"exported\": true\n }\n ],\n \"optional\": false\n },\n {\n \"attribute_id\": 45,\n \"fields\": [\n {\n \"field\": \"event_timestamp_v2\",\n \"filter\": {\n \"recency\": \"P180D\"\n },\n \"exported\": true\n }\n ],\n \"optional\": true\n },\n {\n \"attribute_id\": 30,\n \"fields\": [\n {\n \"field\": \"product_v2.name\",\n \"exported\": true\n }\n ],\n \"optional\": true\n }\n ],\n \"deduplication\": {\n \"period\": \"P90D\",\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ]\n },\n \"frequency_filter\": {\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ],\n \"min_inclusive\": 2,\n \"max_inclusive\": 5\n }\n },\n \"pricing\": {\n \"micro_cents_usd\": 1000000000\n }\n },\n \"name\": \"subscription name\",\n \"cadence\": \"monthly\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/data-shops/subscriptions/{subscription_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 \"budget\": {\n \"amount\": {\n \"value\": 250,\n \"currency\": \"USD\"\n },\n \"period\": {\n \"type\": \"calendar_monthly\"\n }\n },\n \"description\": \"subscription description\",\n \"details\": {\n \"type\": \"marketplace\",\n \"data_rules\": {\n \"attributes\": [\n {\n \"attribute_id\": 32,\n \"fields\": [\n {\n \"field\": \"customer_v1.id.type\",\n \"filter\": {\n \"type\": \"include\",\n \"list\": [\n \"idfa\"\n ]\n },\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.id.value\",\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.name.full_name\",\n \"exported\": true\n }\n ],\n \"optional\": false\n },\n {\n \"attribute_id\": 45,\n \"fields\": [\n {\n \"field\": \"event_timestamp_v2\",\n \"filter\": {\n \"recency\": \"P180D\"\n },\n \"exported\": true\n }\n ],\n \"optional\": true\n },\n {\n \"attribute_id\": 30,\n \"fields\": [\n {\n \"field\": \"product_v2.name\",\n \"exported\": true\n }\n ],\n \"optional\": true\n }\n ],\n \"deduplication\": {\n \"period\": \"P90D\",\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ]\n },\n \"frequency_filter\": {\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ],\n \"min_inclusive\": 2,\n \"max_inclusive\": 5\n }\n },\n \"pricing\": {\n \"micro_cents_usd\": 1000000000\n }\n },\n \"name\": \"subscription name\",\n \"cadence\": \"monthly\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"budget": {
"amount": {
"currency": "USD",
"value": 123
},
"period": {}
},
"company_id": 123,
"created_at": "<string>",
"name": "<string>",
"updated_at": "<string>",
"cancelled_at": "<string>",
"description": "<string>",
"details": {
"type": "data_stream",
"data_rules": {
"column_sets": [
{
"dataset_id": 123,
"fields": [
{
"field": "/id/value",
"exported": true,
"filter": "include_all_values_including_nulls_filter"
}
]
}
],
"attributes": [
{
"attribute_id": 123,
"fields": [
{
"field": "/id/value",
"exported": true,
"filter": "include_all_values_including_nulls_filter"
}
],
"optional": true
}
],
"deduplication": {
"period": "<string>",
"column_references": [
{
"dataset_id": 123,
"column_names": [
"/id/value"
]
}
],
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"/id/value"
]
}
]
},
"frequency_filter": {
"column_references": [
{
"dataset_id": 123,
"column_names": [
"/id/value"
]
}
],
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"/id/value"
]
}
],
"min_inclusive": 123,
"max_inclusive": 123
},
"dataset_filter": {
"dataset_id": 123,
"attribute": {
"attribute_id": 123,
"field": "/id/value"
}
}
},
"data_shop_id": "<string>",
"data_stream_company_id": 123,
"data_stream_content": {
"description": "<string>",
"icon": "<string>",
"sections": [
{}
]
},
"data_stream_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"data_stream_name": "<string>",
"data_stream_slug": "<string>",
"offer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"licensing": {
"period": "<string>",
"license": {
"name": "<string>"
}
},
"pricing": {
"micro_cents_usd": 123
},
"shops": [
"<string>"
]
}
},
"output": {
"dataset_id": 123
}
}Update a subscription
Update a subscription
NOTE: If the cadence of the subscription is modified, the frequency filter will automatically be adjusted to match the new cadence.
curl --request PUT \
--url https://api-dev.narrative.io/data-shops/subscriptions/{subscription_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"budget": {
"amount": {
"value": 250,
"currency": "USD"
},
"period": {
"type": "calendar_monthly"
}
},
"description": "subscription description",
"details": {
"type": "marketplace",
"data_rules": {
"attributes": [
{
"attribute_id": 32,
"fields": [
{
"field": "customer_v1.id.type",
"filter": {
"type": "include",
"list": [
"idfa"
]
},
"exported": true
},
{
"field": "customer_v1.id.value",
"exported": true
},
{
"field": "customer_v1.name.full_name",
"exported": true
}
],
"optional": false
},
{
"attribute_id": 45,
"fields": [
{
"field": "event_timestamp_v2",
"filter": {
"recency": "P180D"
},
"exported": true
}
],
"optional": true
},
{
"attribute_id": 30,
"fields": [
{
"field": "product_v2.name",
"exported": true
}
],
"optional": true
}
],
"deduplication": {
"period": "P90D",
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"event_timestamp_v2"
]
}
]
},
"frequency_filter": {
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"event_timestamp_v2"
]
}
],
"min_inclusive": 2,
"max_inclusive": 5
}
},
"pricing": {
"micro_cents_usd": 1000000000
}
},
"name": "subscription name",
"cadence": "monthly"
}
'import requests
url = "https://api-dev.narrative.io/data-shops/subscriptions/{subscription_id}"
payload = {
"budget": {
"amount": {
"value": 250,
"currency": "USD"
},
"period": { "type": "calendar_monthly" }
},
"description": "subscription description",
"details": {
"type": "marketplace",
"data_rules": {
"attributes": [
{
"attribute_id": 32,
"fields": [
{
"field": "customer_v1.id.type",
"filter": {
"type": "include",
"list": ["idfa"]
},
"exported": True
},
{
"field": "customer_v1.id.value",
"exported": True
},
{
"field": "customer_v1.name.full_name",
"exported": True
}
],
"optional": False
},
{
"attribute_id": 45,
"fields": [
{
"field": "event_timestamp_v2",
"filter": { "recency": "P180D" },
"exported": True
}
],
"optional": True
},
{
"attribute_id": 30,
"fields": [
{
"field": "product_v2.name",
"exported": True
}
],
"optional": True
}
],
"deduplication": {
"period": "P90D",
"attribute_references": [
{
"attribute_id": 123,
"column_names": ["event_timestamp_v2"]
}
]
},
"frequency_filter": {
"attribute_references": [
{
"attribute_id": 123,
"column_names": ["event_timestamp_v2"]
}
],
"min_inclusive": 2,
"max_inclusive": 5
}
},
"pricing": { "micro_cents_usd": 1000000000 }
},
"name": "subscription name",
"cadence": "monthly"
}
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({
budget: {amount: {value: 250, currency: 'USD'}, period: {type: 'calendar_monthly'}},
description: 'subscription description',
details: {
type: 'marketplace',
data_rules: {
attributes: [
{
attribute_id: 32,
fields: [
{
field: 'customer_v1.id.type',
filter: {type: 'include', list: ['idfa']},
exported: true
},
{field: 'customer_v1.id.value', exported: true},
{field: 'customer_v1.name.full_name', exported: true}
],
optional: false
},
{
attribute_id: 45,
fields: [{field: 'event_timestamp_v2', filter: {recency: 'P180D'}, exported: true}],
optional: true
},
{
attribute_id: 30,
fields: [{field: 'product_v2.name', exported: true}],
optional: true
}
],
deduplication: {
period: 'P90D',
attribute_references: [{attribute_id: 123, column_names: ['event_timestamp_v2']}]
},
frequency_filter: {
attribute_references: [{attribute_id: 123, column_names: ['event_timestamp_v2']}],
min_inclusive: 2,
max_inclusive: 5
}
},
pricing: {micro_cents_usd: 1000000000}
},
name: 'subscription name',
cadence: 'monthly'
})
};
fetch('https://api-dev.narrative.io/data-shops/subscriptions/{subscription_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/data-shops/subscriptions/{subscription_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([
'budget' => [
'amount' => [
'value' => 250,
'currency' => 'USD'
],
'period' => [
'type' => 'calendar_monthly'
]
],
'description' => 'subscription description',
'details' => [
'type' => 'marketplace',
'data_rules' => [
'attributes' => [
[
'attribute_id' => 32,
'fields' => [
[
'field' => 'customer_v1.id.type',
'filter' => [
'type' => 'include',
'list' => [
'idfa'
]
],
'exported' => true
],
[
'field' => 'customer_v1.id.value',
'exported' => true
],
[
'field' => 'customer_v1.name.full_name',
'exported' => true
]
],
'optional' => false
],
[
'attribute_id' => 45,
'fields' => [
[
'field' => 'event_timestamp_v2',
'filter' => [
'recency' => 'P180D'
],
'exported' => true
]
],
'optional' => true
],
[
'attribute_id' => 30,
'fields' => [
[
'field' => 'product_v2.name',
'exported' => true
]
],
'optional' => true
]
],
'deduplication' => [
'period' => 'P90D',
'attribute_references' => [
[
'attribute_id' => 123,
'column_names' => [
'event_timestamp_v2'
]
]
]
],
'frequency_filter' => [
'attribute_references' => [
[
'attribute_id' => 123,
'column_names' => [
'event_timestamp_v2'
]
]
],
'min_inclusive' => 2,
'max_inclusive' => 5
]
],
'pricing' => [
'micro_cents_usd' => 1000000000
]
],
'name' => 'subscription name',
'cadence' => 'monthly'
]),
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/data-shops/subscriptions/{subscription_id}"
payload := strings.NewReader("{\n \"budget\": {\n \"amount\": {\n \"value\": 250,\n \"currency\": \"USD\"\n },\n \"period\": {\n \"type\": \"calendar_monthly\"\n }\n },\n \"description\": \"subscription description\",\n \"details\": {\n \"type\": \"marketplace\",\n \"data_rules\": {\n \"attributes\": [\n {\n \"attribute_id\": 32,\n \"fields\": [\n {\n \"field\": \"customer_v1.id.type\",\n \"filter\": {\n \"type\": \"include\",\n \"list\": [\n \"idfa\"\n ]\n },\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.id.value\",\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.name.full_name\",\n \"exported\": true\n }\n ],\n \"optional\": false\n },\n {\n \"attribute_id\": 45,\n \"fields\": [\n {\n \"field\": \"event_timestamp_v2\",\n \"filter\": {\n \"recency\": \"P180D\"\n },\n \"exported\": true\n }\n ],\n \"optional\": true\n },\n {\n \"attribute_id\": 30,\n \"fields\": [\n {\n \"field\": \"product_v2.name\",\n \"exported\": true\n }\n ],\n \"optional\": true\n }\n ],\n \"deduplication\": {\n \"period\": \"P90D\",\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ]\n },\n \"frequency_filter\": {\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ],\n \"min_inclusive\": 2,\n \"max_inclusive\": 5\n }\n },\n \"pricing\": {\n \"micro_cents_usd\": 1000000000\n }\n },\n \"name\": \"subscription name\",\n \"cadence\": \"monthly\"\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/data-shops/subscriptions/{subscription_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"budget\": {\n \"amount\": {\n \"value\": 250,\n \"currency\": \"USD\"\n },\n \"period\": {\n \"type\": \"calendar_monthly\"\n }\n },\n \"description\": \"subscription description\",\n \"details\": {\n \"type\": \"marketplace\",\n \"data_rules\": {\n \"attributes\": [\n {\n \"attribute_id\": 32,\n \"fields\": [\n {\n \"field\": \"customer_v1.id.type\",\n \"filter\": {\n \"type\": \"include\",\n \"list\": [\n \"idfa\"\n ]\n },\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.id.value\",\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.name.full_name\",\n \"exported\": true\n }\n ],\n \"optional\": false\n },\n {\n \"attribute_id\": 45,\n \"fields\": [\n {\n \"field\": \"event_timestamp_v2\",\n \"filter\": {\n \"recency\": \"P180D\"\n },\n \"exported\": true\n }\n ],\n \"optional\": true\n },\n {\n \"attribute_id\": 30,\n \"fields\": [\n {\n \"field\": \"product_v2.name\",\n \"exported\": true\n }\n ],\n \"optional\": true\n }\n ],\n \"deduplication\": {\n \"period\": \"P90D\",\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ]\n },\n \"frequency_filter\": {\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ],\n \"min_inclusive\": 2,\n \"max_inclusive\": 5\n }\n },\n \"pricing\": {\n \"micro_cents_usd\": 1000000000\n }\n },\n \"name\": \"subscription name\",\n \"cadence\": \"monthly\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/data-shops/subscriptions/{subscription_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 \"budget\": {\n \"amount\": {\n \"value\": 250,\n \"currency\": \"USD\"\n },\n \"period\": {\n \"type\": \"calendar_monthly\"\n }\n },\n \"description\": \"subscription description\",\n \"details\": {\n \"type\": \"marketplace\",\n \"data_rules\": {\n \"attributes\": [\n {\n \"attribute_id\": 32,\n \"fields\": [\n {\n \"field\": \"customer_v1.id.type\",\n \"filter\": {\n \"type\": \"include\",\n \"list\": [\n \"idfa\"\n ]\n },\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.id.value\",\n \"exported\": true\n },\n {\n \"field\": \"customer_v1.name.full_name\",\n \"exported\": true\n }\n ],\n \"optional\": false\n },\n {\n \"attribute_id\": 45,\n \"fields\": [\n {\n \"field\": \"event_timestamp_v2\",\n \"filter\": {\n \"recency\": \"P180D\"\n },\n \"exported\": true\n }\n ],\n \"optional\": true\n },\n {\n \"attribute_id\": 30,\n \"fields\": [\n {\n \"field\": \"product_v2.name\",\n \"exported\": true\n }\n ],\n \"optional\": true\n }\n ],\n \"deduplication\": {\n \"period\": \"P90D\",\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ]\n },\n \"frequency_filter\": {\n \"attribute_references\": [\n {\n \"attribute_id\": 123,\n \"column_names\": [\n \"event_timestamp_v2\"\n ]\n }\n ],\n \"min_inclusive\": 2,\n \"max_inclusive\": 5\n }\n },\n \"pricing\": {\n \"micro_cents_usd\": 1000000000\n }\n },\n \"name\": \"subscription name\",\n \"cadence\": \"monthly\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"budget": {
"amount": {
"currency": "USD",
"value": 123
},
"period": {}
},
"company_id": 123,
"created_at": "<string>",
"name": "<string>",
"updated_at": "<string>",
"cancelled_at": "<string>",
"description": "<string>",
"details": {
"type": "data_stream",
"data_rules": {
"column_sets": [
{
"dataset_id": 123,
"fields": [
{
"field": "/id/value",
"exported": true,
"filter": "include_all_values_including_nulls_filter"
}
]
}
],
"attributes": [
{
"attribute_id": 123,
"fields": [
{
"field": "/id/value",
"exported": true,
"filter": "include_all_values_including_nulls_filter"
}
],
"optional": true
}
],
"deduplication": {
"period": "<string>",
"column_references": [
{
"dataset_id": 123,
"column_names": [
"/id/value"
]
}
],
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"/id/value"
]
}
]
},
"frequency_filter": {
"column_references": [
{
"dataset_id": 123,
"column_names": [
"/id/value"
]
}
],
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"/id/value"
]
}
],
"min_inclusive": 123,
"max_inclusive": 123
},
"dataset_filter": {
"dataset_id": 123,
"attribute": {
"attribute_id": 123,
"field": "/id/value"
}
}
},
"data_shop_id": "<string>",
"data_stream_company_id": 123,
"data_stream_content": {
"description": "<string>",
"icon": "<string>",
"sections": [
{}
]
},
"data_stream_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"data_stream_name": "<string>",
"data_stream_slug": "<string>",
"offer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"licensing": {
"period": "<string>",
"license": {
"name": "<string>"
}
},
"pricing": {
"micro_cents_usd": 123
},
"shops": [
"<string>"
]
}
},
"output": {
"dataset_id": 123
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Unique identifier for a subscription.
Body
The maximum amount that can be spent as part of a subscription in a given time period. Once the budget has been exhausted in a given time period no more data is transacted until the start of the next one.
E.g. with a budget of $100 USD and a period of calendar_monthly you're guaranteed that you will not be charged more than $100 for your subscription in a given month.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
A human-friendly name for the subscription.
A human-friendly description of the subscription.
The cadence at which the subscription will be executed.
once: the subscription will run only once.hourly: the subscription run every hour.daily: the subscription run once per day.weekly: the subscription run once per week.monthly: the subscription run once per month.
once, hourly, daily, weekly, monthly Response
OK
Unique identifier for the subscription.
The maximum amount that can be spent as part of a subscription in a given time period. Once the budget has been exhausted in a given time period no more data is transacted until the start of the next one.
E.g. with a budget of $100 USD and a period of calendar_monthly you're guaranteed that you will not be charged more than $100 for your subscription in a given month.
Show child attributes
Show child attributes
Unique identifier for the company to which the subscription belongs.
ISO-8601 timestamp indicating when the subscription rule was created.
A human-friendly name for the subscription.
The current state of the subscription.
active: the subscription is active, data is being purchased regularly.cancelled: the subscription has been cancelled, but not deleted.pending: the subscription has been created but is not yet active, not data is being purchased as part of the subscription.kickoff: the subscription is kicking off (immediate run) prior to activation.completed: the subscription as run once as requested and is completed.
active, cancelled, pending, archived, kickoff, completed ISO-8601 timestamp indicating when the subscription rule was created.
ISO-8601 timestamp indicating when the subscription was cancelled.
A human-friendly description of the subscription.
- Option 1
- Option 2
Show child attributes
Show child attributes
Show child attributes
Show child attributes
The cadence at which the subscription will be executed.
once: the subscription will run only once.hourly: the subscription run every hour.daily: the subscription run once per day.weekly: the subscription run once per week.monthly: the subscription run once per month.
once, hourly, daily, weekly, monthly Was this page helpful?

