# Discount Codes

## GraphQL partial SDLs

This is a graphql reference page. In the llms.txt variant, those components link to the shared partial SDL key list instead of trying to resolve inline GraphQL reference content.

Fetch all available partial SDL keys first:

```text
GET https://docs.commercetools.com/apis/rest/content/by-id?id=ctp:gql-sphere:returnTypesList
```

Then fetch the one or more relevant partial SDL with a key from that list by calling the same endpoint with a schema ID:

```text
GET https://docs.commercetools.com/apis/rest/content/by-id?id=ctp:gql-sphere:schema:<key>
```

The response body is a JSON object keyed by the requested content ID. For example, the key-list request returns a `ctp:gql-sphere:returnTypesList` field and a schema request returns a `ctp:gql-sphere:schema:<key>` field.

**Queries and mutations for managing Discount Codes in the platform.**

## Queries

### Query Discount Codes

[fetch SDL for query discountCodes](#graphql-partial-sdls).

### Get Discount Code

[fetch SDL for query discountCode](#graphql-partial-sdls).

## Mutations

### Create Discount Code

[fetch SDL for mutation createDiscountCode](#graphql-partial-sdls).

### Update Discount Code

[fetch SDL for mutation updateDiscountCode](#graphql-partial-sdls).

### Delete Discount Code

[fetch SDL for mutation deleteDiscountCode](#graphql-partial-sdls).

## Output types

### DiscountCode

[fetch SDL for type DiscountCode](#graphql-partial-sdls).

### Discount Code Query Result

[fetch SDL for type DiscountCodeQueryResult](#graphql-partial-sdls).

## Input types

### DiscountCodeDraft

[fetch SDL for type DiscountCodeDraft](#graphql-partial-sdls).

### DiscountCodeUpdateAction

[fetch SDL for type DiscountCodeUpdateAction](#graphql-partial-sdls).

### Update actions

#### Change Cart Discounts

[fetch SDL for type ChangeDiscountCodeCartDiscounts](#graphql-partial-sdls).

#### Change Groups

[fetch SDL for type ChangeDiscountCodeGroups](#graphql-partial-sdls).

#### Change Is Active

[fetch SDL for type ChangeDiscountCodeIsActive](#graphql-partial-sdls).

#### Set Cart Predicate

[fetch SDL for type SetDiscountCodeCartPredicate](#graphql-partial-sdls).

#### Set Custom Field

[fetch SDL for type SetDiscountCodeCustomField](#graphql-partial-sdls).

#### Set Custom Type

[fetch SDL for type SetDiscountCodeCustomType](#graphql-partial-sdls).

#### Set Description

[fetch SDL for type SetDiscountCodeDescription](#graphql-partial-sdls).

#### Set Key

[fetch SDL for type SetDiscountCodeKey](#graphql-partial-sdls).

#### Set Max Applications

[fetch SDL for type SetDiscountCodeMaxApplications](#graphql-partial-sdls).

#### Set Max Applications Per Customer

[fetch SDL for type SetDiscountCodeMaxApplicationsPerCustomer](#graphql-partial-sdls).

#### Set Name

[fetch SDL for type SetDiscountCodeName](#graphql-partial-sdls).

#### Set Valid From

[fetch SDL for type SetDiscountCodeValidFrom](#graphql-partial-sdls).

#### Set Valid From And Until

[fetch SDL for type SetDiscountCodeValidFromAndUntil](#graphql-partial-sdls).

#### Set Valid Until

[fetch SDL for type SetDiscountCodeValidUntil](#graphql-partial-sdls).

## Related pages

- [Search documentation and API specs](/search.md)