Spree Admin SDK
import { createAdminClient } from '@spree/admin-sdk'
const client = createAdminClient({
baseUrl: 'https://your-store.com',
secretKey: 'sk_xxx',
})
const { data: ruleTypes } = await client.promotionRules.types()spree api get /promotion_rules/types{
"data": [
{
"type": "category",
"label": "Categories",
"description": "Order includes products in specified categories",
"schema": {
"type": "object",
"properties": {
"match_policy": {
"type": "string",
"enum": [
"any",
"all"
],
"default": "any"
}
},
"additionalProperties": false
}
},
{
"type": "channel",
"label": "Channel(s)",
"description": "Limit to orders placed through specified channel(s)",
"schema": {
"type": "object",
"properties": {
"channel_ids": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^ch_[A-Za-z0-9]+$",
"x-spree-prefix": "ch"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "country",
"label": "Country",
"description": "Limit to orders with shipping address in a specific country",
"schema": {
"type": "object",
"properties": {
"country_codes": {
"type": "array",
"items": {
"type": "string",
"format": "iso-country",
"pattern": "^[A-Z]{2}$"
},
"default": []
},
"country_id": {
"type": [
"integer",
"null"
]
},
"country_code": {
"type": [
"string",
"null"
],
"format": "iso-country",
"pattern": "^[A-Z]{2}$"
}
},
"additionalProperties": false
}
},
{
"type": "currency",
"label": "Currency",
"description": "Limit to orders in a specific currency",
"schema": {
"type": "object",
"properties": {
"currency": {
"type": [
"string",
"null"
],
"format": "currency",
"pattern": "^[A-Z]{3}$"
}
},
"additionalProperties": false
}
},
{
"type": "customer_group",
"label": "Customer Group(s)",
"description": "Available only to customers in specified customer group(s)",
"schema": {
"type": "object",
"properties": {
"customer_group_ids": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^cg_[A-Za-z0-9]+$",
"x-spree-prefix": "cg"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "customer",
"label": "Customers",
"description": "Available only to the specified customers",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "first_order",
"label": "First order",
"description": "Must be the customer's first order",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "item_total",
"label": "Item total",
"description": "Order total meets these criteria",
"schema": {
"type": "object",
"properties": {
"amount_min": {
"type": "string",
"format": "money",
"pattern": "^-?\\d+(\\.\\d+)?$",
"default": "100"
},
"operator_min": {
"type": "string",
"default": ">"
},
"amount_max": {
"type": [
"string",
"null"
],
"format": "money",
"pattern": "^-?\\d+(\\.\\d+)?$"
},
"operator_max": {
"type": "string",
"default": "<"
}
},
"additionalProperties": false
}
},
{
"type": "market",
"label": "Market(s)",
"description": "Limit to orders placed in specified market(s)",
"schema": {
"type": "object",
"properties": {
"market_ids": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^mkt_[A-Za-z0-9]+$",
"x-spree-prefix": "mkt"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "one_use_per_user",
"label": "One Use Per User",
"description": "Only One Use Per User",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "customer_logged_in",
"label": "Only logged in customers",
"description": "Available only to logged in customers",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "option_value",
"label": "Option Value(s)",
"description": "Order includes products with matching option value(s)",
"schema": {
"type": "object",
"properties": {
"match_policy": {
"type": "string",
"enum": [
"any"
],
"default": "any"
},
"eligible_values": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^optval_[A-Za-z0-9]+$",
"x-spree-prefix": "optval"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "product",
"label": "Product(s)",
"description": "Order includes specified product(s)",
"schema": {
"type": "object",
"properties": {
"match_policy": {
"type": "string",
"enum": [
"any",
"all",
"none"
],
"default": "any"
}
},
"additionalProperties": false
}
}
]
}List available promotion rule types
Returns the registered Spree::PromotionRule subclasses with their preference schemas.
Required scope: read_promotions (for API-key authentication).
GET
/
api
/
v3
/
admin
/
promotion_rules
/
types
Spree Admin SDK
import { createAdminClient } from '@spree/admin-sdk'
const client = createAdminClient({
baseUrl: 'https://your-store.com',
secretKey: 'sk_xxx',
})
const { data: ruleTypes } = await client.promotionRules.types()spree api get /promotion_rules/types{
"data": [
{
"type": "category",
"label": "Categories",
"description": "Order includes products in specified categories",
"schema": {
"type": "object",
"properties": {
"match_policy": {
"type": "string",
"enum": [
"any",
"all"
],
"default": "any"
}
},
"additionalProperties": false
}
},
{
"type": "channel",
"label": "Channel(s)",
"description": "Limit to orders placed through specified channel(s)",
"schema": {
"type": "object",
"properties": {
"channel_ids": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^ch_[A-Za-z0-9]+$",
"x-spree-prefix": "ch"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "country",
"label": "Country",
"description": "Limit to orders with shipping address in a specific country",
"schema": {
"type": "object",
"properties": {
"country_codes": {
"type": "array",
"items": {
"type": "string",
"format": "iso-country",
"pattern": "^[A-Z]{2}$"
},
"default": []
},
"country_id": {
"type": [
"integer",
"null"
]
},
"country_code": {
"type": [
"string",
"null"
],
"format": "iso-country",
"pattern": "^[A-Z]{2}$"
}
},
"additionalProperties": false
}
},
{
"type": "currency",
"label": "Currency",
"description": "Limit to orders in a specific currency",
"schema": {
"type": "object",
"properties": {
"currency": {
"type": [
"string",
"null"
],
"format": "currency",
"pattern": "^[A-Z]{3}$"
}
},
"additionalProperties": false
}
},
{
"type": "customer_group",
"label": "Customer Group(s)",
"description": "Available only to customers in specified customer group(s)",
"schema": {
"type": "object",
"properties": {
"customer_group_ids": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^cg_[A-Za-z0-9]+$",
"x-spree-prefix": "cg"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "customer",
"label": "Customers",
"description": "Available only to the specified customers",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "first_order",
"label": "First order",
"description": "Must be the customer's first order",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "item_total",
"label": "Item total",
"description": "Order total meets these criteria",
"schema": {
"type": "object",
"properties": {
"amount_min": {
"type": "string",
"format": "money",
"pattern": "^-?\\d+(\\.\\d+)?$",
"default": "100"
},
"operator_min": {
"type": "string",
"default": ">"
},
"amount_max": {
"type": [
"string",
"null"
],
"format": "money",
"pattern": "^-?\\d+(\\.\\d+)?$"
},
"operator_max": {
"type": "string",
"default": "<"
}
},
"additionalProperties": false
}
},
{
"type": "market",
"label": "Market(s)",
"description": "Limit to orders placed in specified market(s)",
"schema": {
"type": "object",
"properties": {
"market_ids": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^mkt_[A-Za-z0-9]+$",
"x-spree-prefix": "mkt"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "one_use_per_user",
"label": "One Use Per User",
"description": "Only One Use Per User",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "customer_logged_in",
"label": "Only logged in customers",
"description": "Available only to logged in customers",
"schema": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
{
"type": "option_value",
"label": "Option Value(s)",
"description": "Order includes products with matching option value(s)",
"schema": {
"type": "object",
"properties": {
"match_policy": {
"type": "string",
"enum": [
"any"
],
"default": "any"
},
"eligible_values": {
"type": "array",
"items": {
"type": "string",
"format": "prefixed-id",
"pattern": "^optval_[A-Za-z0-9]+$",
"x-spree-prefix": "optval"
},
"default": []
}
},
"additionalProperties": false
}
},
{
"type": "product",
"label": "Product(s)",
"description": "Order includes specified product(s)",
"schema": {
"type": "object",
"properties": {
"match_policy": {
"type": "string",
"enum": [
"any",
"all",
"none"
],
"default": "any"
}
},
"additionalProperties": false
}
}
]
}Was this page helpful?
⌘I

