Xuda logo Xuda Docs User Guides
/
xuda.io
← All guides Shipping

Xuda Shipping API Reference

Source file: xuda-shipping-api-reference.md

Xuda Shipping API Reference

This reference covers the full method surface of Xuda Shipping: quoting carriers and local couriers, drafting and booking a delivery, tracking and cancelling it, managing pickup locations, funding and auditing the prepaid shipping wallet, and choosing a plan. It is written for developers integrating against the shipping engine or working on a Xuda surface that calls it, and for anyone who needs to know exactly what each method does before relying on it. Every method key, parameter name, type and required flag below is taken from the shipped method contract.

How To Call These Methods

Every method here is a CPI method. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.

Read this before you write a line of code. None of the 24 Shipping methods is exposed in the API-key catalog. All 24 are registered private, and in this platform private is the hard operator wall on the external, API-key authenticated surface: the API module refuses a private method even for a key whose api_access is full. So there is no externally exposed Shipping REST API today, and the shipping_api_* family described in the product plan does not exist in code. What that leaves is:

  • Nineteen methods with user clearance that require a signed-in dashboard or first-party session, with the caller identity injected from that session. These are the customer-facing surface, they are what every Shipping screen calls, and they are documented in full below because they define the product's behavior and because any future API tier would expose them.
  • Five methods with admin clearance that additionally perform an explicit superuser check in code, because admin clearance is not by itself superuser in this platform. They are listed for completeness and are not part of the customer-facing surface.

Do not build against the nineteen session methods with an API key. They will be refused.

All methods return the platform envelope { code, data }, where code: 1 is success and a negative code is a failure carrying a message or a structured reason in data. No Shipping method carries a min_plan key, so the platform's plan gate never fires for this product. Every plan rule described below is enforced inside the module itself.

Wherever an owner_uid parameter appears it defaults to the calling account, and naming another account requires superuser membership.

What The Availability Labels Mean

Every method below carries one explicit availability line. Read it first, because it tells you whether you can call the method from your own code today.

  • Availability: API key means an external developer API key or the MCP layer can call it. No Shipping method currently carries this label.
  • Availability: Dashboard session means a signed-in user in the Xuda dashboard, or another first-party Xuda surface, can call it, and an API key cannot. The account identity comes from the session, never from a parameter.
  • Availability: Public endpoint means no authentication at all. No Shipping method currently carries this label.
  • Availability: Operator only means Xuda staff. The method carries admin clearance and checks superuser membership in code as well.

Method Index

Method What It Does
shipping_get_account Reads the plan, plan flags, wallet, auto top-up and this month's usage in one call.
shipping_get_wallet Reads the wallet balance plus a page of the append-only ledger, newest first.
shipping_topup_wallet Charges a saved card and credits the shipping wallet.
shipping_set_auto_topup Arms or disarms automatic top-up with a low-water mark, an amount and a daily cap.
shipping_wallet_audit Re-derives the balance from the ledger and reports drift, repairing only on request.
shipping_set_plan Switches the account to a Shipping tier on the consolidated subscription.
shipping_create_location Adds a ship-from location and registers it with any vendor that needs one.
shipping_list_locations Lists the account's pickup locations, default first.
shipping_update_location Updates a pickup location and re-registers it when the address changes.
shipping_delete_location Removes a pickup location, archiving it instead when deliveries are in flight.
shipping_quote Returns one cheapest-first list of priced offers across every eligible vendor and both service modes.
shipping_create_delivery Creates a draft delivery. Nothing is booked and no money moves.
shipping_book_delivery Books a draft against a quoted offer, reserving the wallet before calling the vendor.
shipping_cancel_delivery Cancels a booked delivery with the vendor and records the cancellation.
shipping_get_delivery Reads one delivery in full, including label, tracking or courier and handover PIN.
shipping_list_deliveries Lists deliveries newest first, filterable by mode, status or order reference.
shipping_list_vendors Lists the vendors registered on this host with their coverage and features.
shipping_check_route Answers whether any vendor can serve a route, without producing a quote.
shipping_get_rate_card Reads the pricing rules applied to a tenant's quotes.
shipping_set_rate_card Operator: sets a tenant's pricing mode and markup settings.
shipping_price_preview Operator: shows how a vendor cost prices out under a tenant's rate card.
shipping_wallet_adjust Operator: posts a manual credit or debit to a tenant's ledger.
shipping_run_auto_topup Operator: runs automatic top-up for one tenant, or sweeps armed wallets.
shipping_sync_denied_parties Operator: refreshes the stored denied party name list used by screening.

