{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/segments","auth":"required","settings":"","examples":{"codes":[{"language":"curl","code":"curl -H \"Authorization: key=<insert api token here>\" --data \"name=adwords\" https://pushcrew.com/api/v1/segments","name":""},{"language":"php","code":"<?php\n\n$segmentName = 'homepage';\n$apiToken = '<insert your api token here>';\n\n//set POST variables\n$curlUrl = 'https://pushcrew.com/api/v1/segments';\n$fields = array(\n  'name' => $segmentName\n);\n\n$httpHeadersArray = Array();\n$httpHeadersArray[] = 'Authorization: key='.$apiToken;\n\n//open connection\n$ch = curl_init();\n\n//set the url, number of POST vars, POST data\ncurl_setopt($ch, CURLOPT_URL, $curlUrl);\ncurl_setopt($ch, CURLOPT_POST, true);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeadersArray);\n\n//execute post\n$result = curl_exec($ch);\n\n$resultArray = json_decode($result, true);\n\nif($resultArray['status'] == 'success') {\n    //echo $resultArray['segment_id']; //ID of the newly created segment. The same is used in the API calls for adding/removing subscribers to/from segments\n}\nelse if($resultArray['status'] == 'failure') {\n    //echo $resultArray['message']; //Denotes reason of failure\n}\nelse {\n    //failure\n}\n\n//close connection\ncurl_close($ch);\n\n?>"}]},"method":"post","params":[{"name":"name","type":"string","default":"","desc":"To be sent as a POST Parameter. Name of the Segment.","required":false,"in":"body","ref":"","_id":"55e7325f2d0d3021000db051"}],"results":{"codes":[{"name":"","code":"{\n    \"status\": \"success\",\n    \"segment_id\": \"123\" \n}","language":"json","status":200},{"status":400,"name":"","code":"{\n    \"status\": \"failure\",\n    \"message\": \"Segment name can have a maximum length of 30 chars and can only contain alpha numeric characters, hyphens and underscores\"\n}","language":"json"},{"language":"json","code":"{\n    \"status\": \"failure\",\n    \"message\": \"A segment with this name already exists.\" \n}","status":200},{"code":"{\n    \"status\": \"failure\",\n    \"message\": \"Variable named 'name' was not found in POST data\"\n}","language":"json","status":400},{"code":"{\n    \"message\": \"You are not authorized\"\n}","status":401,"language":"json"},{"status":500,"language":"json","code":"{\n    \"status\": \"failure\",\n    \"message\": \"Oops. Something snapped. Please try again after some time\"\n}"}]}},"next":{"description":"","pages":[]},"title":"Add A Segment","type":"endpoint","slug":"add-segment","excerpt":"This endpoint is used to add a segment. The request method of this call needs to be \"POST\".\n\nThe segment name has to be sent as a POST parameter to the API endpoint.\n\nThe segment name can be a maximum of 30 chars. It may only contain alphanumeric characters, underscore or a dash.","body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Response Description\"\n}\n[/block]\nStatus: To denote whether the request succeeded or not. Values can be 'success' or 'failure'.\n\nSegment ID: To identify the segment newly created. The same ID is used to add/remove subscribers to/from the segment through the API.\n\nMessage: Present in case of failure. Used to denote reason of failure.","updates":[],"order":10,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"55e7325f2d0d3021000db050","project":"55e58b63d101191900f30b13","githubsync":"","parentDoc":null,"user":"5554788cb450630d00041dbc","category":{"sync":{"isSync":false,"url":""},"pages":["55e58d27191aa90d0052b52f","55e58d56191aa90d0052b531","55e58d6ff493c11700584315","55e58d81f493c11700584318","55e59b9bd101191900f30b75","55e59c1ff11ba80d003238f1","55e7325f2d0d3021000db050","55e732ca58e25f35001437a6","55e7339e2d0d3021000db052","55e734aa7991b92100b209ed","55f7028ba7ceef0d00251c19","56669144ce8caf0d006018b6","56d04587376b040b005b2f7d"],"title":"REST API","slug":"rest-api","order":2,"from_sync":false,"reference":false,"_id":"55e58d1bd101191900f30b1d","version":"55e58b63d101191900f30b16","__v":13,"project":"55e58b63d101191900f30b13","createdAt":"2015-09-01T11:33:47.501Z"},"version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["55e58b65d101191900f30b17","55e58d16f493c11700584314","55e58d1bd101191900f30b1d"],"_id":"55e58b63d101191900f30b16","__v":3,"createdAt":"2015-09-01T11:26:27.668Z","releaseDate":"2015-09-01T11:26:27.668Z","project":"55e58b63d101191900f30b13"},"__v":0,"createdAt":"2015-09-02T17:31:11.492Z","editedParams2":true,"editedParams":true}

postAdd A Segment

This endpoint is used to add a segment. The request method of this call needs to be "POST". The segment name has to be sent as a POST parameter to the API endpoint. The segment name can be a maximum of 30 chars. It may only contain alphanumeric characters, underscore or a dash.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

name:
string
To be sent as a POST Parameter. Name of the Segment.

Examples


Result Format


Documentation

[block:api-header] { "type": "basic", "title": "Response Description" } [/block] Status: To denote whether the request succeeded or not. Values can be 'success' or 'failure'. Segment ID: To identify the segment newly created. The same ID is used to add/remove subscribers to/from the segment through the API. Message: Present in case of failure. Used to denote reason of failure.