Wocart
Wocart API

Shipping Profiles

Server

List shipping profiles

GET
https://api.wocart.store
/api/shipping-profiles
X-API-Key (header)

Returns all shipping rate profiles with ruleCount (number of wilaya rules) and productCount (how many products override the store default with this profile).

List shipping profiles › Responses

200

List of shipping profiles

success
​boolean · required
​ShippingProfile[] · required
count
​integer · required

Number of items returned


Create shipping profile

POST
https://api.wocart.store
/api/shipping-profiles
X-API-Key (header)

Creates a profile (rate-card metadata only). Use PUT /{id}/rules afterwards to populate wilaya rates. Setting isDefault: true atomically unsets the current default profile.

Create shipping profile › Request Body

name
​string · minLength: 1 · required
isDefault
​boolean
Default: false
notes
​string | null

Create shipping profile › Responses

Profile created

success
​boolean · required
​ShippingProfileWithRules · required

Shipping profile with its full list of wilaya rules


Get default-profile rules

GET
https://api.wocart.store
/api/shipping-profiles/default/rules
X-API-Key (header)

Returns the wilaya rules of the currently-active default profile. Used by the order form to auto-fill deliveryFee. Returns an empty array if no profile is marked default.

Get default-profile rules › Responses

200

Default profile rules (empty array if no default configured)

success
​boolean · required
​ShippingRule[] · required

Get shipping profile

GET
https://api.wocart.store
/api/shipping-profiles/{id}
X-API-Key (header)

Returns a single profile with its full list of wilaya rules (including homeEnabled / stopDeskEnabled).

Get shipping profile › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

Get shipping profile › Responses

200

Profile with rules

success
​boolean · required
​ShippingProfileWithRules · required

Shipping profile with its full list of wilaya rules


Update shipping profile

PATCH
https://api.wocart.store
/api/shipping-profiles/{id}
X-API-Key (header)

Partial update of profile metadata. Include only the fields you want to change. Set notes to null to clear it.

Default invariant: the system always keeps exactly one profile marked isDefault. Setting isDefault: true here atomically unsets the current default. Setting isDefault: false on the only default profile is rejected with 422 DEFAULT_PROFILE_REQUIRED.

Update shipping profile › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

Update shipping profile › Request Body

name
​string · minLength: 1
isDefault
​boolean
notes
​string | null

Update shipping profile › Responses

Profile updated

success
​boolean · required
​ShippingProfileWithRules · required

Shipping profile with its full list of wilaya rules


Delete shipping profile

DELETE
https://api.wocart.store
/api/shipping-profiles/{id}
X-API-Key (header)

Permanently deletes a profile and all of its wilaya rules (commune overrides cascade).

Blocked when:

  • The profile is currently referenced by one or more products → 422 PROFILE_IN_USE
  • The profile is the default profile → 422 DEFAULT_PROFILE_REQUIRED (set another profile as default first)

Delete shipping profile › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

Delete shipping profile › Responses

Profile deleted

success
​boolean · required

Replace wilaya rules

PUT
https://api.wocart.store
/api/shipping-profiles/{id}/rules
X-API-Key (header)

Atomically replaces the full rules list for a profile — prior rules are deleted (commune overrides cascade) before new ones are inserted.

Constraints:

  • Each wilayaId may appear at most once per profile. Duplicates are rejected with DUPLICATE_WILAYA_RULE.
  • Setting both homeEnabled: false and stopDeskEnabled: false on a wilaya effectively disables delivery for that wilaya under this profile.
  • Sending an empty rules array clears all rules for the profile.

Replace wilaya rules › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

Replace wilaya rules › Request Body

​object[] · required

Replace wilaya rules › Responses

Rules replaced — returns the profile with its new rules

success
​boolean · required
​ShippingProfileWithRules · required

Shipping profile with its full list of wilaya rules


List commune overrides

GET
https://api.wocart.store
/api/shipping-profiles/{id}/rules/{wilayaId}/communes
X-API-Key (header)

Returns every commune in a wilaya with its override status. For each commune the response includes:

  • Raw override fields (homeEnabled, stopDeskEnabled, homePrice, stopDeskPrice) — null means that field inherits from the wilaya rule.
  • Effective values (effectiveHome*, effectiveStopDesk*) — the actual values used during fee resolution (commune override merged onto the wilaya defaults).
  • hasOverride — true if any override row exists for this commune.

Requires that the profile already has a rule for the given wilaya — otherwise responds 404 SHIPPING_RULE_NOT_FOUND.

List commune overrides › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

wilayaId
​integer · min: 1 · max: 58 · required

Wilaya ID (1–58)

Wilaya ID (1–58)

List commune overrides › Responses

200

All communes in this wilaya with override status

success
​boolean · required
​CommuneOverride[] · required

Set or update commune override

PUT
https://api.wocart.store
/api/shipping-profiles/{id}/rules/{wilayaId}/communes/{communeId}
X-API-Key (header)

Upserts a commune-level override on top of the wilaya rule.

Semantics:

  • Any field set to null (or omitted — which is treated as null) inherits from the wilaya rule at fee-resolution time.
  • If all four override fields (homeEnabled, stopDeskEnabled, homePrice, stopDeskPrice) are null, the override row is deleted (equivalent to DELETE).
  • Prices must be ≥ 0 when provided.

Effects on orders: subsequent online orders with this wilaya + commune pair will use the overridden values. Disabling homeEnabled or stopDeskEnabled causes 422 DELIVERY_NOT_AVAILABLE at order creation for that mode.

Set or update commune override › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

wilayaId
​integer · min: 1 · max: 58 · required

Wilaya ID (1–58)

Wilaya ID (1–58)

communeId
​string · required

Commune ID

Commune ID

Set or update commune override › Request Body

homeEnabled
​boolean | null
stopDeskEnabled
​boolean | null
homePrice
​number | null · min: 0
stopDeskPrice
​number | null · min: 0

Set or update commune override › Responses

200

Override upserted (or removed if all fields null)

success
​boolean · required

Remove commune override

DELETE
https://api.wocart.store
/api/shipping-profiles/{id}/rules/{wilayaId}/communes/{communeId}
X-API-Key (header)

Removes the commune override row — the commune will again inherit the wilaya rule. Returns 404 COMMUNE_OVERRIDE_NOT_FOUND if no override row exists for this commune.

Remove commune override › path Parameters

id
​string · required

Shipping profile ID

Shipping profile ID

wilayaId
​integer · min: 1 · max: 58 · required

Wilaya ID (1–58)

Wilaya ID (1–58)

communeId
​string · required

Commune ID

Commune ID

Remove commune override › Responses

200

Override removed — commune reverts to wilaya defaults

success
​boolean · required