# Shipping Rule API Reference

Shipping rule object:

{
	"type": "shipping_rules",
	"id": "(string)",
	"attributes": {
		"title": "string",
		"description": "string",
		"rate": Float,
		"rules": Array,
		"created_at": "string|datetime",
		"updated_at": "string|datetime"
	},
	"relationships": {
		"shipping_zone": {
			"data": Object [Shipping Zone Resource]
		}
	}
}

Related resources: Shipping Zone, Shipping

# Writable fields

Field name Creating Updating
title required|string|max:255 string|min:1|max:255
description string|min:1|max:255 string|min:1|max:255
rate float|>=0 float|>=0
rules array array

# Writable relationships

Relationship name Relationship resource type Type Creating Updating
shipping_zone shipping_zones To-one Yes - Required No

# Rules format

"rules" attribute must be an array of mutiple rule array. Rule array is an array of 3 elements: First element is condition field, second element is operator, last element is your value.

Example of rules data:

[
	["weight", ">", 999],
	["price", "<", 99.99],
	["product_title", "CONTAINS", "example string"],
	["product_ids", "IN", ["...", "..."]]
]

Available condition fields:

Field Supported operators Value
weight >, <, >=, <=, = float
price >, <, >=, <=, = float
quantity >, <, >=, <=, = integer
collection_ids IN, NOT_IN array
product_ids IN,NOT_IN array
variant_ids IN,NOT_IN array
product_title CONTAINS,DOES_NOT_CONTAIN string
product_description CONTAINS,DOES_NOT_CONTAIN string
  • Important: collection_ids wont work with query collections.