---
title: "discountCodeBxgyCreate"
description: "创建一个买X得到Y（BXGY）代码折扣。"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-code-bxgy-create'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-code-bxgy-create.md'
---
# discountCodeBxgyCreate

创建一个买X得到Y（BXGY）代码折扣。

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

## Type Signature

`DiscountCodeBxgyCreatePayload`

## Required Permissions

* `write_discounts`

接口访问需要令牌，具体如何获取令牌请参考：[身份认证](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md)

## Arguments

* `bxgyCodeDiscount`

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

  创建买X得到Y折扣码的输入字段

## Returns

* `codeDiscountNode`

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

  创建的代码折扣

* `userErrors`

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

  执行突变时发生的错误列表。
  

## Code Example

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

```

## Variables

```json
{
  "bxgyCodeDiscount": {
    "appliesTimesPerCustomer": 0,
    "code": "",
    "combinesWith": {
      "orderDiscounts": false,
      "productDiscounts": {},
      "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

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

