Skip to main content

Add members to a segment

POST /v2/marketing/segments/add_to_membership_segment

Adds external IDs to a membership segment. You're limited to providing 50,000 or less external IDs per request. For larger sets, batch the IDs across multiple calls.

Security​

NameInDescription
AuthorizationheaderThe Authorization header with the client bearer token acquired during authentication.

For more information, see Get a client access token.

Parameters​

None.

Request​

FieldTypeRequiredDescription
segment_idstringRequired

The ID of the segment to update. Required.

external_idsArray(string)Required

The external IDs to add to or remove from the segment. Required; must contain at least 1 and at most 50000 entries.

Request examples​

curl --request POST \
--url https://connect.instacart.com/v2/marketing/segments/add_to_membership_segment \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"segment_id": "string",
"external_ids": [
"string"
]
}'

Response​

FieldTypeRequiredDescription
successbooleanOptional

Whether the add succeeded for all supplied external IDs.

processedintegerOptional

The number of external IDs added successfully.

failedintegerOptional

The number of external IDs that could not be added.

failed_external_idsArray(string)Optional

The external IDs that could not be added. Omitted when none failed.

error_messagestringOptional

A human-readable summary of the failure. Omitted on full success.

Response examples​

200 Success

{
"success": true,
"processed": 2,
"failed": 0
}

4XX Errors

Error responses return either a single error or multiple errors.

HTTP CodeCauseError MessageError CodeError Meta
400Invalid body"Invalid request body"1001Not applicable
400Missing field"can't be blank"1001{"key":"segment_id"}
400Too many external IDs"external_ids cannot exceed 50000 entries"1001{"key":"external_ids"}
401Unauthorized"Unauthorized"nullNot applicable
403Forbidden"Forbidden"nullNot applicable