{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/apps/:app_id/segments","auth":"required","examples":{"codes":[{"language":"shell","name":"","code":"curl -X POST \"https://control.pulsatehq.com/api/v1/apps/$APP_ID/segments\"\n  -H \"Authorization: Token token=$MY_ADMIN_API_TOKEN\"\n  -d '{\n      \"segment\": {\n          \"name\": \"new_segment_name\",\n          \"groups\": [\n              {\n                  \"rules\": [\n                      {\n                        \"time_frame\": \"\",\n                        \"match_type\": \"less\",\n                        \"match_value\": \"123\",\n                        \"match_end_value\": \"\",\n                        \"event_resource_type\": \"geofence\",\n                        \"event_resource\": {\n                          \"guid\": \"QrqsYSC4\"\n                        },\n                        \"type\": \"number_of_visits\"\n                      }\n                  ]\n              }\n          ]\n      }\n  }'"}]},"method":"post","params":[{"name":"app_id","type":"string","default":"","desc":"App ID. It can be fetched by using \"Apps: Get All (Index)\" or \"Apps: Get One (Show)\" endpoints.","required":true,"in":"path","ref":"","_id":"57ff8296159c7e0e003c4825"},{"name":"segment","type":"object","default":"","desc":"Segment to be created","required":true,"in":"body","ref":"","_id":"564c431b61008d17006ffa47"},{"name":"segment.name","type":"string","default":"","desc":"Name of the segment","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb43"},{"name":"segment.groups","type":"array_object","default":"","desc":"Array of groups for segment","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb42"},{"name":"segment.groups[].rules","type":"array_object","default":"","desc":"Array of rules for group","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb41"},{"name":"segment.groups[].rules[].type","type":"string","default":"","desc":"Type for the rule, use /api/v1/apps/:app_id/segments/rules for available rules types","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb40"},{"name":"segment.groups[].rules[].time_frame","type":"string","default":"","desc":"Time frame for the rule, can be one of: ['', 'minutes', 'hours', 'days', 'weeks', 'months', 'years']","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb3f"},{"name":"segment.groups[].rules[].match_type","type":"string","default":"","desc":"Match type for the rule, use /api/v1/apps/:app_id/segments/rules for available rules match types","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb3e"},{"name":"segment.groups[].rules[].match_value","type":"string","default":"","desc":"Match value for the rule","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb3d"},{"name":"segment.groups[].rules[].match_end_value","type":"string","default":"","desc":"Match end value for the rule. Combined with match_value can be use for \"between\" rule","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb3c"},{"name":"segment.groups[].rules[].event_resource_type","type":"string","default":"","desc":"Event resource type for the rule, can be one of: ['', 'beacon', 'geofence']","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb3b"},{"name":"segment.groups[].rules[].event_resource","type":"object","default":"","desc":"Event resource for the rule","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb3a"},{"name":"segment.groups[].rules[].event_resource.guid","type":"string","default":"","desc":"Geofence guid for the event resource","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb39"},{"name":"segment.groups[].rules[].event_resource.guid","type":"string","default":"","desc":"Beacons UUID for the event resource","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb38"},{"name":"segment.groups[].rules[].event_resource.major","type":"string","default":"","desc":"Beacons major for the event resource","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb37"},{"name":"segment.groups[].rules[].event_resource.minor","type":"string","default":"","desc":"Beacons minor for the event resource","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb36"},{"name":"segment.groups[].rules[].event_resource.id","type":"string","default":"","desc":"Group id, used for targeting groups of resources.","required":false,"in":"body","ref":"","_id":"599fe9c3f1d56f000f243467"},{"name":"segment.groups[].rules[].locations","type":"array_object","default":"","desc":"Locations for the rule","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb35"},{"name":"segment.groups[].rules[].locations[].values","type":"array_object","default":"","desc":"Values for the locations","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb34"},{"name":"segment.groups[].rules[].locations[].values.center","type":"array_double","default":"","desc":"Center location of geofence circle as [longitude, latitude]","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb33"},{"name":"segment.groups[].rules[].locations[].values.radius","type":"string","default":"","desc":"Radius for the values in meters","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb32"},{"name":"segment.groups[].rules[].locations[].values.type","type":"string","default":"","desc":"Type of the value, can be one of: ['point']","required":false,"in":"body","ref":"","_id":"587653c2bed1710f00f9eb31"}],"results":{"codes":[{"language":"json","code":"{\n  \"segment\": {\n    \"name\": \"new_segment_name\",\n    \"groups\": [\n      {\n        \"rules\": [\n          {\n            \"time_frame\": \"\",\n            \"match_type\": \"less\",\n            \"match_value\": \"123\",\n            \"match_end_value\": \"\",\n            \"event_resource_type\": \"geofence\",\n            \"event_resource\": {\n              \"guid\": \"QrqsYSC4\"\n            },\n            \"type\": \"number_of_visits\"\n          }\n        ]\n      }\n    ],\n    \"id\": \"587650da636f6e3a0c0b0500\"\n  }\n}","name":"","status":200}]},"settings":"564bbbf80cbcc91700b8171c"},"next":{"description":"","pages":[]},"title":"Segments: Create One","type":"endpoint","slug":"segments-create-one","excerpt":"","body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Segment anatomy\",\n  \"body\": \"Pulsate Segment is a tool of grouping users matching a specified criteria list. It consists of one or more groups, which in turn consist of one or more rules.\\n\\nTo be matched by a segment group, user has to fulfill any of the criteria specified by its rules. However, to belong to a segment, user has to be matched by all of its groups.\\n\\n**Example**\\nLet's say one wants to create a segment that matches all users named \\\"Phil\\\" or \\\"Mark\\\", who entered a specified geofence twice. It would have two groups, one containing two rules: \\\"first name is Phil\\\" and \\\"first name is Mark\\\", second one containing just one rule: \\\"been at geofence two times\\\".\"\n}\n[/block]","updates":[],"order":54,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5e4fced159815700262d28cb","category":{"sync":{"isSync":false,"url":""},"pages":["5e4fced159815700262d28c6","5e4fced159815700262d28c7","5e4fced159815700262d28c8","5e4fced159815700262d28c9","5e4fced159815700262d28ca","5e4fced159815700262d28cb","5e4fced159815700262d28cc","5e4fced159815700262d28cd","5e4fced159815700262d28ce","564c68a93eb8f81700838a25"],"title":"Pulsate CMS API","slug":"pulsate-cms-api","order":1,"from_sync":false,"reference":true,"_id":"5e4fced159815700262d289e","__v":10,"createdAt":"2015-11-17T23:47:10.058Z","project":"54aa7f773b56130b0056c86e","version":"5e4fced159815700262d2930"},"createdAt":"2015-11-18T09:21:31.903Z","editedParams2":true,"githubsync":"","parentDoc":null,"__v":6,"editedParams":true,"version":{"version":"2.2","version_clean":"2.2.0","codename":"CMS API","is_stable":false,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5e4fced159815700262d2899","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","5e4fced159815700262d289a","5e4fced159815700262d289b","5e4fced159815700262d289c","5e4fced159815700262d289d","5e4fced159815700262d289e","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","5e4fced159815700262d289f","5e4fced159815700262d28a0","5c73dd27e8fdc000572a206a","5e4fced159815700262d28a1","5e53c04c1d11110018b56e12"],"_id":"5e4fced159815700262d2930","project":"54aa7f773b56130b0056c86e","forked_from":"55781fe25129590d003ff4f7","__v":1,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z"},"project":"54aa7f773b56130b0056c86e","user":"54aa7f3f9bb00c0b00cb899b"}

