data-src=../../../../../includes/commerce-only.md

createPurchaseOrderApprovalRule mutation

The createPurchaseOrderApprovalRule mutation creates a purchase order approval rule.

A request to create an approval rule must include the following fields and objects:

The condition object must contain an attribute field, an operator, and either an amount or a quantity. The attribute field determines if the rule checks the order total (GRAND_TOTAL), the number of SKUs in the order (NUMBER_OF_SKUS), or the shipping expense (SHIPPING_INCL_TAX). The operator must be one of MORE_THAN, LESS_THAN, MORE_THAN_OR_EQUAL_TO, or LESS_THAN_OR_EQUAL_TO.

The applies_to field can contain an array of company user role IDs. When an empty array is provided, the rule is applied to all user roles in the system, including those created in the future.

The default value of the status field is ENABLED.

Syntax

mutation {
    createPurchaseOrderApprovalRule(
        input: PurchaseOrderApprovalRuleInput!
    ) {
        PurchaseOrderApprovalRule
    }
}

Reference

The createPurchaseOrderApprovalRule reference provides detailed information about the types and fields defined in this mutation.

Headers

A valid customer authentication token is required.

Example usage

The following example creates a purchase order approval rule.

Request:

mutation {
  createPurchaseOrderApprovalRule(
    input: {
        name: "Rule name",
        description: "Rule description",
        applies_to: [],
        status: ENABLED,
        condition: {
            attribute: GRAND_TOTAL,
            operator: MORE_THAN,
            amount: {
                value: 100.00,
                currency: EUR
            }
        },
        approvers: ["MQ=="]
    }
  ) {
    name
    uid
    applies_to_roles
    condition
  }
}

Response:

{
  "data": {
    "createPurchaseOrderApprovalRule": {
      "name": "Rule name",
      "uid": "MTA=",
      "applies_to_roles": [],
      "condition": {
        "attribute": "GRAND_TOTAL",
        "operator": "MORE_THAN"
      }
    }
  }
}