shipping_get_account

Get Shipping Account

Returns the caller's shipping account in one read: the plan id, the full plan flag set, the wallet currency, balance, auto top-up configuration and entry count, this month's delivery usage against the plan limit, and any stored account settings. Creating the wallet is a side effect of reading, so a first call on a brand new account returns a zero balance rather than an error. Only a superuser may read another tenant.

Availability: Dashboard session

Parameters

Name Type Required Description
owner_uid string No Tenant to read. Defaults to the caller; naming another tenant needs superuser.
currency string No Currency to create the wallet in if it does not exist yet. Defaults to USD.

Notes

  • Auth: clearance: user. No min_plan.
  • This is the read behind the Balance, Plan, Deliveries this month and Automatic top-up tiles on the shipping wallet screen.
  • The stored account settings object is always empty today. The module reads a settings document but nothing writes one.
  • Usage counts deliveries booked, never quotes. Quoting is free and is never metered.

shipping_get_wallet

Get Shipping Wallet

Returns the wallet balance, currency and auto top-up settings together with a page of the append-only ledger, newest first. Each entry carries its id, timestamp, type, signed amount in cents, the balance after that movement, the reference it relates to and a free-text note. This is the read behind the wallet screen's Activity table.

Availability: Dashboard session

Parameters

Name Type Required Description
owner_uid string No Tenant to read. Defaults to the caller; naming another tenant needs superuser.
limit number No Ledger entries to return, max 200. Defaults to 25.
skip number No Ledger entries to skip, for paging.
currency string No Currency to create the wallet in if it does not exist yet. Defaults to USD.

Notes

  • Auth: clearance: user. No min_plan.
  • The ledger is the authoritative money record and it is append-only. No code mutates a balance. The wallet's balance_cents is only a projection of the entries.
  • Thirteen entry types are defined, including topup, hold, hold_release, delivery_purchase, platform_fee and manual_credit.
  • Xuda Commerce calls this method to warn a seller whose shipping wallet is empty before checkout depends on it.

shipping_topup_wallet

Top Up Shipping Wallet

Charges a saved card through Stripe and credits the shipping wallet. Postage is prepaid because a card charge per label would cost more in payment fees than the delivery earns. The credit is posted as a topup ledger entry keyed on the Stripe charge id, so a retried call after a network failure credits once and returns replayed: true. The minimum is $5.00 and the maximum single top-up is $5,000.00.

Availability: Dashboard session

Parameters

Name Type Required Description
amount_cents number Yes Amount to add, minimum $5 and maximum $5,000 per top-up.
card_id string Yes Saved card to charge.

Notes

  • Auth: clearance: user. No min_plan.
  • Idempotency: the ledger entry id is derived from the Stripe charge id, so a replay collides in the database and returns the original entry rather than crediting twice. The response carries replayed: true in that case.
  • The account needs a saved card already on file. There is no card capture in this method.
  • The dashboard offers $25, $50, $100 and $250 presets, but any amount inside the minimum and maximum is accepted.

shipping_set_auto_topup

Set Wallet Auto Top-up

Configures automatic wallet top-up. Enabling it requires an amount, a card and a daily cap, and the cap must be at least the top-up amount, so a looping integration cannot drain a card and enabling it can never be a silent no-op. Re-arming clears the previous decline. Auto top-up is evaluated inline after each booking and by the sweep method, and it disarms itself if the card declines.

Availability: Dashboard session

Parameters

Name Type Required Description
enabled boolean Yes Turn automatic top-up on or off.
low_water_cents number No Balance at or below which a top-up is triggered.
amount_cents number No Amount to add per top-up. Required when enabling, and must be at least the $5 minimum.
daily_cap_cents number No Maximum total top-up in 24 hours. Required when enabling, and must be at least amount_cents.
card_id string No Saved card to charge. Required when enabling unless one is already stored. Present in code but not declared in the config field list.

Notes

  • Auth: clearance: user. No min_plan.
  • The daily cap is measured against the last 24 hours of real ledger entries rather than against a counter, so it survives a restart and cannot be reset by retrying.
  • A declined card disarms the feature and records the error on the wallet, instead of retrying on every subsequent booking. Re-arming clears that stored decline.
  • Automatic top-up is evaluated inline after each successful booking. Nothing calls the sweep on a schedule today.

shipping_wallet_audit

Audit Shipping Wallet

Re-derives the wallet balance from every ledger entry, in 500-entry pages, and compares it to the stored projection. Returns the projected total, the derived total, the drift in cents, the entry count and whether a repair was applied. It reports by default and never corrects silently; a superuser may pass repair to rewrite the projection from the derived total.

