---
title: "discountCodeBxgyCreate"
description: "A Buy X get Y (BXGY) code discount will be created."
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20260901
source_url:
  html: 'https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-code-bxgy-create'
  md: 'https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-code-bxgy-create.md'
---
# discountCodeBxgyCreate

A Buy X get Y (BXGY) code discount will be created.

- **Required Scopes:** `write_discounts`
- **API Version:** v20260901
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Type Signature

`DiscountCodeBxgyCreatePayload`

## Required Permissions

* `write_discounts`

An access token is required to call this API. Refer to [Authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md) for more information about how to obtain the token.

## Arguments

* `bxgyCodeDiscount`

  [DiscountCodeBxgyInput!](https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/inputs/discount-code-bxgy-input.md)

  Input fields for creating a Buy X Get Y discount code.

## Returns

* `codeDiscountNode`

  [DiscountCodeNode](https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-code-node.md)

  The created code discount.
  
  

* `userErrors`

  [[DiscountUserError!]!](https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-user-error.md)

  The list of errors that occurred from executing the mutation.

## Code Example

```graphql
mutation discountCodeBxgyCreate($bxgyCodeDiscount: DiscountCodeBxgyInput! ) {
	discountCodeBxgyCreate(bxgyCodeDiscount: $bxgyCodeDiscount ) 
		 {
			# DiscountCodeBxgyCreatePayload fields
		}
		
	}

```

## Variables

```json
{
  "bxgyCodeDiscount": {
    "appliesTimesPerCustomer": 0,
    "code": "",
    "combinesWith": {
      "orderDiscounts": {},
      "productDiscounts": false,
      "shippingDiscounts": false
    },
    "customerBuys": {
      "items": "{}",
      "value": {
        "amount": "{}",
        "quantity": 0
      }
    },
    "customerGets": {
      "items": {
        "all": false,
        "collections": {
          "add": "",
          "remove": ""
        },
        "products": {
          "productVariantsToAdd": "",
          "productVariantsToRemove": "",
          "productsToAdd": {},
          "productsToRemove": ""
        }
      },
      "value": {
        "discountAmount": {
          "amount": "{}",
          "appliesOnEachItem": false
        },
        "discountOnQuantity": {
          "effect": {
            "amount": {},
            "percentage": {}
          },
          "quantity": {}
        },
        "percentage": "{}"
      }
    },
    "customerSelection": {
      "all": false,
      "customerSegments": {
        "add": "",
        "remove": ""
      },
      "customers": {
        "add": "",
        "remove": ""
      }
    },
    "endsAt": "{}",
    "startsAt": {},
    "title": {},
    "usageLimit": 0,
    "usesPerOrderLimit": 0
  }
}
```

## Error Handling

For detailed information about common codes, see [Status and error codes](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes).

