Skip to content

Outbound Webhook ​

Outbound status changes are pushed by webhook. Both subscription-based delivery (multiple events, multiple URLs) and the per-order dedicated URL registered through webhook_url at submission are supported. Both use HMAC-SHA256 signing and a 5-second timeout. Delivery runs asynchronously through an outbox, and both subscription-based and dedicated URLs retry with exponential backoff (up to 5 attempts).

Events ​

EventTrigger
outbound.createdOutbound order created
outbound.approvedApproval passed / auto-approved
outbound.warehouse_confirmedWarehouse confirmed and locked inventory
outbound.rejectedApproval rejected
outbound.stock_readyWarehouse marked stock ready
outbound.shippedCarrier picked up / dispatched
outbound.completedDelivery completed
outbound.cancelledOutbound cancelled
outbound.evidence.uploadedWarehouse uploaded evidence

Event types use category.event: the main category is outbound and the sub-type is created, approved, and so on. Subscription events supports the outbound.* wildcard to receive every event in the category.

Delivery ​

  • Method: POST
  • Content-Type: application/json
  • Timeout: 5 seconds for connect and read
  • Success: any 2xx
  • Retry: both subscription-based and dedicated URLs retry after a failure, up to 5 times, with delays 1m, 5m, 30m, 2h, 6h; then stop
  • Ordering: not guaranteed; use occurred_at and data.status
  • Idempotency: consumers must dedupe by id
  • Dedicated URL: pass webhook_url when submitting an outbound request; the system generates webhook_secret for that outbound (readable via /outbound/detail), and delivers with X-E2C-Webhook-Id: 0. Dedicated URLs are enqueued in the same outbox as subscriptions and retry with the same backoff policy

Headers ​

HeaderDescription
X-E2C-EventEvent type, e.g. outbound.stock_ready
X-E2C-DeliveryEvent ID, identical to the payload id (retries reuse the same value)
X-E2C-TimestampUnix seconds
X-E2C-Signaturesha256=<hex hmac>
X-E2C-Webhook-IdSubscription ID; 0 for dedicated URL delivery

Signature ​

text
signature = HMAC_SHA256(secret, timestamp + "." + raw_request_body)
header    = "sha256=" + hex(signature)

Verify:

  1. Read the raw body (before JSON parsing).
  2. Reject if abs(now - X-E2C-Timestamp) > 300 seconds.
  3. Compute the HMAC with the shared secret.
  4. Compare using a constant-time function.
  5. Return 2xx quickly; process asynchronously.

Payload ​

json
{
  "id": "evt_5f3c9a7d1e2b4c6d8e0f1a2b",
  "type": "outbound.stock_ready",
  "version": "1.0",
  "occurred_at": "2026-11-11T10:30:00+00:00",
  "data": {
    "outbound_id": 5001,
    "outbound_no": "OB20261111100000123",
    "source_type": "partner_outbound",
    "source_id": 1001,
    "member_id": 42,
    "warehouse_id": 1,
    "status": "stock_ready",
    "previous_status": "warehouse_confirmed",
    "stock_ready_at": "2026-11-11T10:30:00",
    "dispatch_task_id": null,
    "tracking_number": null
  }
}

Field Reference ​

FieldTypeDescription
idstringEvent ID, evt_ + 24 hex characters, used for idempotency
typestringEvent type
versionstringPayload version, currently 1.0
occurred_atISO8601Event time (with server timezone offset)
data.outbound_idintegerGeneric outbound order ID
data.outbound_nostringOutbound number
data.source_typestringSource type; partner_outbound for partner outbound
data.source_idintegerSource record ID (outbound request ID for partners)
data.member_idintegerOwner member ID
data.warehouse_idintegerWarehouse ID
data.statusstringCurrent SOP status
data.previous_statusstring/nullPrevious SOP status
data.stock_ready_atdatetime/nullStock-ready time
data.dispatch_task_idinteger/nullERP dispatch task ID
data.tracking_numberstring/nullTracking number; usually null for partner outbound, use the dispatch task or carrier callback instead

Example Verification (Node.js) ​

