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.
Request
Section titled “Request”GET /cdp/segments/{id}/exportAuthorization: Bearer vyg_…Path parameters
Section titled “Path parameters”| Param | Type | Description |
|---|---|---|
id | string | The segment id. |
Query parameters
Section titled “Query parameters”| Param | Type | Default | Description |
|---|---|---|---|
limit | integer | 10000 | Maximum NDJSON lines in this response, clamped to [1, 10000]. |
cursor | string | — | Opaque resumption token from a previous response’s X-Next-Cursor header. Continues a partial export. |
Response 200
Section titled “Response 200”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"}}Line fields
Section titled “Line fields”| Field | Type | Description |
|---|---|---|
id | string | The profile’s itemId. |
provenance | string | server | pixel | merged — how the identity was resolved (see Tenant Isolation). |
| identity | — | Flattened identity fields when present: email, phoneNumber, firstName, lastName, city, countryName, zipCode, shopDomain, shopifyCustomerId, mergeIdentifier. |
properties | object | Key activity properties when present: firstVisit, lastVisit. |
Response headers
Section titled “Response headers”| Header | When | Description |
|---|---|---|
X-Next-Cursor | More members remain | Opaque, single-brand, single-segment resumption token. Pass back as ?cursor= to continue. |
When X-Next-Cursor is absent, the export is complete.
Resuming an export
Section titled “Resuming an export”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:
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" ] && breakdoneExample
Section titled “Example”curl -s "https://cdp.vyg.app/cdp/segments/segment-scoped-id/export?limit=1000" \ -H "Authorization: Bearer vyg_your_key_here"Errors
Section titled “Errors”Errors are returned as application/json with the standard envelope.
| Status | When |
|---|---|
400 | Missing segment id, malformed cursor, or a cursor minted for a different segment. |
401 | Missing or invalid credential. |
403 | No connected shop resolves a scope, or the cursor was minted for a different brand. |
404 | The segment does not exist for this brand (missing and out-of-scope are identical). |
405 | Unsupported method (use GET). |
502 | The CDP returned an error while reading membership — retry or resume from the last cursor. |
503 | The CDP is temporarily unavailable — retry. |
See Errors for the full envelope.