---
title: "discountAutomaticDoniCreate"
description: "创建一个第M件折扣的自动折扣"
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-doni-create'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-automatic-doni-create.md'
---
# discountAutomaticDoniCreate

创建一个第M件折扣的自动折扣

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

## Type Signature

`DiscountAutomaticDoniCreatePayload`

## Required Permissions

* `write_discounts`

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

## Arguments

* `automaticDoniDiscount`

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

  创建第M件折扣自动折扣的输入字段

## 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 discountAutomaticDoniCreate($automaticDoniDiscount: DiscountAutomaticDoniInput! ) {
	discountAutomaticDoniCreate(automaticDoniDiscount: $automaticDoniDiscount ) 
		 {
			# DiscountAutomaticDoniCreatePayload fields
		}
		
	}

```

## Variables

```json
{
  "automaticDoniDiscount": {
    "combinesWith": {
      "orderDiscounts": false,
      "productDiscounts": false,
      "shippingDiscounts": false
    },
    "customerGets": {
      "items": {
        "all": false,
        "collections": {
          "add": {},
          "remove": ""
        },
        "products": {
          "productVariantsToAdd": "",
          "productVariantsToRemove": "",
          "productsToAdd": "",
          "productsToRemove": ""
        }
      },
      "value": {
        "discountAmount": {
          "amount": "{}",
          "appliesOnEachItem": {}
        },
        "discountOnQuantity": {
          "effect": {
            "amount": {},
            "percentage": {}
          },
          "quantity": {}
        },
        "percentage": "{}"
      }
    },
    "endsAt": "{}",
    "minimumRequirement": {
      "quantity": {
        "greaterThanOrEqualToQuantity": 0
      },
      "subtotal": {
        "greaterThanOrEqualToSubtotal": "{}"
      }
    },
    "startsAt": {},
    "title": {}
  }
}
```

## 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)。