js
import crypto from 'crypto'

function verify(rawBody, headers, secret) {
  const ts = headers['x-e2c-timestamp']
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(`${ts}.${rawBody}`)
    .digest('hex')
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(headers['x-e2c-signature']))
}

List Subscriptions ​

POST/channel/api/v1/webhook/subscriptions

Auth: request-token (channel_partner)

List all outbound webhook subscriptions of the current member, ordered by ID descending. events is decoded into an array; secret is never returned.

Required capability: outbound_webhook_manage

Request Body ​

No request parameters.

Response ​

json
{
  "code": 200,
  "msg": "success",
  "data": [
    {
      "id": 12,
      "member_id": 42,
      "url": "https://partner.example.com/hooks/e2c",
      "events": ["outbound.stock_ready", "outbound.shipped"],
      "active": 1,
      "created_at": "2026-11-10 09:00:00",
      "updated_at": "2026-11-10 09:00:00"
    }
  ]
}

Error Codes ​

codeMeaning
909Unauthenticated, invalid token, or not a channel partner
606Insufficient capability (outbound_webhook_manage required)

cURL ​

cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/webhook/subscriptions' \
  -H 'request-token: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'

Save Subscription ​

POST/channel/api/v1/webhook/subscriptions/save

Auth: request-token (channel_partner)

Create or update a subscription. Pass id to update one of the member's subscriptions; omit id to create. When secret is omitted a random 24-byte hex string (48 characters) is generated. Note: every update writes secret — a provided value is used, otherwise a new secret is generated and the old one becomes invalid. Omitting active sets it to 0 (disabled).

Required capability: outbound_webhook_manage

Request Body ​

FieldTypeRequiredDescription
idintegernoSubscription ID; present means update
urlstringyesValid URL receiving the webhook (HTTP/HTTPS)
eventsstring[]yesEvent array, at least one item; only values from the event table are kept
secretstringnoSigning secret; generated when empty
activeboolean/integernoWhether enabled; default false (0)

Response ​

json
{
  "code": 200,
  "msg": "success",
  "data": {
    "id": 12,
    "secret": "5d41402abc4b2a76b9719d911017c5923f9c1d2e4b6a8f0c"
  }
}

secret is returned by this endpoint only; store it securely immediately.

Error Codes ​

codeMeaning
909Unauthenticated, invalid token, or not a channel partner
606Insufficient capability (outbound_webhook_manage required)
400Missing or invalid url, or events empty / entirely invalid
404Subscription not found on update, or not owned by this member

cURL ​

cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/webhook/subscriptions/save' \
  -H 'request-token: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://partner.example.com/hooks/e2c",
  "events": [
    "outbound.stock_ready",
    "outbound.shipped"
  ],
  "active": true
}'

Delete Subscription ​

POST/channel/api/v1/webhook/subscriptions/delete

Auth: request-token (channel_partner)

Delete one of the current member's subscriptions. Returns 404 when id does not exist or is not owned by this member.

Required capability: outbound_webhook_manage

Request Body ​

FieldTypeRequiredDescription
idintegeryesSubscription ID (alias subscription_id accepted)

Response ​

json
{
  "code": 200,
  "msg": "success",
  "data": null
}

Error Codes ​

codeMeaning
909Unauthenticated, invalid token, or not a channel partner
606Insufficient capability (outbound_webhook_manage required)
400Missing id
404Subscription not found or not owned by this member

cURL ​

cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/webhook/subscriptions/delete' \
  -H 'request-token: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": 12
}'

Delivery Logs And Retries ​

  • Delivery mode: every delivery (subscription + dedicated URL) is first written to the t_plan_task_record outbox (type=WebhookDelivery) and executed asynchronously by plan-task-worker.php; business requests no longer wait for the HTTP delivery
  • Worker: php script/tools/plan-task-worker.php --limit=50 (run every minute); the old outbound-webhook-retry.php remains as a compatibility entry point
  • Delivery state: status, attempts, next_retry_at, result, last_error on t_plan_task_record; wms_outbound_webhook_delivery is kept for historical data only