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

# Search DiscountCodes

> Search and list DiscountCode records with filtering, sorting, and pagination.

A **DiscountCode** represents a discount registered in the system. Each discount code belongs to a `Business` (location) and defines a percentage or fixed-amount discount that can be applied to different item types: price plans (tariffs), bookings, products, and/or events.

Use the boolean flags (`DiscountPricePlans`, `DiscountBookings`, `DiscountProducts`, `DiscountEvents`) to control which item categories the discount applies to. For each enabled category, associate the specific eligible items via the corresponding ID list (e.g. `Tariffs`, `ResourceTypes`, `Products`, `EventCategories`). Use the `Added*` and `Removed*` list variants for incremental updates without replacing the full list.

A discount can specify either `DiscountPercentage` (e.g. 10 for 10% off) or `DiscountAmount` (a fixed monetary amount off), but not both.

Discount codes can be assigned to individual customers via `CoworkerDiscountCode`. Availability can be further restricted by validity dates (`ValidFrom`/`ValidTo`), publish window (`PublishFrom`/`PublishTo`), usage caps (`MaxUses`, `MaxUsesPerUser`), audience (`OnlyForContacts`, `OnlyForMembers`), and expiration rules (`ExpirationType`, `ExpiresIn`).

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`DiscountCode-List`** role.
</Note>

## Enums

<Accordion title="eDiscountExpirePeriod">
  | Value | Name  |
  | ----- | ----- |
  | 1     | Day   |
  | 2     | Week  |
  | 3     | Month |
  | 4     | Year  |
</Accordion>

## Query Parameters

### Pagination & Sorting

<ParamField query="page" type="integer" default="1">
  The page number to retrieve.
</ParamField>

<ParamField query="size" type="integer" default="25">
  The number of records per page.
</ParamField>

<ParamField query="orderBy" type="string">
  The property name to sort results by (e.g. `Name`, `CreatedOn`).
</ParamField>

<ParamField query="dir" type="integer">
  Sort direction. `0` for ascending, `1` for descending.
</ParamField>

### Filters

<ParamField query="DiscountCode_Business" type="integer">
  Filter by Business Id.
</ParamField>

<ParamField query="DiscountCode_Business_Name" type="string">
  Filter by name of the business (location) this discount code belongs to.
</ParamField>

<ParamField query="DiscountCode_Business_Currency_Code" type="string">
  Filter by currency code of the business (e.g. USD, EUR).
</ParamField>

<ParamField query="DiscountCode_Code" type="string">
  Filter by the unique alphanumeric code customers enter to apply the discount.
</ParamField>

<ParamField query="DiscountCode_Description" type="string">
  Filter by human-readable description of what this discount code is for.
</ParamField>

<ParamField query="DiscountCode_Active" type="boolean">
  Filter by whether this discount code is currently active and can be redeemed.
</ParamField>

<ParamField query="DiscountCode_PublishFrom" type="string">
  Filter by date from which this discount code is visible/published to customers.
</ParamField>

<ParamField query="DiscountCode_PublishTo" type="string">
  Filter by date until which this discount code is visible/published to customers.
</ParamField>

<ParamField query="DiscountCode_DiscountPercentage" type="number">
  Filter by percentage discount to apply (e.g. 10 for 10% off). Mutually exclusive with DiscountAmount.
</ParamField>

<ParamField query="DiscountCode_DiscountAmount" type="number">
  Filter by fixed monetary amount to discount. Mutually exclusive with DiscountPercentage.
</ParamField>

<ParamField query="DiscountCode_ReferralDiscount" type="boolean">
  Filter by whether this discount code is used as part of the referral program.
</ParamField>

<ParamField query="DiscountCode_DiscountPricePlans" type="boolean">
  Filter by whether this discount can be applied to price plans (tariffs). When true, use Tariffs to restrict to specific plans.
</ParamField>

<ParamField query="DiscountCode_DiscountBookings" type="boolean">
  Filter by whether this discount can be applied to resource bookings. When true, use ResourceTypes to restrict to specific resource types.
</ParamField>

<ParamField query="DiscountCode_DiscountProducts" type="boolean">
  Filter by whether this discount can be applied to products. When true, use Products to restrict to specific products.
</ParamField>

<ParamField query="DiscountCode_DiscountEvents" type="boolean">
  Filter by whether this discount can be applied to events. When true, use EventCategories to restrict to specific event categories.
</ParamField>

<ParamField query="DiscountCode_MaxUsesPerUser" type="integer">
  Filter by maximum number of times a single customer can redeem this discount code.
</ParamField>

<ParamField query="DiscountCode_MaxUses" type="integer">
  Filter by maximum total number of times this discount code can be redeemed across all customers.
</ParamField>

<ParamField query="DiscountCode_OnlyForContacts" type="boolean">
  Filter by when true, only contacts (non-member customers) can use this discount code.
</ParamField>

<ParamField query="DiscountCode_OnlyForMembers" type="boolean">
  Filter by when true, only members (customers with an active plan) can use this discount code.