Availability: Dashboard session

Parameters

Name Type Required Description
owner_uid string No Tenant to audit. Defaults to the caller; naming another tenant needs superuser.
repair boolean No Superuser only: rewrite the projection from the derived total instead of only reporting.

Notes

  • Auth: clearance: user. The repair path is superuser only. No min_plan.
  • A silent auto-repair would hide the bug that caused the divergence, which is why reporting is the default and repairing is an explicit act.
  • There is no dedicated screen for this method in the product. It is a method-only surface.
  • Nothing runs this on a schedule today. It is manual.

shipping_set_plan

Set Shipping Plan

Switches the account to a Xuda Shipping plan and adds it to the consolidated Stripe subscription as a line item rather than a separate checkout. It refuses a downgrade that would strand more pickup locations than the lower tier includes, naming how many to remove first. A downgrade that Stripe schedules for the end of the paid period returns scheduled: true with the effective date, and the account keeps the higher tier until the subscription webhook moves it.

Availability: Dashboard session

Parameters

Name Type Required Description
plan_id string Yes Plan key, for example shipping_growth. Must be a plan whose category is shipping.

Notes

  • Auth: clearance: user. No min_plan.
  • No Shipping tier can actually be purchased yet. All four tiers carry placeholder Stripe price ids, so a paid tier returns code -402 with "The plan is not billable yet" and the dashboard's tier picker shows a paid tier as "Coming soon".
  • The plan id is written onto the account document along with a change timestamp. Every other module reads the plan from there.
  • A downgrade is refused when the account holds more pickup locations than the lower tier includes, and the refusal states the exact number to remove first.

shipping_create_location

Create Pickup Location

Adds a pickup or ship-from location and registers it with any vendor that requires a per-location record, so the seller does nothing. A parcel address needs country, line1 and city; a local courier address needs latitude and longitude, because a courier network works in a radius around a point rather than by postcode. The plan's pickup location allowance is enforced here. Vendor registration is attempted with an 8 second timeout per vendor and a failure does not block the save.

Availability: Dashboard session

Parameters

Name Type Required Description
name string Yes Label for this location, for example Warehouse or Shop.
address object Yes Address object. Parcel needs country, line1 and city; local needs lat and lng. Accepted keys: name, company, line1, line2, city, state, postal_code, country, phone, email, lat, lng.
contact_phone string No Phone a courier can call on arrival.
is_default boolean No Use this location when none is named. Setting it clears the flag on every other location.
owner_profile_id string No Profile this location belongs to.

Notes

  • Auth: clearance: user. No min_plan.
  • Plan gate: the plan's pickup_locations allowance is enforced on create, and the refusal names the plan and the number it includes. The ladder runs 1, 3, 15 and unlimited.
  • A vendor that does not need a per-location record is skipped, and a vendor whose registration call fails or times out does not block the save. The cached vendor references are stored on the location document.
  • Without latitude and longitude the location is parcel only and no local courier can be quoted from it.

shipping_list_locations

List Pickup Locations

Lists the tenant's pickup locations, default first and then oldest first, returning the full location documents including the cached vendor location reference map and the archived flag. Xuda Commerce calls this to resolve the seller's ship-from address rather than storing a second copy.

Availability: Dashboard session

Parameters

Name Type Required Description
owner_uid string No Tenant to read. Defaults to the caller; naming another tenant needs superuser.

Notes

  • Auth: clearance: user. No min_plan.
  • Archived locations are returned with the archived flag set. They are kept so an in-flight delivery's origin address never resolves to nothing.

shipping_update_location

Update Pickup Location

Updates a pickup location. Changing the address clears the cached vendor location records so the location is re-registered rather than a delivery shipping from the old address. Setting this location as the default clears the flag on the others.

Availability: Dashboard session

Parameters

Name Type Required Description
location_id string Yes Location to update.
name string No New label.
address object No New address object. Supplying it clears the cached vendor location records.
contact_phone string No New contact phone.
is_default boolean No Make this the default location.

Notes

  • Auth: clearance: user, and the caller must own the location unless superuser. No min_plan.
  • Adding latitude and longitude to a parcel-only location is what makes it eligible for local courier quotes.

shipping_delete_location

Delete Pickup Location

Removes a pickup location. If the account still has any delivery in the booked state, the location is archived instead of deleted and the response says so, so a live delivery's address never resolves to nothing. Otherwise the document is destroyed.

