Batch update operations.
curl --request PATCH \
--url https://api.permutive.app/audience-api/v1/imports/{importId}/segments \
--header 'Content-Type: application/json' \
--data '
{
"operations": [
{
"data": {
"name": "segment",
"code": "1234",
"description": "segment description",
"cpm": 2,
"categories": [
"category1"
]
},
"operation": "Create"
},
{
"code": "12345",
"operation": "Delete"
},
{
"code": "1234",
"data": {
"name": "segment",
"description": "segment description",
"cpm": 2,
"categories": [
"category1"
]
},
"operation": "Update"
}
]
}
'import requests
url = "https://api.permutive.app/audience-api/v1/imports/{importId}/segments"
payload = { "operations": [
{
"data": {
"name": "segment",
"code": "1234",
"description": "segment description",
"cpm": 2,
"categories": ["category1"]
},
"operation": "Create"
},
{
"code": "12345",
"operation": "Delete"
},
{
"code": "1234",
"data": {
"name": "segment",
"description": "segment description",
"cpm": 2,
"categories": ["category1"]
},
"operation": "Update"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
operations: [
{
data: {
name: 'segment',
code: '1234',
description: 'segment description',
cpm: 2,
categories: ['category1']
},
operation: 'Create'
},
{code: '12345', operation: 'Delete'},
{
code: '1234',
data: {
name: 'segment',
description: 'segment description',
cpm: 2,
categories: ['category1']
},
operation: 'Update'
}
]
})
};
fetch('https://api.permutive.app/audience-api/v1/imports/{importId}/segments', 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.permutive.app/audience-api/v1/imports/{importId}/segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'operations' => [
[
'data' => [
'name' => 'segment',
'code' => '1234',
'description' => 'segment description',
'cpm' => 2,
'categories' => [
'category1'
]
],
'operation' => 'Create'
],
[
'code' => '12345',
'operation' => 'Delete'
],
[
'code' => '1234',
'data' => [
'name' => 'segment',
'description' => 'segment description',
'cpm' => 2,
'categories' => [
'category1'
]
],
'operation' => 'Update'
]
]
]),
CURLOPT_HTTPHEADER => [
"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.permutive.app/audience-api/v1/imports/{importId}/segments"
payload := strings.NewReader("{\n \"operations\": [\n {\n \"data\": {\n \"name\": \"segment\",\n \"code\": \"1234\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Create\"\n },\n {\n \"code\": \"12345\",\n \"operation\": \"Delete\"\n },\n {\n \"code\": \"1234\",\n \"data\": {\n \"name\": \"segment\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Update\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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.patch("https://api.permutive.app/audience-api/v1/imports/{importId}/segments")
.header("Content-Type", "application/json")
.body("{\n \"operations\": [\n {\n \"data\": {\n \"name\": \"segment\",\n \"code\": \"1234\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Create\"\n },\n {\n \"code\": \"12345\",\n \"operation\": \"Delete\"\n },\n {\n \"code\": \"1234\",\n \"data\": {\n \"name\": \"segment\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Update\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.permutive.app/audience-api/v1/imports/{importId}/segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"operations\": [\n {\n \"data\": {\n \"name\": \"segment\",\n \"code\": \"1234\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Create\"\n },\n {\n \"code\": \"12345\",\n \"operation\": \"Delete\"\n },\n {\n \"code\": \"1234\",\n \"data\": {\n \"name\": \"segment\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Update\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "1b890475-1482-496d-bcfd-6b2f5564b249",
"code": "1234",
"name": "Segment Name",
"import_id": "9f87bd3e-32eb-4d15-8e85-17fb275fa809",
"description": "segment description",
"cpm": 2,
"categories": [
"category_1"
],
"updated_at": "2023-04-12T11:27:00.716632Z"
}
]
}"<string>"{
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"error": {
"c": "<string>",
"d": {}
}
}Taxonomy API
Batch update segments
Note that operation order is not guaranteed. No more than 5,000 operations can be contained in a batch.
PATCH
/
imports
/
{importId}
/
segments
Batch update operations.
curl --request PATCH \
--url https://api.permutive.app/audience-api/v1/imports/{importId}/segments \
--header 'Content-Type: application/json' \
--data '
{
"operations": [
{
"data": {
"name": "segment",
"code": "1234",
"description": "segment description",
"cpm": 2,
"categories": [
"category1"
]
},
"operation": "Create"
},
{
"code": "12345",
"operation": "Delete"
},
{
"code": "1234",
"data": {
"name": "segment",
"description": "segment description",
"cpm": 2,
"categories": [
"category1"
]
},
"operation": "Update"
}
]
}
'import requests
url = "https://api.permutive.app/audience-api/v1/imports/{importId}/segments"
payload = { "operations": [
{
"data": {
"name": "segment",
"code": "1234",
"description": "segment description",
"cpm": 2,
"categories": ["category1"]
},
"operation": "Create"
},
{
"code": "12345",
"operation": "Delete"
},
{
"code": "1234",
"data": {
"name": "segment",
"description": "segment description",
"cpm": 2,
"categories": ["category1"]
},
"operation": "Update"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
operations: [
{
data: {
name: 'segment',
code: '1234',
description: 'segment description',
cpm: 2,
categories: ['category1']
},
operation: 'Create'
},
{code: '12345', operation: 'Delete'},
{
code: '1234',
data: {
name: 'segment',
description: 'segment description',
cpm: 2,
categories: ['category1']
},
operation: 'Update'
}
]
})
};
fetch('https://api.permutive.app/audience-api/v1/imports/{importId}/segments', 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.permutive.app/audience-api/v1/imports/{importId}/segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'operations' => [
[
'data' => [
'name' => 'segment',
'code' => '1234',
'description' => 'segment description',
'cpm' => 2,
'categories' => [
'category1'
]
],
'operation' => 'Create'
],
[
'code' => '12345',
'operation' => 'Delete'
],
[
'code' => '1234',
'data' => [
'name' => 'segment',
'description' => 'segment description',
'cpm' => 2,
'categories' => [
'category1'
]
],
'operation' => 'Update'
]
]
]),
CURLOPT_HTTPHEADER => [
"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.permutive.app/audience-api/v1/imports/{importId}/segments"
payload := strings.NewReader("{\n \"operations\": [\n {\n \"data\": {\n \"name\": \"segment\",\n \"code\": \"1234\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Create\"\n },\n {\n \"code\": \"12345\",\n \"operation\": \"Delete\"\n },\n {\n \"code\": \"1234\",\n \"data\": {\n \"name\": \"segment\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Update\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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.patch("https://api.permutive.app/audience-api/v1/imports/{importId}/segments")
.header("Content-Type", "application/json")
.body("{\n \"operations\": [\n {\n \"data\": {\n \"name\": \"segment\",\n \"code\": \"1234\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Create\"\n },\n {\n \"code\": \"12345\",\n \"operation\": \"Delete\"\n },\n {\n \"code\": \"1234\",\n \"data\": {\n \"name\": \"segment\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Update\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.permutive.app/audience-api/v1/imports/{importId}/segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"operations\": [\n {\n \"data\": {\n \"name\": \"segment\",\n \"code\": \"1234\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Create\"\n },\n {\n \"code\": \"12345\",\n \"operation\": \"Delete\"\n },\n {\n \"code\": \"1234\",\n \"data\": {\n \"name\": \"segment\",\n \"description\": \"segment description\",\n \"cpm\": 2,\n \"categories\": [\n \"category1\"\n ]\n },\n \"operation\": \"Update\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "1b890475-1482-496d-bcfd-6b2f5564b249",
"code": "1234",
"name": "Segment Name",
"import_id": "9f87bd3e-32eb-4d15-8e85-17fb275fa809",
"description": "segment description",
"cpm": 2,
"categories": [
"category_1"
],
"updated_at": "2023-04-12T11:27:00.716632Z"
}
]
}"<string>"{
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"error": {
"c": "<string>",
"d": {}
}
}⌘I