Machine-readable source of truth:
Related docs:
#What the SDK wraps
The Python SDK is a thin client over the current protocol endpoints under /api.
The default base_url is:
python
http://localhost:3000/apiSo methods such as client.plan(...) call /api/exports/plan at runtime.
#Quickstart
python
import os
from shpbndl import SHPBNDL, SHPBNDLError
client = SHPBNDL(
api_key=os.environ["SHPBNDL_API_KEY"],
base_url=os.environ.get("ENTRYGO_BASE_URL", "http://localhost:3000/api"),
)
try:
synced_orders = client.orders.sync(
accountId="acc_123",
items=[
{
"externalId": "ord-ext-1001",
"destinationCountry": "US",
"destinationRegion": "CA",
"destinationPostalCode": "94105",
"items": [
{
"productId": "prod_123",
"quantity": 1,
"unitValueUsd": 110,
}
],
"metadata": {
"source": "sdk-py-example",
},
}
],
idempotencyKey="orders-sync-001",
)
order_id = str(synced_orders["data"][0]["id"])
plan = client.plan(
accountId="acc_123",
warehouseId="wh_123",
brokerId="br_123",
destinationCountry="US",
orderIds=[order_id],
idempotencyKey="plan-acc-123-001",
)
print(plan["exportId"], plan["planHash"], plan["readinessState"])
if plan["readinessState"] == "BLOCKED":
print(plan["validationMessages"])
raise SystemExit(1)
execution = client.execute(
accountId="acc_123",
batchId=plan["exportId"],
idempotencyKey="execute-acc-123-001",
)
print(execution["customs_package_id"], execution["artifacts"])
inspection = client.inspect(plan["exportId"])
print(inspection["status"], inspection["notifications"], inspection["events"])
except SHPBNDLError as error:
print(error.error_code, error.message, error.field, error.details)#Current methods
Top-level:
client.plan(...)client.execute(...)client.inspect(export_id)
Grouped clients:
client.orders.sync(...)client.products.sync(...)client.exports.plan(...)client.exports.execute(...)client.exports.get(export_id)client.exports.inspect(export_id)
Legacy compatibility:
client.exports.optimize(...)remains available as a compatibility alias, but the current contract should preferplan(...)
#Request and response highlights
#orders.sync(...)
Important request fields:
accountIditems[].externalIditems[].destinationCountryitems[].items[].productIditems[].items[].quantityitems[].items[].unitValueUsd
Important response fields:
datadata[].iddata[].externalIddata[].totalValueUsd
Important rule:
- planning expects EntryGo order IDs returned by order sync
#plan(...)
Important response fields:
exportIdplanHashreadinessStatecomplianceScorevalidationMessagesincluded_order_idsexcluded_order_idsnext_recommended_action
#execute(...)
Important response fields:
exportIdcustoms_package_idartifactsnotification_idsexecution_timestampbrokerSubmission
#inspect(...)
Important response fields:
statusstateplanHashartifactscustomsPackagenotificationsbrokerSubmissioneventssnapshot
#Idempotency and automation guidance
Best practice:
- pass
idempotencyKeyfororders.sync,plan, andexecute - reuse the same key only for retries of the same logical operation
- use
inspect(...)after ambiguous failures or timeouts
For agent or workflow systems:
- treat
planHashas the planning fingerprint - branch on
readinessState,validationMessages,status, andbrokerSubmission
#Errors
The SDK raises SHPBNDLError with:
error_codemessagefielddetails
Common values:
VALIDATION_ERRORINVALID_API_KEYINVALID_ACCOUNT_SCOPEINVALID_ORDER_REFERENCEINVALID_EXPORT_STATEIDEMPOTENCY_CONFLICTNOT_FOUND
#Notes
- The Python SDK returns dictionaries rather than generated typed models.
- For full field definitions, use
/docs/api/openapi.