Skip to content

REST API Reference

The ShipRules AI REST API lets you manage your shipping configuration programmatically. All endpoints return JSON and require an API key in the Authorization header.

Base URL: https://shiprules.ai/api

All request bodies use Content-Type: application/json. Prices are always in cents. Weights are in grams.

GET /api/zones

Returns all zones for your shop, including subzones.

Response:

{
"zones": [
{
"id": "zone_abc123",
"name": "United States",
"countries": ["US"],
"subzones": [
{
"id": "sub_xyz789",
"name": "Alaska & Hawaii",
"postalCodes": "99*,96*"
}
]
}
]
}
GET /api/groups
POST /api/groups
{
"name": "Heavy Items",
"isDefault": false
}
PUT /api/groups
DELETE /api/groups
GET /api/methods

Query parameters:

  • zoneId — filter by zone
  • productGroupId — filter by product group
GET /api/methods/:id

Returns the method with its rate configuration and rules.

POST /api/methods
{
"name": "Standard Shipping",
"subtitle": "5-7 business days",
"zoneId": "zone_abc123",
"productGroupId": "group_def456",
"rateType": "flat",
"config": { "price": 999 },
"enabled": true,
"freeShippingThreshold": 10000
}

Rate type configurations:

{
"rateType": "flat",
"config": { "price": 999 }
}
PUT /api/methods
DELETE /api/methods
GET /api/rules?methodId=:methodId
POST /api/rules
{
"action": "hide",
"conditions": [
{
"conditionType": "destination_state",
"operator": "equals",
"value": "AK,HI",
"scope": "any_product_in_order"
}
]
}

Available actions: hide, show, free, adjust_add, adjust_subtract

For adjustment actions, also include:

{
"action": "adjust_add",
"adjustmentValue": 500,
"adjustmentType": "flat",
"conditions": [...]
}
PUT /api/rules
DELETE /api/rules
GET /api/blended
POST /api/blended
{
"name": "Combined Shipping",
"subtitle": "Calculated from all product groups",
"zoneId": "zone_abc123",
"freeShippingThreshold": 20000,
"preferences": [
{ "productGroupId": "group_default", "preferredMethodId": "method_std" },
{ "productGroupId": "group_heavy", "preferredMethodId": null }
]
}

When preferredMethodId is null, the lowest available rate for that group is used.

PUT /api/blended
DELETE /api/blended
GET /api/versions?limit=20&cursor=version_abc123

Query parameters:

  • limit — number of versions to return (default: 20)
  • cursor — pagination cursor (version ID)
  • includeBatched — if true, show individual batch versions instead of collapsing them
GET /api/versions/:id
POST /api/versions
{
"action": "compare",
"versionA": "version_abc",
"versionB": "version_xyz"
}

Returns { added: [...], modified: [...], removed: [...] }.

POST /api/versions
{
"action": "rollback",
"targetVersionId": "version_abc123"
}

Restores the configuration to the state at this version. Creates a new version with createdBy “rollback”.

POST /api/staging
{ "action": "enter" }
GET /api/staging

Returns shadow comparison results from the active staging changeset.

POST /api/staging
{ "action": "promote" }
POST /api/staging
{ "action": "discard" }
GET /api/config

Returns the full shop configuration as a JSON snapshot.

POST /api/config
{
"action": "preview",
"data": { "productGroups": [...], "zones": [...], "methods": [...], "blendedRates": [...] }
}

Returns a preview of what would change without applying.

POST /api/config
{
"action": "execute",
"data": { "productGroups": [...], "zones": [...], "methods": [...], "blendedRates": [...] }
}

Replaces the current configuration. A version record is created automatically.

POST /api/simulate

See Rate Simulation for full details on the simulation endpoint.

All errors follow this format:

{
"error": {
"code": "NOT_FOUND",
"message": "Shipping method method_abc123 not found"
}
}
StatusCodeMeaning
400VALIDATION_ERRORInvalid request body or parameters
401UNAUTHORIZEDMissing or invalid API key
403FORBIDDENInsufficient permissions
404NOT_FOUNDResource not found
409CONFLICTConflict (e.g., trying to enter staging when already in staging)
422PLAN_LIMIT_EXCEEDEDOperation exceeds your plan’s limits
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORSomething went wrong on our end