The lifecycle is intentionally small:
- sync order demand
- plan an export
- execute the approved batch
- inspect current state
The OpenAPI contract for that lifecycle lives at /docs/api/openapi.
#Lifecycle at a glance
| Phase | Endpoint | Input | Output | Why it exists |
|---|---|---|---|---|
| Sync | POST /api/orders/sync |
Account-scoped source orders | Stable EntryGo order IDs | Makes demand available to the protocol |
| Plan | POST /api/exports/plan |
Order IDs, warehouse, broker, destination | Export decision and readiness | Separates decision from side effect |
| Execute | POST /api/exports/execute |
Planned batchId |
Customs package state, artifacts, broker submission | Applies the approved plan |
| Inspect | GET /api/exports/{id} |
Export ID | Canonical current state | Reconciles what actually happened |
#1. Order intake and sync
Order sync is the entry point where external demand becomes protocol-visible.
Important behavior:
- orders are upserted by
externalIdwithin the authenticated account - line items are replaced on update
- the response returns the EntryGo order IDs that later planning calls must use
Operationally, sync is not just transport. It defines the exact demand set planning is allowed to reason about. If an order is not in the synced order store, it is not part of the plan.
#2. Planning
Planning is the decision phase of the lifecycle.
Planning takes:
accountIdwarehouseIdbrokerIddestinationCountryorderIds
Planning returns:
- inclusion and exclusion decisions
- readiness state
- validation issues
- flags and missing data
- a strategy hint
planHash
The key architectural rule is simple: planning computes what should happen, but it does not yet trigger the operational side effects.
#Why planHash matters
planHash is the deterministic fingerprint of the planning snapshot.
Clients should use it when they need to know whether the planning inputs are materially the same across:
- retries
- repeated evaluations
- automation branches
- human review loops
In practical terms:
- idempotency tells the server whether two writes are intended to be the same logical request
planHashtells the client whether two planning outcomes describe the same planning state
#3. Execution
Execution is the side-effecting phase.
Execution turns a planned batch into operational outputs, including:
- customs package creation or reuse
- artifact generation
- notification creation
- broker submission handling
Execution should only happen after the caller has decided that the planning result is acceptable for policy and readiness.
That means:
200or201from planning is not enough by itselfreadinessStateandvalidationMessagesmust be interpreted before execution
#4. Inspection
Inspection is the lifecycle read model.
Use inspect to answer:
- what was planned
- what executed
- what artifacts currently exist
- whether broker submission succeeded
- which events have occurred
- what state the export is in now
Inspect matters because clients often lose certainty after network failures, partial automation runs, or long-running side effects. The inspect endpoint lets every client converge on the same source of truth.
#Events in the lifecycle
EntryGo exposes event history as part of inspect because lifecycle progress should be observable, not inferred.
Representative events include:
- planning completed
- customs package generated
- broker submission prepared
- broker submission sent or failed
- warehouse notification recorded
- execution completed
Events are useful for:
- human debugging
- auditability
- agent reconciliation
- automation reporting
#Idempotency rules
EntryGo supports idempotent write behavior on the main write endpoints:
POST /api/orders/syncPOST /api/exports/planPOST /api/exports/execute
Rules:
- send the
Idempotency-Keyheader for retriable writes - if both header and body keys are sent, the header wins
- reusing a key for a different logical payload can produce
409 IDEMPOTENCY_CONFLICT
Safe retry pattern:
- send the write request with an idempotency key
- if the client times out or loses the response, retry with the same key
- if state is still unclear, inspect the export or package resource
#Typical lifecycle mistakes
| Mistake | Why it breaks | Correct approach |
|---|---|---|
| Planning from external order references only | Planning expects EntryGo order IDs | Persist IDs returned by order sync |
| Executing immediately on any successful plan response | Readiness may still be REVIEW_REQUIRED or BLOCKED |
Gate execute on policy and readiness fields |
| Treating execute as proof of final state forever | The client may miss later state or events | Use inspect for reconciliation |
| Generating custom partner side effects outside the protocol | Export state becomes fragmented | Let execute own broker and notification side effects |
#Lifecycle guidance for AI agents
For agentic clients, the correct loop is:
- sync current inputs
- plan
- evaluate readiness and validation
- execute only if policy permits
- inspect until the observed state supports the next action
That loop is what makes EntryGo usable as an automation substrate rather than just a set of endpoints.