Availability: Dashboard session

Parameters

Name Type Required Description
location_id string Yes Location to remove.

Notes

  • Auth: clearance: user, and the caller must own the location unless superuser. No min_plan.
  • Whether the location was archived or destroyed is stated in the response. Do not assume deletion.

shipping_quote

Quote Delivery

Returns priced delivery offers across every eligible vendor and both service modes in one cheapest-first list, each behind an opaque token. Screening and eligibility run before any vendor is called: an embargoed destination, a restricted goods description or a denied-party name match blocks the whole request, and the plan's service list filters which modes are quoted at all. Each vendor is called in parallel with a hard 2000 ms timeout and a slow vendor is dropped rather than waited for. Prices returned are retail; the vendor cost is stored on the cached quote but never returned to the customer. Parcel quotes are valid for 15 minutes, local quotes for 3 minutes. When there are no offers the response distinguishes plan_excludes_service, exceeds_service_limits (with the per-vendor reason) and no_coverage (with the blocked origin and destination), because each needs a different answer.

Availability: Dashboard session

Parameters

Name Type Required Description
from object Yes Origin address. Parcel needs country, line1 and city; local needs lat and lng.
to object Yes Destination address. Parcel needs country, line1 and city; local needs lat and lng.
parcels array No Parcel list with weight_g and optional length_cm, width_cm and height_cm. Defaults to a single 500 g parcel.
items array No Goods lines with description, value and quantity. Required for international customs data, and screened for restricted and vague descriptions.
mode string No Limit to one service mode, parcel or local. Omit to quote both together.

Notes

  • Auth: clearance: user. No min_plan.
  • Each offer carries: token, vendor, mode, service, service_label, eta_days, eta_minutes, amount_cents and currency. The wholesale cost and the margin are never in a customer-facing quote response.
  • Plan gate: the plan's services list decides which modes are quoted. A Free tier account quoting a local courier gets reason: plan_excludes_service and no offers.
  • Quotes are free and are never metered. Only deliveries booked count against the monthly quota.
  • Physical limits are enforced at quote time, not at booking. A parcel inside a courier's service area but over its weight, dimension or radius ceiling is refused with a stated reason rather than quoted and then failed later.
  • Screening runs before any vendor call and before any money moves: a six-country embargo list, five families of restricted goods, ten customs descriptions that ICS2 rejects, and a name match against a locally stored denied party list. That last check is a plain lowercase substring match against one public list, with no fuzzy matching and no EU or UN lists. Do not describe it to your own users as sanctions screening.
  • The quote result is cached and the returned tokens resolve against that cache at booking. A parcel quote lives 15 minutes and a local quote 3 minutes; past that, booking answers quote_expired and you must re-quote rather than being silently re-priced.

shipping_create_delivery

Create Delivery

Creates a draft delivery document. Nothing is booked, no vendor is contacted and no money moves until shipping_book_delivery is called with a quoted offer token. Addresses are validated for the chosen service mode before the draft is written, so an obviously incomplete address fails here rather than as a confusing vendor error later. The returned delivery_id is what Xuda Commerce stores on a paid order.

Availability: Dashboard session

Parameters

Name Type Required Description
from object Yes Origin address.
to object Yes Destination address.
service_mode string No parcel or local. Defaults to parcel.
parcels array No Parcel list with weight_g and optional dimensions. Defaults to a single 500 g parcel.
items array No Goods lines with description, value and quantity.
order_ref string No Opaque reference owned by the caller. Stored, indexed and returned, never parsed.
owner_profile_id string No Profile this delivery belongs to.

Notes

  • Auth: clearance: user. No min_plan.
  • A draft costs nothing and is not metered. Only booking is.
  • order_ref is the join key back to your own system. Xuda Commerce passes the paid order id here, and shipping_list_deliveries can filter on it.

shipping_book_delivery

Book Delivery

Books a draft delivery against a quoted offer, in a fixed order that is the point of the method. It re-resolves the offer token against the cached quote (an expired quote is refused with quote_expired, never silently re-priced), screens the recipient again, checks the plan quota and computes the platform fee, reserves the retail amount plus the fee on the wallet, and only then calls the vendor. Insufficient funds fail with code -402 and a required_cents and balance_cents payload before any vendor call. A vendor failure releases the reservation and leaves the delivery bookable. On success the hold is released, a delivery_purchase entry and any platform_fee entry are posted, monthly usage is incremented, the delivery is stamped with the vendor booking reference, tracking or PIN payload and both prices, and automatic top-up is evaluated.

