--- title: DiscountCode description: After setting up the logic for a discount using the PriceRule API, use the DiscountCode API to associate the discount with a code, which can be entered at the checkout to apply the discount. api_version: 2025-10 api_name: admin-rest api_type: rest source_url: html: https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode md: https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode.md --- ![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg) The REST Admin API is a legacy API as of October 1, 2024. Starting April 1, 2025, all new public apps must be built exclusively with the [GraphQL Admin API](https://shopify.dev/docs/api/admin-graphql). For details and migration steps, visit our [migration guide](https://shopify.dev/docs/apps/build/graphql/migrate). # Discount​Code Multiple access scopes needed — refer to each endpoint for access scope requirements. Note We recommend using the GraphQL Admin API to manage discounts. The [Discount types](https://shopify.dev/api/examples/discounts) available in the GraphQL Admin API are intended to replace the GraphQL Admin `PriceRule` object and REST Admin `PriceRule` and `DiscountCode` resources. You can use the PriceRule DiscountCode resource to create discount codes that enable specific discounts to be redeemed. Merchants can distribute discount codes to their customers using a variety of means, such as an email or URL, and customers can apply these codes at checkout. Each discount code belongs to a price rule, which holds the logic for the discount. For more information, see the [PriceRule](https://shopify.dev/docs/admin-api/rest/reference/discounts/pricerule) resource. To create multiple discount codes that use the same price rule logic, use the batch endpoint. For example, you might allow merchants to create a batch of discount codes that belong to the same price rule but are each personalized for a different customer. \# ## Endpoints * [post](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#post-price-rules-price-rule-id-batch) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/batch.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#post-price-rules-price-rule-id-batch) Creates a discount code creation job [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code-creation-job) [discountRedeemCodeBulkAdd](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code-creation-job) * [post](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#post-price-rules-price-rule-id-discount-codes) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/discount\_​codes.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#post-price-rules-price-rule-id-discount-codes) Creates a discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code) [discountRedeemCodeBulkAdd](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code) * [get](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-discount-codes-count) [/admin/api/latest/discount\_​codes/count.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-discount-codes-count) Retrieves a count of discount codes for a shop [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountCodesCount?example=retrieves-a-count-of-discount-codes-for-a-shop) [discountCodesCount](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountCodesCount?example=retrieves-a-count-of-discount-codes-for-a-shop) * [get](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-discount-codes-lookup?code=SUMMERSALE10OFF) [/admin/api/latest/discount\_​codes/lookup.​json?code=SUMMERSALE10OFF](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-discount-codes-lookup?code=SUMMERSALE10OFF) Retrieves the location of a discount code deprecated * [get](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-batch-batch-id) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/batch/{batch\_​id}.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-batch-batch-id) Retrieves a discount code creation job [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-discount-code-creation-job) [discountRedeemCodeBulkCreation](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-discount-code-creation-job) * [get](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-batch-batch-id-discount-codes) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/batch/{batch\_​id}/discount\_​codes.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-batch-batch-id-discount-codes) Retrieves a list of discount codes for a discount code creation job [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-list-of-discount-codes-for-a-discount-code-creation-job) [discountRedeemCodeBulkCreation](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-list-of-discount-codes-for-a-discount-code-creation-job) * [get](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-discount-codes) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/discount\_​codes.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-discount-codes) Retrieves a list of discount codes [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) [codeDiscountNode](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) * [get](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-discount-codes-discount-code-id) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/discount\_​codes/{discount\_​code\_​id}.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#get-price-rules-price-rule-id-discount-codes-discount-code-id) Retrieves a single discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) [codeDiscountNode](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) * [put](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#put-price-rules-price-rule-id-discount-codes-discount-code-id) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/discount\_​codes/{discount\_​code\_​id}.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#put-price-rules-price-rule-id-discount-codes-discount-code-id) Updates an existing discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete) [discountCodeRedeemCodeBulkDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd) [discountRedeemCodeBulkAdd](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd) * [del](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#delete-price-rules-price-rule-id-discount-codes-discount-code-id) [/admin/api/latest/price\_​rules/{price\_​rule\_​id}/discount\_​codes/{discount\_​code\_​id}.​json](https://shopify.dev/docs/api/admin-rest/latest/resources/discountcode#delete-price-rules-price-rule-id-discount-codes-discount-code-id) Deletes a discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete?example=deletes-a-discount-code) [discountCodeRedeemCodeBulkDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete?example=deletes-a-discount-code) *** ## The DiscountCode resource ### Properties *** code -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCode#field-DiscountRedeemCode.fields.code) [code](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCode#field-DiscountRedeemCode.fields.code) The case-insensitive discount code that customers use at checkout. (maximum: 255 characters) Caution Use the same value for `code` as the `title` property of the associated [price rule](https://shopify.dev/docs/admin-api/rest/reference/discounts/pricerule/#title-property). *** created\_at read-only -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCodeBulkCreation#field-DiscountRedeemCodeBulkCreation.fields.createdAt) [createdAt](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCodeBulkCreation#field-DiscountRedeemCodeBulkCreation.fields.createdAt) The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the discount code was created. *** updated\_at read-only The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the discount code was updated. *** id read-only -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCode#field-DiscountRedeemCode.fields.id) [id](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCode#field-DiscountRedeemCode.fields.id) The ID for the discount code. *** price\_rule\_id read-only -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountCodeNode#field-DiscountCodeNode.fields.id) [id](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountCodeNode#field-DiscountCodeNode.fields.id) The ID for the price rule that this discount code belongs to. *** usage\_count read-only -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCode#field-DiscountRedeemCode.fields.asyncUsageCount) [asyncUsageCount](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCode#field-DiscountRedeemCode.fields.asyncUsageCount) The number of times that the discount code has been redeemed. *** errors read-only -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCodeBulkCreationCode#field-DiscountRedeemCodeBulkCreationCode.fields.errors) [errors](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountRedeemCodeBulkCreationCode#field-DiscountRedeemCodeBulkCreationCode.fields.errors) An array of errors that occurred when retrieving a list of discount codes for a discount code creation job. *** {} ## The DiscountCode resource ```json { "code": "SUMMERSALE10OFF", "created_at": "2017-03-13T16:09:54-04:00", "updated_at": "2017-03-13T16:09:54-04:00", "id": 9808080986, "price_rule_id": 423748927342, "usage_count": 3, "errors": { "code": [ "must be unique. Please try a different code." ] } } ``` *** ## postCreates a discount code creation job [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code-creation-job) [discountRedeemCodeBulkAdd](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code-creation-job) Creates a discount code creation job. The batch endpoint can be used to asynchronously create up to 100 discount codes in a single request. It enqueues and returns a `discount_code_creation` object that can be monitored for completion. You can enqueue a single creation job per a shop and you can't enqueue more until the job completes. The `price_rule_id` path parameter is the ID of the price rule that the discount code will belong to. This is required because each discount code must belong to a price rule. Response fields that are specific to the batch endpoint include: * `status`: The state of the discount code creation job. Possible values are: * `queued`: The job is acknowledged, but not started. * `running`: The job is in process. * `completed`: The job has finished. * `codes_count`: The number of discount codes to create. * `imported_count`: The number of discount codes created successfully. * `failed_count`: The number of discount codes that were not created successfully. Unsuccessful attempts will retry up to three times. * `logs`: A report that specifies when no discount codes were created because the provided data was invalid. Example responses: * "Price rule target selection can't be blank" * "Price rule allocation method can't be blank" ### Parameters *** api\_version string required *** price\_rule\_id string required *** ### Examples Create a discount code creation job Path parameters price\_​rule\_​id=​507328175 string required post ## /admin/api/2025-10/price\_​rules/507328175/batch.​json ```bash curl -d '{"discount_codes":[{"code":"SUMMER1"},{"code":"SUMMER2"},{"code":"SUMMER3"}]}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/batch.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` {} ## Response JSON ```json HTTP/1.1 201 Created { "discount_code_creation": { "id": 989355119, "price_rule_id": 507328175, "started_at": null, "completed_at": null, "created_at": "2025-10-01T15:05:46-04:00", "updated_at": "2025-10-01T15:05:46-04:00", "status": "queued", "codes_count": 3, "imported_count": 0, "failed_count": 0, "logs": [] } } ``` ### examples * #### Create a discount code creation job ##### ```curl curl -d '{"discount_codes":[{"code":"SUMMER1"},{"code":"SUMMER2"},{"code":"SUMMER3"}]}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/batch.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const discount_code = new admin.rest.resources.DiscountCode({session: session}); discount_code.price_rule_id = 507328175; await discount_code.batch({ body: {"discount_codes": [{"code": "SUMMER1"}, {"code": "SUMMER2"}, {"code": "SUMMER3"}]}, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session discount_code = ShopifyAPI::DiscountCode.new(session: test_session) discount_code.price_rule_id = 507328175 discount_code.batch( session: test_session, body: {"discount_codes" => [{"code" => "SUMMER1"}, {"code" => "SUMMER2"}, {"code" => "SUMMER3"}]}, ) ``` ##### ```node // Session is built by the OAuth process const discount_code = new shopify.rest.DiscountCode({session: session}); discount_code.price_rule_id = 507328175; await discount_code.batch({ body: {"discount_codes": [{"code": "SUMMER1"}, {"code": "SUMMER2"}, {"code": "SUMMER3"}]}, }); ``` #### response ```json HTTP/1.1 201 Created{"discount_code_creation":{"id":989355119,"price_rule_id":507328175,"started_at":null,"completed_at":null,"created_at":"2025-10-01T15:05:46-04:00","updated_at":"2025-10-01T15:05:46-04:00","status":"queued","codes_count":3,"imported_count":0,"failed_count":0,"logs":[]}} ``` *** ## postCreates a discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code) [discountRedeemCodeBulkAdd](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd?example=creates-a-discount-code) Requires `price_rules` access scope. Creates a discount code. The `price_rule_id` path parameter is the ID of the price rule that the discount code will belong to. This is required because each discount code must belong to a price rule. ### Parameters *** api\_version string required *** price\_rule\_id string required *** ### Examples Create a discount code Path parameters price\_​rule\_​id=​507328175 string required Request body discount\_​code​ Discount\_code resource Show discount\_code properties discount\_​code.code:​"SUMMERSALE10OFF" -> [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/DiscountRedeemCodeInput#fields-code) [code](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/DiscountRedeemCodeInput#fields-code) The case-insensitive discount code that customers use at checkout. (maximum: 255 characters) Caution Use the same value for `code` as the `title` property of the associated [price rule](https://shopify.dev/docs/admin-api/rest/reference/discounts/pricerule/#title-property). post ## /admin/api/2025-10/price\_​rules/507328175/discount\_​codes.​json ```bash curl -d '{"discount_code":{"code":"SUMMERSALE10OFF"}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` {} ## Response JSON ```json HTTP/1.1 201 Created { "discount_code": { "id": 1057371196, "price_rule_id": 507328175, "code": "SUMMERSALE10OFF", "usage_count": 0, "created_at": "2025-10-01T15:05:54-04:00", "updated_at": "2025-10-01T15:05:54-04:00" } } ``` ### examples * #### Create a discount code ##### ```curl curl -d '{"discount_code":{"code":"SUMMERSALE10OFF"}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const discount_code = new admin.rest.resources.DiscountCode({session: session}); discount_code.price_rule_id = 507328175; discount_code.code = "SUMMERSALE10OFF"; await discount_code.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session discount_code = ShopifyAPI::DiscountCode.new(session: test_session) discount_code.price_rule_id = 507328175 discount_code.code = "SUMMERSALE10OFF" discount_code.save! ``` ##### ```node // Session is built by the OAuth process const discount_code = new shopify.rest.DiscountCode({session: session}); discount_code.price_rule_id = 507328175; discount_code.code = "SUMMERSALE10OFF"; await discount_code.save({ update: true, }); ``` #### response ```json HTTP/1.1 201 Created{"discount_code":{"id":1057371196,"price_rule_id":507328175,"code":"SUMMERSALE10OFF","usage_count":0,"created_at":"2025-10-01T15:05:54-04:00","updated_at":"2025-10-01T15:05:54-04:00"}} ``` *** ## getRetrieves a count of discount codes for a shop [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountCodesCount?example=retrieves-a-count-of-discount-codes-for-a-shop) [discountCodesCount](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountCodesCount?example=retrieves-a-count-of-discount-codes-for-a-shop) Requires `price_rules` access scope. Retrieves a count of discount codes for a shop ### Parameters *** api\_version string required *** times\_used Show discount codes with times used. *** times\_used\_max Show discount codes used greater than or equal to this value. *** times\_used\_min Show discount codes used less than or equal to this value. *** ### Examples Retrieve a count of discount codes for a shop tag:elasticsearch:true get ## /admin/api/2025-10/discount\_​codes/count.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/discount_codes/count.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "count": 2 } ``` ### examples * #### Retrieve a count of discount codes for a shop tag:elasticsearch:true ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/discount_codes/count.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.count({ session: session, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.count( session: test_session, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.count({ session: session, }); ``` #### response ```json HTTP/1.1 200 OK{"count":2} ``` *** ## getRetrieves the location of a discount codedeprecated Requires `price_rules` access scope. Retrieves the location of a discount code. The discount code's location is returned in the location header, not in the DiscountCode object itself. Depending on your HTTP client, the location of the discount code might follow the location header automatically. ### Parameters *** api\_version string required *** code required ≤ 100 Retrieves the location of a discount code by code name. *** ### Examples Search for a discount code Query parameters code=​SUMMERSALE10OFF required ≤ 100 Retrieves the location of a discount code by code name. get ## /admin/api/2025-10/discount\_​codes/lookup.​json?code=​SUMMERSALE10OFF ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/discount_codes/lookup.json?code=SUMMERSALE10OFF" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 303 See Other ``` ### examples * #### Search for a discount code ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/discount_codes/lookup.json?code=SUMMERSALE10OFF" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.lookup({ session: session, code: "SUMMERSALE10OFF", }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.lookup( session: test_session, code: "SUMMERSALE10OFF", ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.lookup({ session: session, code: "SUMMERSALE10OFF", }); ``` #### response ```json HTTP/1.1 303 See Other ``` *** ## getRetrieves a discount code creation job [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-discount-code-creation-job) [discountRedeemCodeBulkCreation](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-discount-code-creation-job) Retrieves a discount code creation job The `price_rule_id` path parameter is the ID of the price rule that the discount code creation job was ran for. This is required because each discount code creation job is associated to a price rule. The `batch_id` path parameter is the ID of the discount code creation job for the associated price rule. ### Parameters *** api\_version string required *** batch\_id string required *** price\_rule\_id string required *** ### Examples Retrieve a discount code creation job get ## /admin/api/2025-10/price\_​rules/507328175/batch/173232803.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/batch/173232803.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "discount_code_creation": { "id": 173232803, "price_rule_id": 507328175, "started_at": null, "completed_at": null, "created_at": "2025-10-01T15:04:04-04:00", "updated_at": "2025-10-01T15:04:04-04:00", "status": "queued", "codes_count": 3, "imported_count": 0, "failed_count": 0, "logs": [] } } ``` ### examples * #### Retrieve a discount code creation job ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/batch/173232803.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.get_all({ session: session, price_rule_id: 507328175, batch_id: 173232803, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.get_all( session: test_session, price_rule_id: 507328175, batch_id: 173232803, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.get_all({ session: session, price_rule_id: 507328175, batch_id: 173232803, }); ``` #### response ```json HTTP/1.1 200 OK{"discount_code_creation":{"id":173232803,"price_rule_id":507328175,"started_at":null,"completed_at":null,"created_at":"2025-10-01T15:04:04-04:00","updated_at":"2025-10-01T15:04:04-04:00","status":"queued","codes_count":3,"imported_count":0,"failed_count":0,"logs":[]}} ``` *** ## getRetrieves a list of discount codes for a discount code creation job [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-list-of-discount-codes-for-a-discount-code-creation-job) [discountRedeemCodeBulkCreation](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountRedeemCodeBulkCreation?example=retrieves-a-list-of-discount-codes-for-a-discount-code-creation-job) Retrieves a list of discount codes for a discount code creation job. The `price_rule_id` path parameter is the ID of the price rule that the discount code creation job was ran for. This is required because each discount code creation job is associated to a price rule. The `batch_id` path parameter is the ID of the discount code creation job for the associated price rule. Discount codes that have been successfully created include a populated `id` field. Discount codes that encountered errors during the creation process include a populated `errors` field. ### Parameters *** api\_version string required *** batch\_id string required *** price\_rule\_id string required *** ### Examples Retrieve a list of discount codes for a discount code creation job get ## /admin/api/2025-10/price\_​rules/507328175/batch/173232803/discount\_​codes.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/batch/173232803/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "discount_codes": [ { "id": null, "code": "foo", "errors": {} }, { "id": null, "code": "", "errors": {} }, { "id": null, "code": "bar", "errors": {} } ] } ``` ### examples * #### Retrieve a list of discount codes for a discount code creation job ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/batch/173232803/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.all({ session: session, price_rule_id: 507328175, batch_id: 173232803, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.all( session: test_session, price_rule_id: 507328175, batch_id: 173232803, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.all({ session: session, price_rule_id: 507328175, batch_id: 173232803, }); ``` #### response ```json HTTP/1.1 200 OK{"discount_codes":[{"id":null,"code":"foo","errors":{}},{"id":null,"code":"","errors":{}},{"id":null,"code":"bar","errors":{}}]} ``` *** ## getRetrieves a list of discount codes [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) [codeDiscountNode](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) Requires `price_rules` access scope. Retrieve a list of discount codes. **Note:** This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to [Make paginated requests to the REST Admin API](https://shopify.dev/api/usage/pagination-rest). The `price_rule_id` path parameter is the ID of the price rule that the discount codes belongs to. ### Parameters *** api\_version string required *** price\_rule\_id string required *** ### Examples Retrieve a list of all discount codes Path parameters price\_​rule\_​id=​507328175 string required get ## /admin/api/2025-10/price\_​rules/507328175/discount\_​codes.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "discount_codes": [ { "id": 507328175, "price_rule_id": 507328175, "code": "SUMMERSALE10OFF", "usage_count": 0, "created_at": "2025-10-01T15:04:04-04:00", "updated_at": "2025-10-01T15:04:04-04:00" } ] } ``` ### examples * #### Retrieve a list of all discount codes ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.all({ session: session, price_rule_id: 507328175, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.all( session: test_session, price_rule_id: 507328175, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.all({ session: session, price_rule_id: 507328175, }); ``` #### response ```json HTTP/1.1 200 OK{"discount_codes":[{"id":507328175,"price_rule_id":507328175,"code":"SUMMERSALE10OFF","usage_count":0,"created_at":"2025-10-01T15:04:04-04:00","updated_at":"2025-10-01T15:04:04-04:00"}]} ``` *** ## getRetrieves a single discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) [codeDiscountNode](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNode) Requires `price_rules` access scope. Retrieves a single discount code. The `price_rule_id` path parameter is the ID of the price rule that the discount code belongs to. This is required because each discount code must belong to a price rule. The `discount_code_id` path parameter is the ID of the discount code to retrieve for the associated price rule. ### Parameters *** api\_version string required *** discount\_code\_id string required *** price\_rule\_id string required *** ### Examples Retrieve a single discount code get ## /admin/api/2025-10/price\_​rules/507328175/discount\_​codes/507328175.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "discount_code": { "id": 507328175, "price_rule_id": 507328175, "code": "SUMMERSALE10OFF", "usage_count": 0, "created_at": "2025-10-01T15:04:04-04:00", "updated_at": "2025-10-01T15:04:04-04:00" } } ``` ### examples * #### Retrieve a single discount code ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.find({ session: session, price_rule_id: 507328175, id: 507328175, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.find( session: test_session, price_rule_id: 507328175, id: 507328175, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.find({ session: session, price_rule_id: 507328175, id: 507328175, }); ``` #### response ```json HTTP/1.1 200 OK{"discount_code":{"id":507328175,"price_rule_id":507328175,"code":"SUMMERSALE10OFF","usage_count":0,"created_at":"2025-10-01T15:04:04-04:00","updated_at":"2025-10-01T15:04:04-04:00"}} ``` *** ## putUpdates an existing discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete) [discountCodeRedeemCodeBulkDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd) [discountRedeemCodeBulkAdd](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountRedeemCodeBulkAdd) Requires `price_rules` access scope. Updates an existing discount code. The `price_rule_id` path parameter is the ID of the price rule that the discount code belongs to. This is required because each discount code must belong to a price rule. The `discount_code_id` path parameter is the ID of the discount code to update for the associated price rule. ### Parameters *** api\_version string required *** discount\_code\_id string required *** price\_rule\_id string required *** ### Examples Update the code for a discount Request body discount\_​code​ Discount\_code resource Show discount\_code properties discount\_​code.id:​507328175 read-only The ID for the discount code. discount\_​code.code:​"WINTERSALE20OFF" The case-insensitive discount code that customers use at checkout. (maximum: 255 characters) Caution Use the same value for `code` as the `title` property of the associated [price rule](https://shopify.dev/docs/admin-api/rest/reference/discounts/pricerule/#title-property). put ## /admin/api/2025-10/price\_​rules/507328175/discount\_​codes/507328175.​json ```bash curl -d '{"discount_code":{"id":507328175,"code":"WINTERSALE20OFF"}}' \ -X PUT "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "discount_code": { "id": 507328175, "price_rule_id": 507328175, "code": "WINTERSALE20OFF", "usage_count": 0, "created_at": "2025-10-01T15:04:04-04:00", "updated_at": "2025-10-01T15:05:51-04:00" } } ``` ### examples * #### Update the code for a discount ##### ```curl curl -d '{"discount_code":{"id":507328175,"code":"WINTERSALE20OFF"}}' \ -X PUT "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const discount_code = new admin.rest.resources.DiscountCode({session: session}); discount_code.price_rule_id = 507328175; discount_code.id = 507328175; discount_code.code = "WINTERSALE20OFF"; await discount_code.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session discount_code = ShopifyAPI::DiscountCode.new(session: test_session) discount_code.price_rule_id = 507328175 discount_code.id = 507328175 discount_code.code = "WINTERSALE20OFF" discount_code.save! ``` ##### ```node // Session is built by the OAuth process const discount_code = new shopify.rest.DiscountCode({session: session}); discount_code.price_rule_id = 507328175; discount_code.id = 507328175; discount_code.code = "WINTERSALE20OFF"; await discount_code.save({ update: true, }); ``` #### response ```json HTTP/1.1 200 OK{"discount_code":{"id":507328175,"price_rule_id":507328175,"code":"WINTERSALE20OFF","usage_count":0,"created_at":"2025-10-01T15:04:04-04:00","updated_at":"2025-10-01T15:05:51-04:00"}} ``` *** ## delDeletes a discount code [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete?example=deletes-a-discount-code) [discountCodeRedeemCodeBulkDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeRedeemCodeBulkDelete?example=deletes-a-discount-code) Requires `price_rules` access scope. Deletes a discount code. The `price_rule_id` path parameter is the ID of the price rule that the discount code belongs to. This is required because each discount code must belong to a price rule. The `discount_code_id` path parameter is the ID of the discount code to delete for the associated price rule. ### Parameters *** api\_version string required *** discount\_code\_id string required *** price\_rule\_id string required *** ### Examples Delete a discount code del ## /admin/api/2025-10/price\_​rules/507328175/discount\_​codes/507328175.​json ```bash curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 204 No Content ``` ### examples * #### Delete a discount code ##### ```curl curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.DiscountCode.delete({ session: session, price_rule_id: 507328175, id: 507328175, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::DiscountCode.delete( session: test_session, price_rule_id: 507328175, id: 507328175, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.DiscountCode.delete({ session: session, price_rule_id: 507328175, id: 507328175, }); ``` #### response ```json HTTP/1.1 204 No Content ```