> ## Documentation Index
> Fetch the complete documentation index at: https://developers.redo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# segmentExportStart

> Write a segment's contacts to a CSV in the background, as the app's segment export does, and return the export at once; poll `segmentExport` for the file. A dynamic segment's members are those it has when the export runs. An empty segment gives a file with only the header row. No email is sent, and a store may run several exports at once; each start also counts against a per-store export quota shared with tracker exports, and over it returns THROTTLED. A retry that returns the export an earlier attempt with its idempotencyKey started doesn't use up the quota, but is still refused with THROTTLED while the quota is empty. Returns null when the store has no segment with this id. Throws IDEMPOTENCY_KEY_REUSED and TRY_AGAIN as idempotencyKey describes.

**Required scopes:** [`segments_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-segments_read)

**Store must have one of:** `EMAIL_SMS`

## Arguments

**idempotencyKey** `String`

A key you choose, 1 to 400 characters, that makes a retry safe. It never expires: repeating the start with the same key returns the export it started instead of starting another, even once that export has FAILED; start again with a new key. When an export with a key couldn't start, the start throws TRY\_AGAIN (503) and keeps the export; repeat it with the same key to start that export. The same key with another request, such as another segment or a tracker export, throws IDEMPOTENCY\_KEY\_REUSED (422).

**segmentId** `ID!` *required*

The segment's `id`, or its `legacyId` from an earlier version of the Redo API.

## Returns

**segmentExportStart** `[SegmentExport](/docs/api-reference/v3/reference/marketing/segment-export)`

A CSV of a segment's contacts, one row per contact, written in the background with the columns the app's segment export writes. The file is available for 7 days after the export starts; after that the export reads FAILED with RESULT\_EXPIRED.

**fields**

**createdAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the job was started.

**error** `[JobError](/docs/api-reference/v3/reference/common/job-error)`

Why the job failed. Null unless `status` is FAILED.

**fields**

**code** `String!` *required*

A stable code in SCREAMING\_SNAKE\_CASE. Branch on it, not on `message`.

**message** `String!` *required*

What went wrong, in words.

**file** `[File](/docs/api-reference/v3/reference/common/file)`

The CSV, once SUCCEEDED. Its link works for up to an hour; read the export again for a fresh one. Null otherwise.

**fields**

**contentType** `String!` *required*

The file's media type, such as text/csv.

**fileName** `String`

The name the file downloads as. Null when the file has none.

**height** `Int`

An image's height in pixels. Null for other files.

**sizeBytes** `Int`

The file's size in bytes. Null when it wasn't recorded.

**url** `String!` *required*

Where to download the file. Signed and short-lived for a private file (see `urlExpiresAt`); stable for a public one.

**urlExpiresAt** `[DateTime](/docs/api-reference/v3/reference/common/date-time)`

When `url` stops working. Null for a public file, whose `url` doesn't expire.

**width** `Int`

An image's width in pixels. Null for other files.

**finishedAt** `[DateTime](/docs/api-reference/v3/reference/common/date-time)`

When the job finished. Null while it is going.

**id** `ID!` *required*

Poll the job again with this id.

**rowCount** `Int`

How many contacts the file has. Null until SUCCEEDED.

**status** `[JobStatus!](/docs/api-reference/v3/reference/common/job-status)` *required*

Where the job stands.

## Errors

Besides the [errors any request can return](https://developers.redo.com/docs/api-reference/v3/errors.md), this operation fails with these codes in `extensions.code`.

| Code | HTTP status | Meaning | Retry |
| - | - | - | - |
| `BAD_USER_INPUT` | `400` | An argument is invalid, or names something the store doesn't have. The message says which. Nothing was written. | Fix the input the message names, then send it again. |
| `IDEMPOTENCY_KEY_REUSED` | `422` | The idempotencyKey was already used for a different request. Nothing was written. | Send the new request with a new idempotencyKey, or resend the first request unchanged to get its result. |
| `TRY_AGAIN` | `503` | The change couldn't start for a passing reason, and nothing was written or sent. | Send the same request again after a short wait, with the same idempotencyKey if it has one. |

## Example

```graphql theme={null}
mutation {
  segmentExportStart(idempotencyKey: "...", segmentId: "...") {
    createdAt
    finishedAt
    id
    rowCount
    status
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.