Availability: Dashboard session

Parameters

Name Type Required Description
delivery_id string Yes Draft delivery to book.
quote_id string Yes Quote the offer token came from.
offer_token string Yes Opaque token identifying the chosen offer.

Notes

  • Auth: clearance: user, and the caller must own the delivery and the quote unless superuser. No min_plan.
  • Idempotency: booking an already-booked delivery returns the original result rather than buying a second label. Ledger entries are keyed on a hash of the account and the idempotency key, so a replayed post collides in the database and returns the original entry instead of moving money twice.
  • Insufficient funds return -402 before any vendor is contacted, so you are never charged for a label the carrier did not sell you.
  • Plan gate: the plan's services list is re-checked here, and the monthly deliveries_per_month quota is checked. On a tier whose per-delivery platform fee is zero the quota is a hard stop with a message naming the plan and its allowance. On a tier that charges a fee, the booking proceeds and the fee is posted as a separate platform_fee ledger entry so what Xuda earned and what the vendor charged are never mixed.
  • Two ledger entries can result from one booking: delivery_purchase for the postage and platform_fee for the over-quota fee. The hold that preceded them is released rather than double counted.
  • Automatic top-up is evaluated inline immediately after a successful booking.

shipping_cancel_delivery

Cancel Delivery

Cancels a booked delivery with the vendor and records the cancellation state and any cancellation fee on the delivery. Any refund is credited to the wallet when the vendor confirms it, not when cancellation is requested, and the response says so explicitly, because telling a customer their money is back before it is back is how reconciliation disputes start. Only a delivery in the booked state can be cancelled.

Availability: Dashboard session

Parameters

Name Type Required Description
delivery_id string Yes Delivery to cancel.

Notes

  • Auth: clearance: user, and the caller must own the delivery unless superuser. No min_plan.
  • No wallet credit is posted by this call. Refund landing is not built yet, so a cancellation never credits the wallet on its own today. Do not write code that waits for a refund entry.
  • A delivery that is not in the booked state, including one already cancelled or already terminal, cannot be cancelled.

shipping_get_delivery

Get Delivery

Returns one delivery document in full: mode, state, canonical status and sub-status, vendor and booking reference, both addresses, parcels and items, the chosen offer, the event timeline, the platform fee, and the mode-specific payload (label url, label format, tracking number and tracking page for a parcel; courier, PIN and position for a local job). The vendor cost and the margin are stripped from the response for anyone who is not a superuser.

Availability: Dashboard session

Parameters

Name Type Required Description
delivery_id string Yes Delivery to read.

Notes

  • Auth: clearance: user, and the caller must own the delivery unless superuser. No min_plan.
  • Every vendor is normalized into one of nine canonical statuses: pre_transit, in_transit, out_for_delivery, delivered, available_for_pickup, return_to_sender, exception, cancelled and unknown. Five finer local-courier states are carried as sub_status and map upward. No raw vendor string ever reaches this response. Match on the canonical status, never on vendor text.
  • The event timeline is only ever populated by what the vendor returned at booking. There is no tracking poller and no inbound vendor webhook today, so do not expect the timeline to grow on its own.
  • The delivery's state (draft, booked, cancelled) and its status are different fields. State is the lifecycle in Xuda, status is where the parcel is.

shipping_list_deliveries

List Deliveries

Lists deliveries for the caller's account, newest first, filterable by service mode, canonical status or the caller's own order reference. Each row carries the delivery id, service mode, state, status and sub-status, vendor, order reference, destination city and country, the retail amount and the created timestamp. A superuser additionally sees the wholesale cost and margin per row, and only a superuser may read another tenant.

Availability: Dashboard session

Parameters

Name Type Required Description
owner_uid string No Tenant to read. Defaults to the caller; naming another tenant needs superuser.
service_mode string No Filter to parcel or local.
status string No Filter to one canonical status.
order_ref string No Filter to one caller order reference.
limit number No Rows to return, max 200. Defaults to 25.
skip number No Rows to skip, for paging.

Notes

  • Auth: clearance: user. No min_plan.
  • order_ref is indexed, so filtering on your own reference is the supported way to find the delivery for one of your orders.
  • The plan ladder declares a retention window per tier, but no code enforces it today. Rows are not pruned on your behalf.

shipping_list_vendors

List Shipping Vendors

Lists the shipping vendors registered on this host with their service mode, available services, feature map and a coverage summary. Parcel vendors report their origin country list and either "all" destinations or a destination count; local vendors report their named service areas and scheduling window. A vendor whose capability call fails is returned with an error string rather than omitted. The response also carries is_debug, which is what tells the operator screen that the development-only mock vendors are active.

