Segments can be created, edited, deleted and viewed using the following REST api instructions. When you have created a segment, you can attach that list to a demand or supply tag for targeting.
Table of Contents
Creating a Segment
SDK
Use tab completion with SDK to auto-complete function names or show field options!Segments can be created, edited, deleted and viewed using the following REST api instructions. When you have created a segment, you can attach that list to a demand or supply tag for targeting.
Table of Contents
Creating a Segment
SDK
Use tab completion with SDK to auto-complete function names or show field options!
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.new({'account_id':1, 'name':'my segment'})
In [3]: print segm_list.ok, segm_list.id
True 9 |
REST API
POST /api/v0/segments
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
Device ID Segment
{ "name" : "My , "description": "My Device description", "segment_type”: "list", "segment_list_type”: "device_id" } |
Cookie ID Segment
|
Required parameters: name. If not given a segment_type it will default to 'cookie'
Full options:
segment_type (list or pixel)
segment_list_type (cookie or device_id) – only applies when segment_type is list
segment_pixel_type (cookie or ip) – only applies when segment_type is pixel
Response
Status code 200
Code Block |
---|
{
"id": 10044,
"account_id": 1,
"name": "My DID Segment",
"description": "My description",
"active": true,
"segment_type": "list",
"segment_list_type": "cookie",
"created_at": "2020-03-18T19:17:01.383Z"
} |
Get a segment
SDK
Use tab completion with SDK to auto-complete function names or show field options!
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: segm_list.raw
Out[3]:
{'id': 10064,
'account_id': 1,
'name': 'test segment',
'description': None,
'active': True,
'segment_type': 'pixel',
'segment_pixel_type': 'cookie',
'user_expiration_value': None,
'created_at': '2021-02-11T22:05:47.412Z'}
|
REST API
GET /api/v0/segments/<id>
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Response
Status code 200
Code Block |
---|
{
"id": 10044,
"account_id": 1,
"name": "My DID Segment",
"description": "My description",
"active": true,
"segment_type": "list",
"segment_list_type": "cookie",
"created_at": "2020-03-18T19:17:01.383Z"
} |
Add elements to a Segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: add = segm_list.bulk_create(['123456789909nfejwnfkjewrjkweh8368721y6','123456789909nfejwnfkjewrjkweh8768765r7'])
In [4]: add.ok
Out[4]: True |
REST API
POST /api/v0/segments/<id>/items/bulk_create
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
Code Block |
---|
{
"items": ["d207654f-6bdd-474e-9734-67b7c3d02d96"]
}
|
Response
Status code 200
Code Block |
---|
{"created": True} |
Add Items to a Segment using a File
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve In [2]: segm_list = springserve.segment_lists.new({'account_id':1, 'name':'my segment'}) get(9) In [3]: add print= segm_list.ok, segm_list.id True 9bulk_create(file_path='/<filepath>/appending_segm_list.csv') In [4]: add.ok Out[4]: True |
REST API
POST POST /api/v0/segments
Headers
...
/<id>/items/file_bulk_create
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/segments/<id>/items/file_bulk_create' \ --header 'Content-Type: application/json' \ --header 'Authorization "yourAuthToken" |
Body (example)
Device ID Segment
...
{
"name"
:
"My Device
Segment"
,
"segment_list_type”: "device_id"
}
...
{
"name"
:
"My Cookie ID Segment"
,
"description": "My Cookie ID description"
"segment_type”: "list",
"segment_list_type”: "cookie"}
Required parameters: name. If not given a segment_type it will default to 'cookie'
Full options:
segment_type (list or pixel)
segment_list_type (cookie or device_id) – only applies when segment_type is list
segment_pixel_type (cookie or ip) – only applies when segment_type is pixel
Response
Status code 200
Code Block |
---|
{
"id": 10044,
"account_id": 1,
"name": "My DID Segment",
"description": "My description",
"active": true,
"segment_type": "list",
"segment_list_type": "cookie",
"created_at": "2020-03-18T19:17:01.383Z"
} |
Get a segment
SDK
...
: <yourAuthToken>' \
--form 'csv_file=@"/<filepath>/appending_items_to_segment_list.csv"' |
Response
Status code 201
Code Block |
---|
{"created": True} |
Replace Entire Segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: repl = segm_list.bulk_replace(['123456789909nfejwnfkjewrjkweh8368721y6'])
In [4]: repl.ok
Out[4]: True |
REST API
POST /api/v0/segments/<id>/items/bulk_replace
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken"
|
Body (example)
Code Block |
---|
{
"items": ["item1", "item2"]
} |
Response
Status code 201
Code Block |
---|
{"created": True} |
Replace Entire Segment with a File
Replaces segment with the items in the csv file
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: repl = segm.bulk_replace(file_path='/<filepath>/repl_segm_list.csv')
In [4]: repl.ok
Out[4]: True |
REST API
POST /api/v0/segments/<id>/items/file_bulk_replace
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/segments/<id>/items/file_bulk_replace' \
--header 'Content-Type: application/json' \
--header 'Authorization: <yourAuthToken>' \
--form 'csv_file=@"/<filepath>/replacement_segment.csv"' |
Response
Status code 201
Code Block |
---|
{"created": True} |
Get Device IDs or Cookies in a Segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve In [2]: segm_list = springserve.segment_lists.get(9) In [3]: my_list = segm_list.raw Out[3]: {'id': 10064, 'account_id': 1, 'name': 'test segment', 'description': None, 'active': True, 'segment_type': 'pixel', 'segment_pixel_type': 'cookie', 'user_expiration_value': None, 'created_at': '2021-02-11T22:05:47.412Z'}get_list() In [4]: my_list.raw Out[4]: [{'item': 'd207654f-6bdd-474e-9734-67b7c3d02d96'}, {'item': '123456789909nfejwnfkjewrjkweh8368721y3'}, {'item': 'd207654f-6bdd-474e-9734-67b7c3d02d97'}] |
REST API
GET /api/v0/segments/<id>/items
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Response
Status code 200
Code Block |
---|
{ "id": 10044, "account_id": 1, "name": "My DID Segment", "description": "My description", application/json Authorization "yourAuthToken" |
Response (note you need to paginate)
Status code 200
Code Block |
---|
[ { "activeitem": true,"d207654f-6bdd-474e-9734-67b7c3d02d96" "segment_type": "list"}, "segment_list_type": "cookie",{ "created_atitem": "2020-03-18T19:17:01.383Z" } |
...
d20gt57i-6bdd-474e-9734-67b7c3d02d96"
}
] |
Remove specific Device Ids or Cookies
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve In [2]: segm_list = springserve.segment_lists.get(9) In [3]: adddel = segm_list.bulk_create(['123456789909nfejwnfkjewrjkweh8368721y6','123456789909nfejwnfkjewrjkweh8768765r7delete(['d207654f-6bdd-474e-9734-67b7c3d02d96', '123456789909nfejwnfkjewrjkweh8368721y3']) In [4]: adddel.ok Out[4]: True |
REST API
POST DELETE /api/v0/segments/<id>/items/bulk_createdelete
Headers
Code Block |
---|
Content-Type application/json Authorization "yourAuthToken" |
Body (example) where "1" and "2" are the numeric
Code Block |
---|
{
"items": ["d207654f-6bdd-474e-9734-67b7c3d02d96"]
}
|
Response (note you need to pagenate)
Status code 200
Code Block |
---|
{" |
...
deleted": True} |
...
Remove specific items using a File
Removes items in the csv file from the segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: |
...
del = segm_list.bulk_ |
...
delete(file_path='/<filepath>/ |
...
ips_ |
...
to_ |
...
delete.csv') In [4]: |
...
del.ok Out[4]: True |
REST API
...
DELETE /api/v0/segments/<id>/items/file_bulk_
...
delete
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/segments/<id>/items/file_bulk_ |
...
delete' \ --header 'Content-Type: application/json' \ --header 'Authorization: <yourAuthToken>' \ --form 'csv_file=@"/<filepath>/ |
...
delete_these_items |
...
.csv"' |
Response
Status code
...
200
Code Block |
---|
{" |
...
deleted": True} |
...
Remove all items in a segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3 |
...
REST API
POST /api/v0/app_name_lists/<id>/app_names/bulk_replace
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken"
|
Body (example)
Code Block |
---|
{
"items": ["item1", "item2"]
} |
Response
Status code 201
Code Block |
---|
{"created": True} |
Replace Entire Segment with a File
Replaces segment with the items in the csv file
SDK
...
language | py |
---|
...
]: repl = segm_list.bulk_replace([''])
In [4]: repl.ok
Out[4]: True |
Edit Segments
SDK
Code Block | ||||
---|---|---|---|---|
| ||||
segment = springserve.segment_lists.get(914367) In [3]: repl segment.active = "false" changed = segmsegment.bulk_replace(file_path='/<filepath>/repl_segm_list.csv') In [4]: repl.ok Out[4]: True |
REST API
...
save()
changed.ok
print(changed.active)
True
False |
REST API
Method: PATCH
Endpoint URL: /api/v0/segments/<id>/items/file_bulk_replace
...
id - (required, type: integer) ID of the segment.
Request:
Code Block | ||||
---|---|---|---|---|
| ||||
PATCH /api/v0/segments/<id>/items/file_bulk_replace' \ --header '14366 Host: console.springserve.com Content-Type: application/json' \ --header 'Authorization: <yourAuthToken>' \ --form 'csv_file=@"/<filepath>/replacement_segment.csv"' |
Response
Status code 201
Code Block |
---|
{"created": True} |
Get Device IDs or Cookies in a Segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: my_list = segm_list.get_list()
In [4]: my_list.raw
Out[4]:
[{'item': 'd207654f-6bdd-474e-9734-67b7c3d02d96'},
{'item': '123456789909nfejwnfkjewrjkweh8368721y3'},
{'item': 'd207654f-6bdd-474e-9734-67b7c3d02d97'}]
|
REST API
GET /api/v0/segments/<id>/items
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Response (note you need to paginate)
Status code 200
Code Block |
---|
[
{
"item": "d207654f-6bdd-474e-9734-67b7c3d02d96"
},
{
"item": "d20gt57i-6bdd-474e-9734-67b7c3d02d96"
}
] |
Remove specific Device Ids or Cookies
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: del = segm_list.bulk_delete(['d207654f-6bdd-474e-9734-67b7c3d02d96', '123456789909nfejwnfkjewrjkweh8368721y3'])
In [4]: del.ok
Out[4]: True
|
REST API
DELETE /api/v0/segments/<id>/items/bulk_delete
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example) where "1" and "2" are the numeric
Code Block |
---|
{
"items": ["d207654f-6bdd-474e-9734-67b7c3d02d96"]
}
|
Response (note you need to pagenate)
Status code 200
Code Block |
---|
{"deleted": True} |
Remove specific items using a File
Removes items in the csv file from the segment
SDK
Code Block | ||
---|---|---|
| ||
In [1]: import springserve
In [2]: segm_list = springserve.segment_lists.get(9)
In [3]: del = segm_list.bulk_delete(file_path='/<filepath>/ips_to_delete.csv')
In [4]: del.ok
Out[4]: True |
REST API
DELETE /api/v0/segments/<id>/items/file_bulk_delete
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/segments/<id>/items/file_bulk_delete' \
--header 'Content-Type: application/json' \
--header 'Authorization: <yourAuthToken>' \
--form 'csv_file=@"/<filepath>/delete_these_items.csv"' |
Response
Status code 200
Code Block |
---|
{"deleted": True} |
Remove all items in a segment
SDK
...
language | py |
---|
...
"yourAuthToken"
{
"active": false
} |
Response:
Code Block | ||||
---|---|---|---|---|
| ||||
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 14366,
"account_id": 391,
"name": "API Example Segment",
"description": null,
"active": false,
"segment_count": 3,
"upload_status": "complete",
"segment_type": "pixel",
"segment_pixel_type": "cookie",
"user_expiration_value": 14,
"created_at": "2019-05-29T19:12:38.248Z",
"updated_at": "2023-12-01T10:24:01.506Z"
} |
Examples
Python Example
Code Block | ||||
---|---|---|---|---|
| ||||
import requests
import json
url = "https://console.springserve.com/api/v0/segemtens/25528"
payload = json.dumps({
"active": False
})
headers = {
'Authorization': 'yourAuthToken',
'Content-Type': 'application/json'
}
response = requests.request("PATCH", url, headers=headers, data=payload)
print(response.text) |
NodeJS Example
Code Block | ||||
---|---|---|---|---|
| ||||
var request = require('request');
var options = {
'method': 'PATCH',
'url': 'https://admin-console.springserve.com/api/v0/segments/14366',
'headers': {
'Authorization': 'yourAuthToken',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"active": false
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
}); |
Delete Segments
SDK
n/a
REST API
Method: DELETE
Endpoint URL: /api/v0/segments/<id>
id - (required, type: integer) ID of the segment.
Request:
Code Block | ||||
---|---|---|---|---|
| ||||
DELETE /api/v0/segments/14366
Host: console.springserve.com
Content-Type: application/json
Authorization: "yourAuthToken" |
Response:
Code Block | ||||
---|---|---|---|---|
| ||||
HTTP/1.1 204 No Content
Content-Type: application/json |
Attach to a Demand or Supply Tag
See documentation on the Supply and Demand Tag APIs