> ## 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.

# generatedDiscountCodes

> List the unique codes generated from one discount configuration, newest first, as the discount page shows them. The list is search-indexed and can trail a new code by a few seconds. An unknown discount returns no codes.

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

## Arguments

**after** `String`

Forward pagination cursor — returns items after it. Pass an `edges[].cursor` or `pageInfo.endCursor` from a previous page.

**before** `String`

Backward pagination cursor — returns items before it. Pass an `edges[].cursor` or `pageInfo.startCursor` from a previous page.

**discountId** `ID!` *required*

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

**first** `Int`

Forward pagination: returns the first N items (max 100, default 25). Use with `after`; mutually exclusive with `last`/`before`.

**last** `Int`

Backward pagination: returns the last N items (max 100, default 25). Use with `before`; mutually exclusive with `first`/`after`.

**query** `String`

Only include codes that start with or contain this text, ignoring case. At most 200 characters.

**reverse** `Boolean`

Lists the oldest codes first instead of the newest.

**status** `[GeneratedDiscountCodeStatus](/docs/api-reference/v3/reference/marketing/generated-discount-code-status)`

Only include codes with this status. Without it, previews are included.

## Returns

**generatedDiscountCodes** `[GeneratedDiscountCodeConnection!](/docs/api-reference/v3/pagination)` *required*

A paginated list of GeneratedDiscountCode items.

**fields**

**edges** `[\[GeneratedDiscountCodeEdge!\]!](/docs/api-reference/v3/pagination)` *required*

The list of edges (each a node plus its pagination `cursor`).

**fields**

**cursor** `String!` *required*

Opaque cursor for this item; pass to `after`/`before` to page from here.

**node** `[GeneratedDiscountCode!](/docs/api-reference/v3/reference/marketing/generated-discount-code)` *required*

The item at this edge.

**fields**

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

The code a customer enters at checkout.

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

When the code was generated.

**customer** `[Customer](/docs/api-reference/v3/reference/customers/customer)`

The customer the code was generated for. Null when it was not generated for a customer, or the customer has since been deleted.

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

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

When the code stops working. Null if it never expires.

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

The id of this generated discount code.

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

When the code was last used. Null if it never was.

**legacyId** `String!` *required*

The generated code's legacy Mongo ObjectId (24-char hex) from before the CockroachDB migration.

**source** `[GeneratedDiscountCodeSource!](/docs/api-reference/v3/reference/marketing/generated-discount-code-source)` *required*

Which Redo feature generated the code.

**status** `[GeneratedDiscountCodeStatus!](/docs/api-reference/v3/reference/marketing/generated-discount-code-status)` *required*

Whether the code is active, expired, or a preview. Usage does not change it: see `usageCount`.

**usageCount** `Int!` *required*

How many times the code was used on an order. A code used before usage records were kept counts as 1.

**nodes** `[\[GeneratedDiscountCode!\]!](/docs/api-reference/v3/reference/marketing/generated-discount-code)` *required*

The nodes in this page, without the edge/cursor wrapper — a convenience over `edges`.

**fields**

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

The code a customer enters at checkout.

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

When the code was generated.

**customer** `[Customer](/docs/api-reference/v3/reference/customers/customer)`

The customer the code was generated for. Null when it was not generated for a customer, or the customer has since been deleted.

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

**fields**

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

When the customer record was created.

**customFields** `[JSON](/docs/api-reference/v3/reference/common/json)`

Merchant-defined custom field values, keyed by each field's name. Null when the customer has no custom fields set.

**email** `String`

The customer's primary email address.

**firstName** `String`

The customer's first name.

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

The id of this customer.

**lastName** `String`

The customer's last name.

**legacyId** `String!` *required*

The customer's legacy identifier (the source Mongo ObjectId), accepted anywhere an `id` is.

**location** `[CustomerLocation](/docs/api-reference/v3/reference/customers/customer-location)`

The customer's current location, if known.

**phoneNumber** `String`

The customer's primary phone number.

**supportTickets** `[SupportTicketConnection!](/docs/api-reference/v3/pagination)` *required*

The help desk tickets this customer is the primary contact on any thread of, newest first. Every ticket whose `customer` is this customer is here.

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

**fields**

**Arguments**

**after** `String`

Forward pagination cursor — returns tickets after it.

**before** `String`

Backward pagination cursor — returns tickets before it.

**first** `Int`

Forward pagination: returns the first N tickets (max 100, default 25). Use with `after`; mutually exclusive with `last`/`before`.

**last** `Int`

Backward pagination: returns the last N tickets (max 100, default 25). Use with `before`; mutually exclusive with `first`/`after`.

**tags** `[CustomerTagConnection!](/docs/api-reference/v3/pagination)` *required*

The tags on this customer, from the store's customer tag catalog, A–Z by name.

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

**fields**

**Arguments**

**after** `String`

Forward pagination cursor — returns tags after it.

**before** `String`

Backward pagination cursor — returns tags before it.

**first** `Int`

Forward pagination: returns the first N tags (max 100, default 25). Use with `after`; mutually exclusive with `last`/`before`.

**last** `Int`

Backward pagination: returns the last N tags (max 100, default 25). Use with `before`; mutually exclusive with `first`/`after`.

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

When the customer record was last updated.

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

When the code stops working. Null if it never expires.

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

The id of this generated discount code.

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

When the code was last used. Null if it never was.

**legacyId** `String!` *required*

The generated code's legacy Mongo ObjectId (24-char hex) from before the CockroachDB migration.

**source** `[GeneratedDiscountCodeSource!](/docs/api-reference/v3/reference/marketing/generated-discount-code-source)` *required*

Which Redo feature generated the code.

**status** `[GeneratedDiscountCodeStatus!](/docs/api-reference/v3/reference/marketing/generated-discount-code-status)` *required*

Whether the code is active, expired, or a preview. Usage does not change it: see `usageCount`.

**usageCount** `Int!` *required*

How many times the code was used on an order. A code used before usage records were kept counts as 1.

**pageInfo** `[PageInfo!](/docs/api-reference/v3/pagination)` *required*

Pagination metadata for the current page.

**fields**

**endCursor** `String`

Cursor of the last edge in this page; pass to `after` to page forward.

**hasNextPage** `Boolean!` *required*

Whether more items exist after this page (drives forward pagination with `first`/`after`).

**hasPreviousPage** `Boolean!` *required*

Whether more items exist before this page (drives backward pagination with `last`/`before`).

**startCursor** `String`

Cursor of the first edge in this page; pass to `before` to page backward.

## Example

```graphql theme={null}
query {
  generatedDiscountCodes(after: "...", before: "...", discountId: "...", first: 10, last: 10, query: "...", reverse: true, status: ACTIVE) {
    nodes {
      code
      createdAt
      expiresAt
      id
      lastUsedAt
      legacyId
      source
      status
      # ...
    }
    pageInfo { hasNextPage endCursor }
  }
}
```


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