Availability: Dashboard session

Parameters

This method takes no parameters.

Notes

  • Auth: clearance: user. No min_plan.
  • Mock vendors exist to prove the adapter contract, the router and the pricing engine. They are filtered out of routing on any host where debug mode is off, so a mock rate can never be sold to a real customer. When is_debug is true in the response, the vendors you see include mocks.
  • One real parcel vendor is implemented. It declares 11 origin countries (AU, CA, FR, DE, HK, IT, NL, SG, ES, GB, US) and all destinations. The truthful claim to carry into your own copy is "ship worldwide", which is about destinations, not "ship from anywhere", which is not true on any tier.
  • The only local courier adapter today is a mock. On a production host, local courier delivery therefore has no vendor at all.
  • A vendor whose credentials are absent simply does not register, rather than registering an adapter that throws.

shipping_check_route

Check Shipping Route

Answers whether any vendor can serve a route, across both service modes, without producing a quote or contacting a vendor for prices. Parcel eligibility is by country pair; local eligibility requires both the origin and the destination to fall inside one service-area polygon, because a courier network that can collect but not deliver is not coverage. Parcel weight and dimensions matter as much as geography, since courier networks have weight, size and radius ceilings, so a route check that ignores the box answers the wrong question. An unserviceable route returns the blocked origin and destination, which is the number that ranks which vendor to add next.

Availability: Dashboard session

Parameters

Name Type Required Description
from object Yes Origin. Parcel needs country; local needs lat and lng.
to object Yes Destination. Parcel needs country; local needs lat and lng.
mode string No Limit the check to one service mode, parcel or local. Omit to check both.
parcels array No Parcel list with weight_g and optional length_cm, width_cm and height_cm. Local courier networks have weight, size and radius ceilings, so a route check without the parcel can say yes to something that cannot be booked.

Notes

  • Auth: clearance: user. No min_plan.
  • This is a coverage question, not a price question. No vendor is called for rates and nothing is cached or metered.
  • Pass the parcel you actually intend to ship. Omitting it can return a yes that a real quote would refuse on physical limits.

shipping_get_rate_card

Get Shipping Rate Card

Returns the pricing rules applied to a tenant's quotes: the pricing mode (passthrough, spread, discounted or markup), any markup settings, the plan id, and the postage discount percentage that plan grants. The customer-facing discount always comes from the plan and is never a per-tenant field, so a support edit cannot hand someone a better deal than their plan sells.

Availability: Dashboard session

Parameters

Name Type Required Description
owner_uid string No Tenant to read. Defaults to the caller; naming another tenant needs superuser.

Notes

  • Auth: clearance: user. No min_plan.
  • The launch policy is back to back. The default pricing mode is passthrough, the retail price equals the vendor's price with zero markup on every tier including Free, and the engine refuses to price retail below wholesale.
  • The negotiated vendor discount that would make spread and discounted meaningful is read from configuration that does not exist in either environment today, so the negotiated discount is zero everywhere and all four modes currently collapse to the same number.
  • A plan's postage discount is clamped to the negotiated discount, so a plan can never give away more than Xuda actually negotiated. Every tier's postage discount is zero today.

shipping_set_rate_card

Set Shipping Rate Card

Sets a tenant's pricing mode and markup settings. The customer-facing postage discount is deliberately not settable here, because that number comes from the plan and only from the plan.

Availability: Operator only

Parameters

Name Type Required Description
owner_uid string Yes Tenant whose rate card to set.
pricing_mode string No One of passthrough, spread, discounted or markup.
markup_percent number No Percentage markup applied over the vendor cost.
markup_fixed_cents number No Fixed markup in cents applied over the vendor cost.
markup_min_cents number No Minimum markup in cents.

Notes

  • Auth: clearance: admin plus an explicit superuser check in code. Admin clearance alone is not enough.
  • Read the result back with shipping_get_rate_card, which is the customer-visible half of the same document.
  • With the negotiated vendor discount unset everywhere, spread and discounted price identically to passthrough today.

shipping_price_preview

Preview Shipping Price

Shows how a given vendor cost prices out under a tenant's rate card, returning the list price, the wholesale cost, the retail price and the margin. This is the read behind the wholesale-to-retail preview on the operator carriers and pricing screen.

Availability: Operator only

Parameters

