discount Redeem Code Bulk Addmutation
Requires Apps must have write
access scope.
Asynchronously add discount redeem codes in bulk. Specify the codes to add and the discount code ID that the codes will belong to.
Arguments
The list of codes that will be added to the code discount. Maximum 100 codes permitted.
The ID of the code discount that the codes will be added to.
DiscountRedeemCodeBulkAddPayload returns
The ID of the discount redeem code bulk creation operation. The properties and status of the operation can be tracked using the
Discount
query.Redeem Code Bulk Creation The list of errors that occurred from executing the mutation.
Code examples for MUTATION: discountRedeemCodeBulkAdd
Query Reference for MUTATION: discountRedeemCodeBulkAdd
"mutation discountRedeemCodeBulkAdd($codes: [DiscountRedeemCodeInput!]!, $discountId: ID!) {\n discountRedeemCodeBulkAdd(codes: $codes, discountId: $discountId) {\n bulkCreation {\n # DiscountRedeemCodeBulkCreation fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: discountRedeemCodeBulkAdd
"{\n \"codes\": [\n {\n \"code\": \"<your-code>\"\n }\n ],\n \"discountId\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: discountRedeemCodeBulkAdd
"input DiscountRedeemCodeInput {\n code: String!\n}\n"
Display Examples for MUTATION: discountRedeemCodeBulkAdd
[ { "example": { "type_name": "discountredeemcodebulkadd", "title": "Asynchronously add redeem codes to a code discount", "description": "Asynchronously add 3 redeem codes to a code discount", "query_string": "mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {\n discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {\n bulkCreation {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n}", "variables": { "discountId": "gid://shopify/DiscountCodeNode/2429471", "codes": [ { "code": "DISCOUNT_1" }, { "code": "DISCOUNT_2" }, { "code": "DISCOUNT_3" } ] }, "response": { "data": { "discountRedeemCodeBulkAdd": { "bulkCreation": { "id": "gid://shopify/DiscountRedeemCodeBulkCreation/989355119" }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_redeem_code_bulk_add_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) { discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) { bulkCreation { id } userErrors { code field message } } }\",\n \"variables\": {\n \"discountId\": \"gid://shopify/DiscountCodeNode/2429471\",\n \"codes\": [\n {\n \"code\": \"DISCOUNT_1\"\n },\n {\n \"code\": \"DISCOUNT_2\"\n },\n {\n \"code\": \"DISCOUNT_3\"\n }\n ]\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {\n discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {\n bulkCreation {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"discountId\": \"gid://shopify/DiscountCodeNode/2429471\",\n \"codes\": [\n {\n \"code\": \"DISCOUNT_1\"\n },\n {\n \"code\": \"DISCOUNT_2\"\n },\n {\n \"code\": \"DISCOUNT_3\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {\n discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {\n bulkCreation {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"discountId\": \"gid://shopify/DiscountCodeNode/2429471\",\n \"codes\": [{\"code\"=>\"DISCOUNT_1\"}, {\"code\"=>\"DISCOUNT_2\"}, {\"code\"=>\"DISCOUNT_3\"}]\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {\n discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {\n bulkCreation {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"discountId\": \"gid://shopify/DiscountCodeNode/2429471\",\n \"codes\": [\n {\n \"code\": \"DISCOUNT_1\"\n },\n {\n \"code\": \"DISCOUNT_2\"\n },\n {\n \"code\": \"DISCOUNT_3\"\n }\n ]\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {\n discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {\n bulkCreation {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"discountId\" => \"gid://shopify/DiscountCodeNode/2429471\",\n \"codes\" => [{\"code\"=>\"DISCOUNT_1\"}, {\"code\"=>\"DISCOUNT_2\"}, {\"code\"=>\"DISCOUNT_3\"}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "discountId", "description": "The ID of the code discount that the codes will be added to.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "discountId", "argValue": " \"gid://shopify/DiscountCodeNode/2429471\"", "typeKind": "MUTATION" }, { "arg": { "name": "codes", "description": "The list of codes that will be added to the code discount. Maximum 100 codes permitted.", "type": { "kind": "INPUT_OBJECT", "name": "DiscountRedeemCodeInput", "list": true, "non_null": true }, "defaultValue": null, "typeSignature": "[DiscountRedeemCodeInput!]!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "codes", "argValue": " [{\"code\":\"DISCOUNT_1\"},{\"code\":\"DISCOUNT_2\"},{\"code\":\"DISCOUNT_3\"}]", "typeKind": "MUTATION" } ] } ]