</ParamField>

<ParamField query="DiscountCode_ValidFrom" type="string">
  Filter by start date from which this discount code can be redeemed.
</ParamField>

<ParamField query="DiscountCode_ValidTo" type="string">
  Filter by end date after which this discount code can no longer be redeemed.
</ParamField>

<ParamField query="DiscountCode_ExpirationType" type="integer">
  Filter by unit of the expiration period (Day, Week, Month, Year). Used with ExpiresIn to determine when the discount expires after being assigned to a customer.
</ParamField>

<ParamField query="DiscountCode_ExpiresIn" type="integer">
  Filter by number of ExpirationType periods after assignment until the discount expires for a customer.
</ParamField>

### Range Filters

<ParamField query="from_DiscountCode_PublishFrom" type="string">
  Filter by date from which this discount code is visible/published to customers greater than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="to_DiscountCode_PublishFrom" type="string">
  Filter by date from which this discount code is visible/published to customers less than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="from_DiscountCode_PublishTo" type="string">
  Filter by date until which this discount code is visible/published to customers greater than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="to_DiscountCode_PublishTo" type="string">
  Filter by date until which this discount code is visible/published to customers less than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="from_DiscountCode_DiscountPercentage" type="number">
  Filter by percentage discount to apply (e.g. 10 for 10% off). Mutually exclusive with DiscountAmount greater than or equal to this value.
</ParamField>

<ParamField query="to_DiscountCode_DiscountPercentage" type="number">
  Filter by percentage discount to apply (e.g. 10 for 10% off). Mutually exclusive with DiscountAmount less than or equal to this value.
</ParamField>

<ParamField query="from_DiscountCode_DiscountAmount" type="number">
  Filter by fixed monetary amount to discount. Mutually exclusive with DiscountPercentage greater than or equal to this value.
</ParamField>

<ParamField query="to_DiscountCode_DiscountAmount" type="number">
  Filter by fixed monetary amount to discount. Mutually exclusive with DiscountPercentage less than or equal to this value.
</ParamField>

<ParamField query="from_DiscountCode_MaxUsesPerUser" type="integer">
  Filter by maximum number of times a single customer can redeem this discount code greater than or equal to this value.
</ParamField>

<ParamField query="to_DiscountCode_MaxUsesPerUser" type="integer">
  Filter by maximum number of times a single customer can redeem this discount code less than or equal to this value.
</ParamField>

<ParamField query="from_DiscountCode_MaxUses" type="integer">
  Filter by maximum total number of times this discount code can be redeemed across all customers greater than or equal to this value.
</ParamField>

<ParamField query="to_DiscountCode_MaxUses" type="integer">
  Filter by maximum total number of times this discount code can be redeemed across all customers less than or equal to this value.
</ParamField>

<ParamField query="from_DiscountCode_ValidFrom" type="string">
  Filter by start date from which this discount code can be redeemed greater than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="to_DiscountCode_ValidFrom" type="string">
  Filter by start date from which this discount code can be redeemed less than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="from_DiscountCode_ValidTo" type="string">
  Filter by end date after which this discount code can no longer be redeemed greater than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="to_DiscountCode_ValidTo" type="string">
  Filter by end date after which this discount code can no longer be redeemed less than or equal to this value. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="from_DiscountCode_ExpiresIn" type="integer">
  Filter by number of ExpirationType periods after assignment until the discount expires for a customer greater than or equal to this value.
</ParamField>

<ParamField query="to_DiscountCode_ExpiresIn" type="integer">
  Filter by number of ExpirationType periods after assignment until the discount expires for a customer less than or equal to this value.
</ParamField>

<ParamField query="from_DiscountCode_CreatedOn" type="string">
  Filter records created on or after this date. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="to_DiscountCode_CreatedOn" type="string">
  Filter records created on or before this date. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="from_DiscountCode_UpdatedOn" type="string">
  Filter records updated on or after this date. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

<ParamField query="to_DiscountCode_UpdatedOn" type="string">
  Filter records updated on or before this date. Format: `YYYY-MM-DDTHH:mm`.
</ParamField>

## Code Examples

### Simple listing

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET \
    "https://spaces.nexudus.com/api/billing/discountcodes?page=1&size=15&orderBy=Code&dir=0" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/discountcodes?' + new URLSearchParams({
      page: 1,
      size: 15,
      orderBy: 'Code',
      dir: 1 // Ascending
    }),
    {
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN'
      }
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://spaces.nexudus.com/api/billing/discountcodes',
      params={
          'page': 1,
          'size': 15,
          'orderBy': 'Code',
          'dir': 0 // Ascending
      },
      headers={
          'Authorization': 'Bearer YOUR_TOKEN'
      }
  )

  data = response.json()
  ```
</CodeGroup>

### Filtering by Code

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET \
    "https://spaces.nexudus.com/api/billing/discountcodes?DiscountCode_Code=example-value&orderBy=Code&dir=0" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/discountcodes?' + new URLSearchParams({
      DiscountCode_Code: 'example-value',
      orderBy: 'Code',
      dir: 1
    }),
    {
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN'
      }
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://spaces.nexudus.com/api/billing/discountcodes',
      params={
          'DiscountCode_Code': 'example-value',
          'orderBy': 'Code',
          'dir': 0 // Ascending
      },
      headers={
          'Authorization': 'Bearer YOUR_TOKEN'
      }
  )

  data = response.json()
  ```
