Create a membership segment
POST /v2/marketing/segments/create_membership_segment
Creates a new membership segment.
Your request must include the segment's name and can optionally include a description to help identify the segment later. The response contains name, description, and the Instacart-generated segment_id.
Security
| Name | In | Description |
|---|---|---|
Authorization | header | The Authorization header with the client bearer token acquired during authentication. |
For more information, see Get a client access token.
Parameters
None.Request
| Field | Type | Required | Description |
|---|---|---|---|
name | string | The display name for the new segment. Required. | |
description | string | An optional human-readable description of the segment. |
Request examples
- cURL
- Java
- Python
- Go
curl --request POST \
--url https://connect.instacart.com/v2/marketing/segments/create_membership_segment \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"name": "string",
"description": "string"
}'
HttpResponse<String> response = Unirest.post("https://connect.instacart.com/v2/marketing/segments/create_membership_segment")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer <token>")
.body("{\n \"name\": \"string\",\n \"description\": \"string\"\n}")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
payload = "{\n \"name\": \"string\",\n \"description\": \"string\"\n}"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer <token>"
}
conn.request("POST", "/v2/marketing/segments/create_membership_segment", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://connect.instacart.com/v2/marketing/segments/create_membership_segment"
payload := strings.NewReader("{\n \"name\": \"string\",\n \"description\": \"string\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response
| Field | Type | Required | Description |
|---|---|---|---|
segment_id | string | The unique ID of the segment. | |
name | string | The display name of the segment. | |
description | string | A human-readable description of the segment. |
Response examples
200 Success
200Success
{
"segment_id": "f87414d7-1836-4b5c-84b5-6efeb2406a18",
"name": "My Segment",
"description": "desc"
}
4XX Errors
Error responses return either a single error or multiple errors.
| HTTP Code | Cause | Error Message | Error Code | Error Meta |
|---|---|---|---|---|
400 | Invalid body | "Invalid request body" | 1001 | Not applicable |
400 | Missing name | "can't be blank" | 1001 | {"key":"name"} |
400 | Segment already exists | "segment with name "My Segment" already exists: f87414d7-1836-4b5c-84b5-6efeb2406a18" | 1001 | {"key":"name"} |
401 | Unauthorized | "Unauthorized" | null | Not applicable |
403 | Forbidden | "Forbidden" | null | Not applicable |