Skip to content

Export Segment

GET /cdp/segments/{id}/export — export a segment’s full membership as NDJSON (newline-delimited JSON: one profile per line). The brand must own the segment (a segment you don’t own is indistinguishable from a missing one — both 404); only in-scope profiles are ever exported.

Each response is capped at 10,000 lines. When more members remain, the response carries an opaque resumption cursor in the X-Next-Cursor header — pass it back as ?cursor= to continue. The cursor walk is correct past the 10,000-row result window, so segments of any size can be exported end to end without hand-rolling pagination.

GET /cdp/segments/{id}/export
Authorization: Bearer vyg_…
ParamTypeDescription
idstringThe segment id.
ParamTypeDefaultDescription
limitinteger10000Maximum NDJSON lines in this response, clamped to [1, 10000].
cursorstringOpaque resumption token from a previous response’s X-Next-Cursor header. Continues a partial export.

Content-Type: application/x-ndjson — the body is newline-delimited JSON, one profile per line (no JSON envelope). A segment with no members returns an empty body.

{"id":"shopify_your-shop_1234","provenance":"server","email":"jane@example.com","firstName":"Jane","lastName":"Doe","shopDomain":"your-shop.myshopify.com","shopifyCustomerId":"1234","properties":{"firstVisit":"2026-01-01T00:00:00Z","lastVisit":"2026-06-01T00:00:00Z"}}
{"id":"shopify_your-shop_5678","provenance":"merged","email":"sam@example.com","shopDomain":"your-shop.myshopify.com","properties":{"lastVisit":"2026-05-20T12:34:56Z"}}
FieldTypeDescription
idstringThe profile’s itemId.
provenancestringserver | pixel | merged — how the identity was resolved (see Tenant Isolation).
identityFlattened identity fields when present: email, phoneNumber, firstName, lastName, city, countryName, zipCode, shopDomain, shopifyCustomerId, mergeIdentifier.
propertiesobjectKey activity properties when present: firstVisit, lastVisit.
HeaderWhenDescription
X-Next-CursorMore members remainOpaque, single-brand, single-segment resumption token. Pass back as ?cursor= to continue.

When X-Next-Cursor is absent, the export is complete.

The cursor is bound to the brand it was minted for and to the segment it was exporting: presenting another brand’s cursor is 403, and presenting a cursor minted for a different segment is 400. Keep requesting with the returned cursor until the header disappears:

Terminal window
CURSOR=""
while :; do
RESPONSE=$(curl -s -D headers.txt \
"https://cdp.vyg.app/cdp/segments/segment-scoped-id/export${CURSOR:+?cursor=$CURSOR}" \
-H "Authorization: Bearer vyg_your_key_here")
printf '%s' "$RESPONSE" >> members.ndjson
CURSOR=$(grep -i '^x-next-cursor:' headers.txt | tr -d '\r' | cut -d' ' -f2)
[ -z "$CURSOR" ] && break
done
Terminal window
curl -s "https://cdp.vyg.app/cdp/segments/segment-scoped-id/export?limit=1000" \
-H "Authorization: Bearer vyg_your_key_here"

Errors are returned as application/json with the standard envelope.

StatusWhen
400Missing segment id, malformed cursor, or a cursor minted for a different segment.
401Missing or invalid credential.
403No connected shop resolves a scope, or the cursor was minted for a different brand.
404The segment does not exist for this brand (missing and out-of-scope are identical).
405Unsupported method (use GET).
502The CDP returned an error while reading membership — retry or resume from the last cursor.
503The CDP is temporarily unavailable — retry.

See Errors for the full envelope.