Name Type Required Description
wholesale_cents number Yes Vendor cost to price out.
owner_uid string No Tenant whose rate card to price against. Defaults to the caller.
vendor string No Vendor key to price against.
pricing_mode string No Override the stored pricing mode for this preview.
customer_discount_percent number No Customer discount percentage to model.

Notes

  • Auth: clearance: admin plus an explicit superuser check in code.
  • Nothing is written and no vendor is contacted. This is a calculation.
  • Retail can never fall below wholesale. The engine floors it and logs an error when a combination would.

shipping_wallet_adjust

Adjust Shipping Wallet

Posts a manual credit or debit to a tenant's ledger. The operator's own uid is recorded in the entry's meta, so a manual movement is always attributable.

Availability: Operator only

Parameters

Name Type Required Description
owner_uid string Yes Tenant whose ledger to adjust.
amount_cents number Yes Signed non-zero integer. Positive credits, negative debits.
note string Yes Reason for the adjustment, stored on the entry.
idempotency_key string No Key that makes a retried adjustment post once.

Notes

  • Auth: clearance: admin plus an explicit superuser check in code.
  • Idempotency: the ledger entry id is a hash of the account and the idempotency key, so a replay with the same key returns the original entry rather than moving money twice.
  • The adjustment is a new append-only entry. It never edits an existing entry and never writes a balance directly.

shipping_run_auto_topup

Run Auto Top-up

Runs automatic top-up for one tenant, or sweeps up to 500 armed wallets when no tenant is named. Every guard inside it is a no-op when conditions are not met, so it is safe to call on a schedule.

Availability: Operator only

Parameters

Name Type Required Description
owner_uid string No Tenant to run. Omit to sweep armed wallets.

Notes

  • Auth: clearance: admin plus an explicit superuser check in code.
  • Nothing calls this on a schedule today. Automatic top-up is otherwise evaluated inline after each successful booking.
  • The 24 hour cap is checked against real ledger history, and a declined card disarms the tenant's automatic top-up rather than being retried.

shipping_sync_denied_parties

Sync Denied Party List

Downloads the public OFAC Specially Designated Nationals CSV and stores the primary names used by pre-booking screening. It refuses to overwrite the stored list when the download parses to fewer than 100 names, so a truncated or failed fetch cannot quietly empty the screen.

Availability: Operator only

Parameters

Name Type Required Description
url string No Source CSV to pull. Defaults to the published OFAC SDN CSV.

Notes

  • Auth: clearance: admin plus an explicit superuser check in code.
  • The download has a 45 second abort timeout, and the parsed list is cached in module memory for 10 minutes, so a fresh sync is not visible to screening instantly.
  • Nothing runs this on a schedule today.
  • The resulting check is a plain lowercase substring match against one public list. There is no fuzzy matching, no deliberate-misspelling resistance and no EU or UN list. It must not be described in customer copy as sanctions screening.

The Plan Ladder And What It Gates

There are four tiers: shipping_free, shipping_starter, shipping_growth and shipping_scale. Postage itself is sold at cost on every one of them, including Free, so a tier buys volume, service modes and locations rather than a better postage price.

No Shipping tier can be purchased yet. All four carry placeholder Stripe price ids in both environments, so shipping_set_plan answers -402 for a paid tier and the dashboard prices it as "Coming soon".

Only four plan flags are read by any code today:

Flag Free Starter Growth Scale Where it bites
services parcel only parcel and local parcel and local parcel and local Filters shipping_quote offers and is re-checked in shipping_book_delivery.
deliveries_per_month 25 400 2000 10000 Counted in shipping_book_delivery. Quotes are never counted.
platform_fee_per_delivery none, hard stop at the quota $0.05 $0.03 $0.02 Posted as a separate platform_fee ledger entry on an over-quota booking.
pickup_locations 1 3 15 unlimited Enforced in shipping_create_location and on downgrade in shipping_set_plan.

Every other flag on the ladder is declared but not read by any code in the module: vendor_rate_shopping, scheduled_local, branded_tracking_page, returns_portal, insurance, seller_byo_accounts, postpaid_billing, api, api_rate_per_min, webhooks, seats and retention_days. Do not build an integration that assumes one of those is enforced.

Errors

Every method returns the platform envelope { code, data }. code: 1 is success. A negative code is a failure carrying a message or a structured reason in data.

Code Meaning
-402 Insufficient wallet balance at booking, carrying required_cents and balance_cents, raised before any vendor is contacted. Also returned by shipping_set_plan when the tier has no live Stripe price, with the message "The plan is not billable yet".

No Shipping method carries a min_plan key, so the platform's plan gate never fires here. Plan refusals are raised inside the module.