postSegments: Create One


Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

app_id:
required
string
App ID. It can be fetched by using "Apps: Get All (Index)" or "Apps: Get One (Show)" endpoints.

Body Params

segment:
required
object
Segment to be created
segment.name:
string
Name of the segment
segment.groups:
array of objects
Array of groups for segment
segment.groups[].rules:
array of objects
Array of rules for group
segment.groups[].rules[].type:
string
Type for the rule, use /api/v1/apps/:app_id/segments/rules for available rules types
segment.groups[].rules[].time_frame:
string
Time frame for the rule, can be one of: ['', 'minutes', 'hours', 'days', 'weeks', 'months', 'years']
segment.groups[].rules[].match_type:
string
Match type for the rule, use /api/v1/apps/:app_id/segments/rules for available rules match types
segment.groups[].rules[].match_value:
string
Match value for the rule
segment.groups[].rules[].match_end_value:
string
Match end value for the rule. Combined with match_value can be use for "between" rule
segment.groups[].rules[].event_resource_type:
string
Event resource type for the rule, can be one of: ['', 'beacon', 'geofence']
segment.groups[].rules[].event_resource:
object
Event resource for the rule
segment.groups[].rules[].event_resource.guid:
string
Geofence guid for the event resource
segment.groups[].rules[].event_resource.guid:
string
Beacons UUID for the event resource
segment.groups[].rules[].event_resource.major:
string
Beacons major for the event resource
segment.groups[].rules[].event_resource.minor:
string
Beacons minor for the event resource
segment.groups[].rules[].event_resource.id:
string
Group id, used for targeting groups of resources.
segment.groups[].rules[].locations:
array of objects
Locations for the rule
segment.groups[].rules[].locations[].values:
array of objects
Values for the locations
segment.groups[].rules[].locations[].values.center:
array of doubles
Center location of geofence circle as [longitude, latitude]
segment.groups[].rules[].locations[].values.radius:
string
Radius for the values in meters
segment.groups[].rules[].locations[].values.type:
string
Type of the value, can be one of: ['point']

Examples


Result Format


Documentation

[block:callout] { "type": "info", "title": "Segment anatomy", "body": "Pulsate Segment is a tool of grouping users matching a specified criteria list. It consists of one or more groups, which in turn consist of one or more rules.\n\nTo be matched by a segment group, user has to fulfill any of the criteria specified by its rules. However, to belong to a segment, user has to be matched by all of its groups.\n\n**Example**\nLet's say one wants to create a segment that matches all users named \"Phil\" or \"Mark\", who entered a specified geofence twice. It would have two groups, one containing two rules: \"first name is Phil\" and \"first name is Mark\", second one containing just one rule: \"been at geofence two times\"." } [/block]

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}