# Discount Codes With Discount Codes it is possible to give specific Cart Discounts to eligible customers. They are defined by a string value which can be added to a Cart so that specific Cart Discounts can be applied to the cart. A [DiscountCode](/urn?urn=ctp%3Aapi%3Atype%3ADiscountCode) can apply up to **10** [CartDiscounts](/api/projects/cartDiscounts.md#cartdiscount). Discount Codes inherit their Store association from the Cart Discounts they reference. For an introduction to Discount Codes and to understand how they work, see the [Discount Codes overview](/api/pricing-and-discounts-overview.md#discount-codes). Learn more about Discount Codes in our self-paced Discount Codes module. ## Representations #### DiscountCode [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCode). #### DiscountCodeDraft [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeDraft). #### DiscountCodePagedQueryResponse [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodePagedQueryResponse). #### DiscountCodeReference [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeReference). #### DiscountCodeKeyReference [type definition](/api/projects/discountCodes.md?urn=ctp:import:type:DiscountCodeKeyReference). #### DiscountCodeResourceIdentifier [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeResourceIdentifier). ## Get DiscountCode ### Get DiscountCode by ID [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/\{id}:GET). ### Get DiscountCode by Key [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/key=\{key}:GET). ## Get DiscountCode in Store ### Get DiscountCode in Store by ID [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/in-store/key=\{storeKey}/discount-codes/\{id}:GET). ### Get DiscountCode in Store by Key [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/in-store/key=\{storeKey}/discount-codes/key=\{key}:GET). ## Query DiscountCodes [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes:GET). ## Query DiscountCodes in Store [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/in-store/key=\{storeKey}/discount-codes:GET). ## Check if DiscountCode exists ### Check if DiscountCode exists by ID [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/\{id}:HEAD). ### Check if DiscountCode exists by Key [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/key=\{key}:HEAD). ### Check if DiscountCode exists by Query Predicate [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes:HEAD). ## Check if DiscountCode exists in Store ### Check if DiscountCode exists in Store by ID [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/in-store/key=\{storeKey}/discount-codes/\{id}:HEAD). ### Check if DiscountCode exists in Store by Key [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/in-store/key=\{storeKey}/discount-codes/key=\{key}:HEAD). ### Check if DiscountCode exists in Store by Query Predicate [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/in-store/key=\{storeKey}/discount-codes:HEAD). ## Create DiscountCode [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes:POST). ## Update DiscountCode ### Update DiscountCode by ID [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/\{id}:POST). ### Update DiscountCode by Key [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/key=\{key}:POST). ## Update actions #### Set Key [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetKeyAction). #### Set Name [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetNameAction). #### Set Description [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetDescriptionAction). #### Set Cart Predicate [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetCartPredicateAction). #### Set Max Applications [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetMaxApplicationsAction). #### Set Max Applications Per Customer [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetMaxApplicationsPerCustomerAction). #### Set Custom Type [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetCustomTypeAction). #### Set CustomField [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetCustomFieldAction). #### Change CartDiscounts [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeChangeCartDiscountsAction). #### Change Groups [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeChangeGroupsAction). #### Change IsActive [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeChangeIsActiveAction). #### Set Valid From [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetValidFromAction). #### Set Valid Until [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetValidUntilAction). #### Set Valid From and Until [type definition](/api/projects/discountCodes.md?urn=ctp:api:type:DiscountCodeSetValidFromAndUntilAction). ## Delete DiscountCode The API does not check if a CartDiscount, Cart, or Order exists that has a reference to the DiscountCode before deleting it. ### Delete DiscountCode by ID [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/\{id}:DELETE). ### Delete DiscountCode by Key [endpoint definition](/api/projects/discountCodes.md?urn=ctp:api:endpoint:/\{projectKey}/discount-codes/key=\{key}:DELETE). ## Related pages - [Area overview page with navigation](/api.md) - [Previous page: Cart Discounts](/api/projects/cartDiscounts.md) - [Next page: Discount Groups](/api/projects/discount-groups.md)