Importing Discount Codes
Create and update Discount Codes in your Project.
The Discount Codes data to import is represented by DiscountCodeImport and included in a DiscountCodeImportRequest, which is imported using Import Discount Codes.
Representations
DiscountCodeImportRequest
The request body to import Discount Codes. Contains data for Discount Codes to be created or updated in a Project.
type | "discount-code"The Discount Code import resource type. |
resourcesArray of DiscountCodeImport | The Discount Code import resources of this request. MaxItems:20 |
{"type": "discount-code","resources": [{"key": "discountCodeKey","code": "Save10","name": {"en": "Save10"},"cartDiscounts": [{"typeId": "cart-discount","key": "cartDiscountKey"}],"isActive": false,"groups": []}]}
DiscountCodeImport
The data representation for a Discount Code to be imported that is persisted as a Discount Code in the Project.
keyString | User-defined unique identifier. If a Discount Code with this 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
name | Maps to |
description | Maps to |
codeString | User-defined unique identifier of the DiscountCode that is used by the customer to apply the discount. The value cannot be updated. Attempting to update the value will result in an InvalidFieldsUpdate error. |
cartDiscountsArray of CartDiscountKeyReference | Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied. |
cartPredicateString | DiscountCode can only be applied to Carts that match this predicate. |
isActiveBoolean | Indicates if the DiscountCode is active and can be applied to the Cart. |
maxApplicationsInt | Number of times the DiscountCode can be applied. DiscountCode application is counted at the time of Order creation or update. However, Order cancellation or deletion does not decrement the count. |
maxApplicationsPerCustomerInt | Number of times the DiscountCode can be applied per Customer (anonymous Carts are not supported). DiscountCode application is counted at the time of Order creation or update. However, Order cancellation or deletion does not decrement the count. |
groupsArray of String | Groups to which the DiscountCode belongs. |
validFrom | Date and time (UTC) from which the DiscountCode is effective. |
validUntil | Date and time (UTC) until which the DiscountCode is effective. |
custom | Custom Fields of the DiscountCode. |
Import Discount Codes
Creates a request for creating new Discount Codes or updating existing ones.
manage_discount_codes:{projectKey}view_discount_codes:{projectKey}regionString | The Region in which the Project is hosted. |
projectKeyString | The Project key. |
importContainerKeyString | The ImportContainer used to create the new resource |
application/jsonapplication/jsoncurl https://import.{region}.commercetools.com/{projectKey}/discount-codes/import-containers/{importContainerKey} -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"type" : "discount-code","resources" : [ {"key" : "discountCodeKey","code" : "Save10","name" : {"en" : "Save10"},"cartDiscounts" : [ {"typeId" : "cart-discount","key" : "cartDiscountKey"} ],"isActive" : false,"groups" : [ ]} ]}DATA