Constructing a Rule

A rule has two main parts: conditions and a fee. When Calculate Service Fees is called, it assesses each rule in relation to the specified order. When a rule is assessed, if the conditions are met, the fee is included in the API's response.

Conditions

Conditions can be either a single condition or a condition tree.

A single condition evaluates a specific field in the order. For example, it could check if the value of the field is greater than a certain number.

A condition tree contains two conditions and an operator. The conditions can each be either a single condition or a condition tree. There are two operator values:

  • "AND": Both conditions must be met for the condition tree to be considered met.
  • "OR": At least one of the conditions must be met for the condition tree to be considered met.

Condition tree example

Conditions

For the service fee to be applied, we would need to satisfy these conditions:

  • The price subtotal is greater than 50
    AND
  • Either:
    • Delivery type is "DELIVERY"
      OR
    • Order is made in the mobile app

Example: Conditions are met

We have the following values:

  • Subtotal is 70
  • Delivery type is "DELIVERY"
  • Order is "WEBSITE"

In this case, the conditions are met, because the subtotal is greater than 50 and the delivery type is "DELIVERY". It doesn't matter that the platform isn't "MOBILE_APP" because we only need that OR delivery type to be "DELIVERY".

Example: Conditions are not met

We have the following values:

  • Subtotal is 30
  • Delivery type is "DELIVERY"
  • Order is "MOBILE_APP"

In this case, the conditions are not met, because even though the delivery type is "DELIVERY" and the platform is "MOBILE_APP", the subtotal is not greater than 50.

Fee

A fee is either a fixed amount or a percentage of the order's subtotal. It can also include tax.

If the conditions are met, the fee is calculated and applied when Calculate Service Fees is called.

Was this helpful?
Yes
No

Service Fees: Supported Filters and Sorting

The following table shows field support for filters and sorting for the rules object:

FieldSupported FiltersSortable
id$eq, $ne, $lt, $lte, $gt, $gte, $in, $hasSome, $hasAll, $startsWith, $containsSortable

Related content: API Query Language, Query Rules

Was this helpful?
Yes
No

Rule Object

A rule defines the fee that is applied when specific conditions (also defined by the rule) are met. You can use a rule to apply a service fee to a restaurant order.

Properties
idstringRead-only
Rule ID.

locationIdstringformat GUID
ID of the restaurant’s location.

namestringmaxLength 50minLength 1
Rule name.

createdDatestringRead-onlyformat date-time
Date and time the rule was created.

updatedDatestringRead-onlyformat date-time
Date and time the rule was updated.

taxRatestringdeprecated - use taxes insteaddecimalValue {"maxScale":2,"gte":"0","lte":"100"}
Percentage value to apply as a custom tax rate. For example, 5 respresents a 5% fee applied to the order's total. Min: '0'. Max: 100.

conditionsTypestringdeprecated - use conditionType instead
3 enum supported values:
NO_CONDITIONSCONDITIONCONDITION_TREE
Specifies the type of condition.

conditionTypestring
3 enum supported values:
UNDEFINED_CONDITION_TYPECONDITIONCONDITION_TREE
Specifies the type of condition.

enabledboolean
Whether the rule is enabled. If true, the rule is evaluated when service fees are calculated. If false, the rule will not be evaluated when service fees are calculated.

revisionintegerRead-onlyformat uint64
Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing revision must be used when updating a rule.

labelstringdeprecated - use appId insteadmaxLength 100minLength 1
DEPRECATED. Defines the app that the rule is connected to.

appIdstringformat GUID
Defines the app that the rule is connected to.

roundingStrategystring
3 enum supported values:
UNKNOWN_ROUNDING_STRATEGYHALF_UPHALF_EVEN
Rounding strategy to apply to fee and tax calculation.
  • HALF_UP rounds up any number exactly halfway between two integers. For example, 2.5 rounds to 3, and 3.5 and rounds to 4.
  • HALF_EVEN rounds such numbers to the nearest even integer. For example, 2.5 rounds to 2, but 3.5 rounds to 4.

ONE OF:


amountobjectdeprecated - use fixedFee instead
Fixed fee. Must hold a positive value.

