Get a segment
GET /v2/marketing/segments/{segment_id}
Returns a single segment by its ID. The response includes the segment's segment_id, name, and description.
Supply the segment_id of the membership segment you want to retrieve as a path parameter. To find the available segment IDs, use List segments.
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
| Name | In | Type | Required | Description |
|---|---|---|---|---|
segment_id | path | string | The ID of the segment. |
Request
None.Request examples
- cURL
- Java
- Python
- Go
curl --request GET \
--url 'https://connect.instacart.com/v2/marketing/segments/{segment_id}' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
HttpResponse<String> response = Unirest.get("https://connect.instacart.com/v2/marketing/segments/{segment_id}")
.header("Accept", "application/json")
.header("Authorization", "Bearer <token>")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
headers = {
'Accept': "application/json",
'Authorization': "Bearer <token>"
}
conn.request("GET", "/v2/marketing/segments/{segment_id}", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://connect.instacart.com/v2/marketing/segments/{segment_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "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": "Loyalists",
"description": "Top spenders"
}
4XX Errors
Error responses return either a single error or multiple errors.
| HTTP Code | Cause | Error Message | Error Code | Error Meta |
|---|---|---|---|---|
400 | Missing segment_id | "segment_id is required" | 1001 | {"key":"segment_id"} |
401 | Unauthorized | "Unauthorized" | null | Not applicable |
403 | Forbidden | "Forbidden" | null | Not applicable |
404 | Not found | "segment not found" | 4000 | Not applicable |