Reasons returned when a quote produces no offers. Each needs a different answer, which is why they are distinct:

Reason Meaning
plan_excludes_service The account's plan does not sell the service mode that would have covered this route.
exceeds_service_limits A vendor covers the route but the parcel is over its weight, dimension or radius ceiling. The per-vendor reason is included.
no_coverage No vendor serves this origin and destination at all. The blocked origin and destination are returned.

Other named failures:

  • quote_expired from shipping_book_delivery when the offer token resolves to a quote past its TTL. Re-quote. The offer is never silently re-priced.
  • Screening refusals from shipping_quote and shipping_book_delivery, returned as a list of reasons: an embargoed destination (RU, BY, KP, IR, SY, CU), a restricted goods match across five families (lithium batteries, flammables and aerosols, weapons and explosives, controlled substances, cash and bullion), one of ten customs descriptions that ICS2 rejects, or a denied party name match.
  • A quota hard stop from shipping_book_delivery on a tier whose per-delivery platform fee is zero, with a message naming the plan and its monthly allowance.
  • A pickup location refusal from shipping_create_location naming the plan and the number of locations it includes, and from shipping_set_plan on a downgrade, naming how many to remove first.
  • A vendor failure during booking releases the wallet reservation and leaves the delivery bookable, so a retry is safe.

Rate Limits

There is no per-method rate limit in the Shipping module. The plan ladder declares an api_rate_per_min value per tier, but no code reads it, and no Shipping method is reachable with an API key in any case.

The timeouts that do exist are internal and are there to protect a checkout page rather than to ration you:

Scope Limit
Each vendor call inside one quote 2000 ms hard timeout. A slow vendor is dropped from the fan-out, not waited for.
Vendor registration when saving a pickup location 8 seconds per vendor. A failure does not block the save.
Denied party list download 45 second abort timeout.

Idempotency And Lifetimes

  • Money movements are idempotent by construction. A ledger entry's document id is derived from a hash of the account and the idempotency key, so a replayed post collides in the database and returns the original entry instead of moving money twice.
  • A top-up cannot double credit. The topup entry is keyed on the Stripe charge id, and a retried call after a network failure returns replayed: true.
  • A double-clicked booking cannot buy two labels. Booking an already-booked delivery returns the original booking result.
  • Cancelling is not a refund. No wallet credit is posted when a cancellation is requested, and refund landing is not built, so nothing credits later on its own either.
  • Deleting a pickup location may archive it instead. Read the response rather than assuming the document is gone.
Lifetime Default
Parcel quote and its offer tokens 15 minutes
Local courier quote and its offer tokens 3 minutes
Denied party list cached in module memory 10 minutes
Minimum single wallet top-up $5.00
Maximum single wallet top-up $5,000.00
Ledger page size on shipping_get_wallet and rows on shipping_list_deliveries 25 by default, 200 maximum
Wallets swept per shipping_run_auto_topup sweep 500
Ledger page size used by the wallet audit 500 entries

Webhooks

Xuda Shipping publishes no webhooks and receives none. There is no inbound vendor webhook handler and no outbound customer webhook in the module. The webhooks plan flag is declared on the ladder but is not read by any code.

The practical consequence for an integration: a delivery's event timeline is only ever populated by what the vendor returned at booking time. There is no tracking poller, so nothing updates a delivery's status after it is booked. Poll shipping_get_delivery if you need the stored state, and do not wait for a callback that will not arrive.

There are also no crons. Automatic top-up runs inline after a successful booking. The wallet audit, the automatic top-up sweep and the denied party sync are manual today.

The ten shipping_api_* methods and ten webhook events described in the product plan are not built. Nothing in the shipped module implements them.

A Note On The Rest Of The Surface

The five operator methods above are documented so the surface is complete and so nobody mistakes their absence for a gap. They carry admin clearance and each performs an explicit superuser check in code. They are not part of the customer-facing product and cannot be called from a normal account.

Beyond the 24 methods here, the module exposes nothing else. Other Xuda modules reach Shipping through generated broker wrappers that export exactly these 24 methods. Xuda Commerce is the only module that imports Shipping, never the other way round: it calls shipping_quote for live checkout rates and maps only the retail price into the buyer's browser, shipping_get_wallet to warn a seller whose wallet is empty, shipping_list_locations to resolve the seller's ship-from address rather than storing a second copy, and shipping_create_delivery when a paid order is fulfilled, passing the order id as the opaque order_ref. Buying the label stays a separate deliberate act in Shipping, because it spends the seller's wallet.