percentagestringdeprecated - use percentageFee insteaddecimalValue {"maxScale":2,"gte":"0","lte":"100"}
Percentage fee. For example, 5 respresents a 5% fee applied to the order's total.

ONE OF:


fixedFeeobject
Fixed fee. Must hold a positive value.

percentageFeestringdecimalValue {"maxScale":2,"gte":"0","lte":"100"}
Percentage fee. For example, 5 respresents a 5% fee applied to the order's total.

ONE OF:


conditionobjectdeprecated - use conditionOptions instead
Single condition that must be met for the rule to be applied to an order.

conditionTreeobjectdeprecated - use conditionTreeOptions instead
Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.

ONE OF:


conditionOptionsobject
Single condition that must be met for the rule to be applied to an order.

conditionTreeOptionsobject
Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.

ONE OF:


customTaxRatestring
Percentage value to apply as a custom tax rate. Range: [0-100].

taxGroupIdstringformat GUID
Tax group ID. Internal only.
Was this helpful?
Yes
No

PostCalculate Service Fees

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Calculates service fees for an order.

The specified order information is evaluated against all rules created for the site. If the rule conditions are met, the service fee set in the rule is applied. Otherwise, no service fee is added.

Endpoint
POST
https://www.wixapis.com/service-fees/v1/calculate

Was this helpful?
Yes
No

GetList Rules

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves an array of all rules.

You can filter by location or app that the rules are associated with.

Endpoint
GET
https://www.wixapis.com/service-fees/v1/rules

Was this helpful?
Yes
No

PostCreate Rule

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a rule.

To create multiple rules at once, use Bulk Create Rules.

Read more about constructing a rule.

Endpoint
POST
https://www.wixapis.com/service-fees/v1/rules

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

GetGet Rule

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a rule.

Endpoint
GET
https://www.wixapis.com/service-fees/v1/rules/{ruleId}

Was this helpful?
Yes
No

DeleteDelete Rule

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes a rule.

To delete mutiple rules at once, use Bulk Delete Rules.

Endpoint
DELETE
https://www.wixapis.com/service-fees/v1/rules/{ruleId}

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

PatchUpdate Rule

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates a rule.

Each time the task is updated, revision increments by 1. The existing revision must be included when updating the task. This ensures you're working with the latest task and prevents unintended overwrites.

To update multiple rules at once, use Bulk Update Rules.

Endpoint
PATCH
https://www.wixapis.com/service-fees/v1/rules/{rule.id}

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

PostQuery Rules

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a list of rules, given the provided paging, filtering, and sorting.

For field support for filters and sorting, see Service Fees: Supported Filters and Sorting.

Query Rules runs with these defaults, which you can override:

  • cursorPaging.limit is 50

To learn about working with Query endpoints, see API Query Language, Sorting and Paging, and Field Projection.

Endpoint
POST
https://www.wixapis.com/service-fees/v1/rules/query

Was this helpful?
Yes
No

PostBulk Create Rules

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Bulk creates rules.

To create only one rule, use Create Rule.

Read more about constructing a rule.

Endpoint
POST
https://www.wixapis.com/service-fees/v1/bulk/rules/create

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

PatchBulk Update Rules

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Bulk updates rules.

Each time the task is updated, revision increments by 1. The existing revision must be included when updating the task. This ensures you're working with the latest task and prevents unintended overwrites.

To update a single rule, use Update Rule.

Endpoint
PATCH
https://www.wixapis.com/service-fees/v1/bulk/rules/update

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

DeleteBulk Delete Rules

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Bulk deletes rules.

To delete a single rule, use Delete Rule.

Endpoint
DELETE
https://www.wixapis.com/service-fees/v1/bulk/rules/delete

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

Rule Created

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.service.fees.v1.rule.

slugstring
Event name. Expected created.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

createdEventobject
Event information.
Was this helpful?
Yes
No

Rule Updated

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.service.fees.v1.rule.

slugstring
Event name. Expected updated.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

updatedEventobject
Event information.
Was this helpful?
Yes
No

Rule Deleted

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.service.fees.v1.rule.

slugstring
Event name. Expected deleted.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

deletedEventstruct
Event information.
Was this helpful?
Yes
No