How can I update an existing Location Segment through the API?

This article will walk you through updating existing Location Segments through the API.
For all of the examples below, please use your app key and master secret for your application.
Please also fill in the segment ID when needed.


Step 1: Get list of Segments

This will provide a list of all segments made on your application.

Request:

curl -X GET -u "<appkey>:<Secret>" -H "Content-Type: application/json" https://go.urbanairship.com/api/segments

Response:

{"segments":[{"id":"2005f63c-541a-4141-b598-35b826800aaa","display_name":"Test","creation_date":1387559344243,"modification_date":1387560894985},{"id":"8e1a0668-0e09-4f7d-b22e-4516f954be4e","display_name":"Austin TX 78750","creation_date":1387554776052,"modification_date":1387554776052},{"id":"c4774338-89d8-49f1-8124-79c9c9022656","display_name":"Test","creation_date":1387467286345,"modification_date":1387467286345}]}

 

Step 2: Get specific details about Segment

This request will allow you to see details about a specific segment. Just add in the Segment ID from the Step 1 response.

Request:

curl -X GET -u "<appkey>:<Secret>" -H "Content-Type: application/json" https://go.urbanairship.com/api/segments/<segment ID>

Response:

{"display_name":"Test","criteria":{"and":[{"location":{"id":"5Wwxd2b4EAexYxsJbTQGUr","date":{"recent":{"minutes":1}}}}]}}



Step 3: Update Segment

This request will update the segment. Make sure you copy the response from Step 2  to add in the data parameter, then change the needed information from here.

Request:

curl -X PUT -u "<appkey>:<Secret>" -H "Content-Type: application/json" --data '{"display_name":"Test","criteria":{"and":[{"location":{"id":"5Wwxd2b4EAexYxsJbTQGUr","date":{"recent":{"hours":1}}}}]}}' https://go.urbanairship.com/api/segments/<segment>

 

Response:

{"ok":true}