</CodeGroup>

### Range filters

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET \
    "https://spaces.nexudus.com/api/billing/discountcodes?from_DiscountCode_UpdatedOn=2025-01-01T00:00&to_DiscountCode_UpdatedOn=2025-12-31T23:59&orderBy=UpdatedOn&dir=0" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/discountcodes?' + new URLSearchParams({
      from_DiscountCode_UpdatedOn: '2025-01-01T00:00',
      to_DiscountCode_UpdatedOn: '2025-12-31T23:59',
      orderBy: 'UpdatedOn',
      dir: 1 // Descending
     }),
    {
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN'
      }
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://spaces.nexudus.com/api/billing/discountcodes',
      params={
          'from_DiscountCode_UpdatedOn': '2025-01-01T00:00',
          'to_DiscountCode_UpdatedOn': '2025-12-31T23:59',
          'orderBy': 'UpdatedOn',
          'dir': 1 // Descending
      },
      headers={
          'Authorization': 'Bearer YOUR_TOKEN'
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Records" type="DiscountCode[]">
  The list of DiscountCode records matching the query. See the [Get one DiscountCode](/rest-api/billing/get-discountcodes-by-id) endpoint for the full list of properties returned for each record.
</ResponseField>

<Warning>
  **Partial records** — The listing endpoint returns a summary representation of each DiscountCode. The following fields are **not populated** in the `Records[]` response: `PublishFrom`, `PublishTo`, `ReferralDiscount`, `DiscountPricePlans`, `DiscountBookings`, `DiscountProducts`, `DiscountEvents`, `MaxUsesPerUser`, `MaxUses`, `OnlyForContacts`, `OnlyForMembers`, `ValidTo`, `ExpirationType`, `ExpiresIn`.

  To get all fields, fetch the full record using the [Get one DiscountCode](/rest-api/billing/get-discountcodes-by-id) endpoint.

  **Important for updates:** When updating a record via `PUT`, always retrieve the full record with a `GET` request first, apply your changes to that complete data, and then send the updated record. Do not use data from a listing response as the base for a `PUT` request, as missing fields may be unintentionally cleared.
</Warning>

<ResponseField name="CurrentPage" type="integer">
  Current page number.
</ResponseField>

<ResponseField name="CurrentPageSize" type="integer">
  Number of records per page.
</ResponseField>

<ResponseField name="CurrentOrderField" type="string">
  The field used for sorting.
</ResponseField>

<ResponseField name="CurrentSortDirection" type="integer">
  The sort direction (`0` = ascending, `1` = descending).
</ResponseField>

<ResponseField name="FirstItem" type="integer">
  Index of the first item on the current page.
</ResponseField>

<ResponseField name="LastItem" type="integer">
  Index of the last item on the current page.
</ResponseField>

<ResponseField name="TotalItems" type="integer">
  Total number of matching records across all pages.
</ResponseField>

<ResponseField name="TotalPages" type="integer">
  Total number of pages.
</ResponseField>

<ResponseField name="HasNextPage" type="boolean">
  Whether there is a next page of results.
</ResponseField>

<ResponseField name="HasPreviousPage" type="boolean">
  Whether there is a previous page of results.
</ResponseField>

```json Example Response theme={null}
{
  "Records": [
    {
      "BusinessId": 0,
      "BusinessName": null,
      "BusinessCurrencyCode": null,
      "Code": "",
      "Description": "",
      "Active": false,
      "DiscountPercentage": null,
      "DiscountAmount": null,
      "Tariffs": [],
      "ResourceTypes": [],
      "Products": [],
      "EventCategories": [],
      "ValidFrom": null,
      "Id": 87654321,
      "UpdatedOn": "2025-01-15T10:30:00Z",
      "CreatedOn": "2025-01-10T08:00:00Z",
      "UniqueId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "UpdatedBy": "admin@example.com",
      "IsNew": false,
      "SystemId": null,
      "ToStringText": "DiscountCode Example",
      "LocalizationDetails": null,
      "CustomFields": null
    }
  ],
  "CurrentPageSize": 15,
  "CurrentPage": 1,
  "CurrentOrderField": "Code",
  "CurrentSortDirection": 1,
  "FirstItem": 1,
  "HasNextPage": false,
  "HasPreviousPage": false,
  "LastItem": 1,
  "PageNumber": 1,
  "PageSize": 15,
  "TotalItems": 1,
  "TotalPages": 1
}
```
