younifyd
Menu

discountRedeemCodeBulkAdd

Asynchronously add discount codes in bulk that customers can use to redeem a discount. You can use the discountRedeemCodeBulkAdd mutation to automate the distribution of discount codes through emails or other…

Use it in a workflow

  1. Add a step and choose the Shopify connector.
  2. Pick the discountRedeemCodeBulkAdd action (under Discount).
  3. Fill in the fields below, then reference the result from later steps as {{discountredeemcodebulkadd.response.data}}.

Query

This is the mutation the action sends by default. Edit it in the step's Query field to change which fields come back.

graphql
mutation DiscountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {
  discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {
    bulkCreation {
      codesCount
      createdAt
      discountCode {
        codeDiscount
        id
      }
      done
      failedCount
      id
      importedCount
    }
    userErrors {
      code
      extraInfo
      field
      message
    }
  }
}

Variables

Pass these as a JSON object in the step's Variables field.

discountIdstringrequired

The ID of the [`DiscountCodeNode`](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountCodeNode#field-id) object that the codes will be added to. For example, `gid://shopify/DiscountCodeNode/123`. You can use the [`codeDiscountNodes` query](https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNodes) to retrieve the ID.

codesarray<object>required

The list of codes to associate with the [code discount](https://help.shopify.com/manual/discounts/discount-types#discount-codes). Maximum: 250 codes.

codestringrequired
json
{
  "discountId": "string",
  "codes": [
    {
      "code": "string"
    }
  ]
}

Response

Read the result with {{discountredeemcodebulkadd.response.data.data.discountRedeemCodeBulkAdd}}. If the API returns errors, the step fails and they are at {{discountredeemcodebulkadd.response.data.errors}}.

bulkCreationobject
codesCountnumber
createdAtstring
discountCodeobject2 fields
doneboolean
failedCountnumber
idstring
importedCountnumber
userErrorsarray<object>
codeobject
extraInfoobject
fieldobject
messageobject

Need more? See the Shopify guide for connection setup and behaviour shared by every action.