---
title: "discountCodeBasicCreate"
description: "创建基本代码折扣"
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-basic-create'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/mutations/discount-code-basic-create.md'
---
# discountCodeBasicCreate

创建基本代码折扣

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

## Type Signature

`DiscountCodeBasicCreatePayload`

## Required Permissions

* `write_discounts`

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

## Arguments

* `basicCodeDiscount`

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

  用于创建代码折扣的输入数据

## 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 discountCodeBasicCreate($basicCodeDiscount: DiscountCodeBasicInput! ) {
	discountCodeBasicCreate(basicCodeDiscount: $basicCodeDiscount ) 
		 {
			# DiscountCodeBasicCreatePayload fields
		}
		
	}

```

## Variables

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

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

