Eventjet GraphQL API documentation

generateDiscountCodes

Generates a batch of codes with random code strings and bundles them in a new DiscountGroup.

Every generated code carries the same benefit and the same constraints. The code strings themselves are assigned for you, so read them afterwards from DiscountGroup.discounts or get a link to the full list from DiscountGroup.downloadUrl. Use createDiscount when you want to pick the code string yourself.

GenerateDiscountCodesInput.numberOfCodes must be at least 1 and may not exceed the maximum number of codes that can be generated in one call; both violations respond with an error. GenerateDiscountCodesInput.groupName becomes DiscountGroup.name, must not be empty, and does not have to be unique.

Constraints follow the same shape as in createDiscount: exactly one of time, redemptions or ticketTypes per entry, at most one entry per kind, and an entry with no field set responds with an error. Unlike createDiscount, ticket type IDs that do not exist are dropped here instead of being reported.

Generation is asynchronous. The response waits a short while for the new group to appear; for small batches it is there right away. If it does not appear in time, Mutation.generateDiscountCodes resolves to null even though the codes are being created. In that case locate the group through Company.discountGroups. Either way, poll DiscountGroup.isGenerating until it turns false before treating the group as complete.

mutation GenerateCodes($companyId: ID!) {
  generateDiscountCodes(
    input: {
      companyId: $companyId
      groupName: "Newsletter 2026"
      numberOfCodes: 500
      benefit: { fixedDiscount: { amount: 10, currencyCode: "EUR" } }
      constraints: [{ redemptions: 1 }]
    }
  ) {
    discountGroup {
      id
      isGenerating
      numberOfDiscounts
    }
  }
}
mutation GenerateCodes($companyId: ID!) {
  generateDiscountCodes(
    input: {
      companyId: $companyId
      groupName: "Newsletter 2026"
      numberOfCodes: 500
      benefit: { fixedDiscount: { amount: 10, currencyCode: "EUR" } }
      constraints: [{ redemptions: 1 }]
    }
  ) {
    discountGroup {
      id
      isGenerating
      numberOfDiscounts
    }
  }
}

Authorization is required: you must be allowed to manage the discounts of the given company.

Arguments

ArgumentDescriptionType
inputGenerateDiscountCodesInput!

Type

This field resolves to GenerateDiscountCodesPayload, which has the following fields:

FieldDescriptionType
discountGroupDiscountGroup