IP Address lists can be created, edited and viewed using the api. When you have created an IP Address list, you can attach that list to a demand or supply tag for targeting.
Use tab completion with SDK to auto-complete function names or show field options!
In [1]: import springserve In [2]: ip_list = springserve.ip_lists.new({"name":"My Test IP List"}) In [3]: print ip_list.ok, ip_list.id True 9 |
POST /api/v0/ip_lists
Headers
Content-Type application/json Authorization "yourAuthToken" |
Body (example)
{ "name" : "My IP List" , "description": "My description" } |
Required parameters: name
Response
Status code 200
{ "id": 6, "account_id": 1, "name": "My IP List", "description": "My description", "active": true, "created_at": "2018-08-08T21:06:09.923Z" } |
In [1]: ip_list = springserve.ip_lists.get(9) In [2]: print ip_list.name "My Test IP List" |
GET /api/v0/ip_lists/<id>
Headers
Content-Type application/json Authorization "yourAuthToken" |
Response
Status code 200
{ "id": 6, "account_id": 1, "name": "My IP List", "description": "My description", "active": true, "created_at": "2018-08-08T17:19:44.516Z" } |
In [1]: ip_list = springserve.ip_lists.get(9) In [2]: add = ip_list.add_ips(['158.106.194.74', '158.106.194.75']) In [3]: print add.ok True |
POST /api/v0/ip_lists/<id>/ips/bulk_create
Headers
Content-Type application/json Authorization "yourAuthToken" |
Body (example)
{ "ips": ["158.106.194.74", "158.106.194.75"] } |
Response
Status code 200
{"created": True} |
In [15]: resp = ip_list.get_ips() In [16]: for ip in resp: ....: print ip.ip ....: 158.106.194.74 158.106.194.75 |
GET /api/v0/ip_lists/<id>/ips
Headers
Content-Type application/json Authorization "yourAuthToken" |
Response (note you need to pagenate)
Status code 200
{ "ip": "158.106.194.74" "ip": "158.106.194.75" } |
In [13]: ip_list = springserve.ip_lists.get(9) In [14]: resp = ip_list.remove_ips(['158.106.194.75']) In [15]: resp.ok Out [15]: True In [16]: print resp.deleted True |
DELETE /api/v0/ip_lists/<id>/ips/bulk_delete
Headers
Content-Type application/json Authorization "yourAuthToken" |
Body (example) where "1" and "2" are the numeric
{ "ip": "158.106.194.74" "ip": "158.106.194.75" } |
Response (note you need to pagenate)
Status code 200
{"deleted": True} |
To attach an ip list to a supply or demand tag you must set the following fields on a supply or demand tag
In [18]: tag = springserve.demand_tags.get(2) In [19]: tag.ip_list_ids.append(9) In [20]: tag.ip_targeting = "Allowlist" In [21]: print tag.save().ok True |
See documentation on the Supply and Demand Tag APIs