Audience Segments
Create audience segment
Saves a named rule set over the team’s audience profiles. A team holds at most 100 segments. Every campaign a rule names must belong to the team. Both audience betas, campaigns.audience-profiles and campaigns.segments, must be available; otherwise the request answers 403 feature_unavailable.
API keys require campaigns:manage. Project tokens are not accepted.
POST
/
platform
/
audience-segments
Create audience segment
curl --request POST \
--url https://api.polymorfa.com/platform/audience-segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rules": {
"groups": [
{
"conditions": [
{
"field": "tag",
"operator": "contains",
"value": "<string>"
}
],
"negate": true
}
]
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
rules: {
groups: [
{
conditions: [{field: 'tag', operator: 'contains', value: '<string>'}],
negate: true
}
]
}
})
};
fetch('https://api.polymorfa.com/platform/audience-segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/platform/audience-segments"
payload = {
"name": "<string>",
"rules": { "groups": [
{
"conditions": [
{
"field": "tag",
"operator": "contains",
"value": "<string>"
}
],
"negate": True
}
] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/platform/audience-segments"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"rules\": {\n \"groups\": [\n {\n \"conditions\": [\n {\n \"field\": \"tag\",\n \"operator\": \"contains\",\n \"value\": \"<string>\"\n }\n ],\n \"negate\": true\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))
}false{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"revision": 2,
"rules": {
"match": "all",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "tag",
"operator": "contains",
"value": "<string>"
}
],
"negate": true
}
]
},
"createdAt": 1,
"updatedAt": 1
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}Authorizations
Send your team API key or project token as Authorization: Bearer <token>. The credential must have the required permissions. Project tokens can access only their own project.
Body
application/json
Response
Success
Structured data carried by this object.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Create audience segment
curl --request POST \
--url https://api.polymorfa.com/platform/audience-segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rules": {
"groups": [
{
"conditions": [
{
"field": "tag",
"operator": "contains",
"value": "<string>"
}
],
"negate": true
}
]
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
rules: {
groups: [
{
conditions: [{field: 'tag', operator: 'contains', value: '<string>'}],
negate: true
}
]
}
})
};
fetch('https://api.polymorfa.com/platform/audience-segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/platform/audience-segments"
payload = {
"name": "<string>",
"rules": { "groups": [
{
"conditions": [
{
"field": "tag",
"operator": "contains",
"value": "<string>"
}
],
"negate": True
}
] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/platform/audience-segments"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"rules\": {\n \"groups\": [\n {\n \"conditions\": [\n {\n \"field\": \"tag\",\n \"operator\": \"contains\",\n \"value\": \"<string>\"\n }\n ],\n \"negate\": true\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))
}false{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"revision": 2,
"rules": {
"match": "all",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "tag",
"operator": "contains",
"value": "<string>"
}
],
"negate": true
}
]
},
"createdAt": 1,
"updatedAt": 1
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"request_log_url": "<string>"
},
"data": null,
"docs": "<string>"
}