---
title: "discountAutomaticBxgyCreate"
description: "创建买X送Y自动折扣"
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-automatic-bxgy-create'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-automatic-bxgy-create.md'
---
# discountAutomaticBxgyCreate

创建买X送Y自动折扣

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

## Type Signature

`DiscountAutomaticBxgyCreatePayload`

## Required Permissions

* `write_discounts`

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

## Arguments

* `automaticBxgyDiscount`

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

  创建买X送Y自动折扣的输入字段

## Returns

* `automaticDiscountNode`

  [DiscountAutomaticNode](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-automatic-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 discountAutomaticBxgyCreate($automaticBxgyDiscount: DiscountAutomaticBxgyInput ) {
	discountAutomaticBxgyCreate(automaticBxgyDiscount: $automaticBxgyDiscount ) 
		 {
			# DiscountAutomaticBxgyCreatePayload fields
		}
		
	}

```

## Variables

```json
{
  "automaticBxgyDiscount": {
    "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": {}
      }
    },
    "endsAt": {},
    "startsAt": "{}",
    "title": {},
    "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)。

