EventsSubmit Events Asynchronously

Submit Events Asynchronously

Queue a batch of events with POST /Integration/Events/async and read the outcome from GET /Integration/Jobs.

Introduction

This page is for developers integrating a system with Wholechain through the Connect API. It covers:

  • POST /Integration/Events/async
  • GET /Integration/Jobs

Why Use Async

POST /Integration/Events (sync) holds the HTTP connection open while Wholechain validates and writes every event. For large batches or long event chains, that risks client and gateway timeouts.

POST /Integration/Events/async takes the same request body, does a quick check, puts the batch in a queue and returns a correlationId straight away. A background worker then processes the batch. You get the outcome by looking up that ID in the Jobs log.

Sync /Integration/EventsAsync /Integration/Events/async
Request body{ "Events": [...] }Identical
HTTP responseFull processing resultcorrelationId only
Business errors (inventory, chronology)Returned as an HTTP 4xxHTTP 200 at submit, then the job shows Failed
Where the result livesResponse bodyGET /Integration/Jobs → success / error

Environments and Authentication

EnvironmentBase URLWhere to generate keys
Sandboxhttps://connect-sandbox.wholechain.comhttps://sandbox.wholechain.com/settings/integrations
Productionhttps://connect.wholechain.comhttps://app.wholechain.com/settings/integrations

Step 1: Submit a Batch

Endpoint

POST /Integration/Events/async

Example: Three Dependent Events in One Call

This batch creates a lot (Commission), processes it (Transform) and ships part of the output (Ship):

08:00  COMMISSION   100 kg Whole Salmon   lot RAW-001   @ plant
10:00  TRANSFORM    RAW-001 (100 kg) → 70 kg Salmon Fillet lot FIL-001
14:00  SHIP         50 kg FIL-001   plant → buyer DC

Each event depends on the one before it. All three can go in one call because Wholechain orders events by EventTime, not by array position. Even so, it's good practice to list them in time order.

curl -X POST "https://connect-sandbox.wholechain.com/Integration/Events/async" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: $WHOLECHAIN_API_KEY" \
  -d '{
  "Events": [
    {
      "$type": "commission",
      "Id": "asyncdemo1-COM-001",
      "Location": {
        "Id": "asyncdemo1_plant",
        "Details": {
          "TradePartner": { "Id": "asyncdemo1_self", "Name": "Async Demo Co", "ConnectionType": "SELF" },
          "Name": "Async Demo Plant",
          "Address": { "City": "Cape Town", "Country": "South Africa", "AddressLine1": "1 Demo St", "PostalCode": "8001" }
        }
      },
      "ProductInstances": [
        {
          "Quantity": 100,
          "LotSerial": "asyncdemo1-RAW-001",
          "Product": {
            "Id": "asyncdemo1_whole_salmon",
            "Details": { "ProductIdentifierType": "Lot", "Name": "Whole Salmon", "SimpleUnitOfMeasurement": "Kgm", "SharingPolicy": "Open" }
          }
        }
      ],
      "EventTime": "2026-11-10T08:00:00",
      "EventTimeZone": "+00:00"
    },
    {
      "$type": "transform",
      "Id": "asyncdemo1-TRN-001",
      "Location": { "Id": "asyncdemo1_plant" },
      "InputProducts": [
        { "Quantity": 100, "LotSerial": "asyncdemo1-RAW-001", "Product": { "Id": "asyncdemo1_whole_salmon" } }
      ],
      "OutputProducts": [
        {
          "Quantity": 70,
          "LotSerial": "asyncdemo1-FIL-001",
          "Product": {
            "Id": "asyncdemo1_salmon_fillet",
            "Details": { "ProductIdentifierType": "Lot", "Name": "Salmon Fillet", "SimpleUnitOfMeasurement": "Kgm", "SharingPolicy": "Open" }
          }
        }
      ],
      "EventTime": "2026-11-10T10:00:00",
      "EventTimeZone": "+00:00"
    },
    {
      "$type": "ship",
      "Id": "asyncdemo1-SHP-001",
      "ShipFromLocation": { "Id": "asyncdemo1_plant" },
      "ShipToLocation": {
        "Id": "asyncdemo1_buyer_dc",
        "Details": {
          "TradePartner": { "Id": "asyncdemo1_buyer", "Name": "Demo Buyer", "ConnectionType": "BUYER" },
          "Name": "Demo Buyer DC",
          "Address": { "City": "Cape Town", "Country": "South Africa", "AddressLine1": "9 Buyer Rd", "PostalCode": "8002" }
        }
      },
      "ProductInstances": [
        { "Quantity": 50, "LotSerial": "asyncdemo1-FIL-001", "Product": { "Id": "asyncdemo1_salmon_fillet" } }
      ],
      "PurchaseOrder": "asyncdemo1-PO-1",
      "EventTime": "2026-11-10T14:00:00",
      "EventTimeZone": "+00:00"
    }
  ]
}'

Response When the Batch Is Queued (HTTP 200)

{
  "result": "Success",
  "correlationId": "76b83134-4a69-49ea-8011-f7a1cbab9e6c",
  "validations": []
}

"result": "Success" only means the batch was queued. It does not mean any event was created. Store correlationId against your outbound batch record right away, because it's the only handle you have on the outcome.


Step 2: Look Up the Result in the Jobs Log

Endpoint

GET /Integration/Jobs?JobId={correlationId}

The correlationId returned when you submit is the jobId.

Query paramTypeNotes
JobIduuidThe correlation ID. Use this for single-job lookups.
Statusstring[]Started, Completed, Failed. Repeatable, e.g. ?Status=Failed&Status=Started.
EventTypestring[]In the spec; not tested here.
PageNumber / PageSizeintDefault 1 / 20. Always send values ≥ 1 (see Other Quirks Seen in the Sandbox).
SortBystringIn the spec; accepted values aren't documented.
curl "https://connect.wholechain.com/Integration/Jobs?JobId=76b83134-4a69-49ea-8011-f7a1cbab9e6c" \
  -H "X-API-KEY: $WHOLECHAIN_API_KEY"

Job Object Returned

FieldMeaning
jobIdSame value as correlationId.
name"events" for event batches.
payloadThe request body you sent, as a JSON string.
statusStarted → still processing. Completed → batch committed. Failed → nothing in the batch was committed.
startedAt / completedAtUTC timestamps. completedAt is null while Started.
successWhen Completed: a JSON string holding the same ProcessEventsResponse the sync endpoint returns.
errorWhen Failed: a string. Usually problem-details JSON, but sometimes plain text (see Other Quirks Seen in the Sandbox).

Completed Job

Raw response, with payload and success shortened:

{
  "totalPages": 1, "pageNumber": 1, "pageSize": 20, "totalItems": 1,
  "results": [
    {
      "jobId": "76b83134-4a69-49ea-8011-f7a1cbab9e6c",
      "name": "events",
      "payload": "{"Events": [{"$type": "commission", "Id": "asyncdemo1-COM-001", ...}]}",
      "status": "Completed",
      "startedAt": "2026-11-16T03:34:05.529608Z",
      "completedAt": "2026-11-16T03:34:08.036187Z",
      "error": null,
      "success": "{"message":"Events processed successfully","result":[...]}"
    }
  ],
  "hasNextPage": false,
  "hasPreviousPage": false
}

The success string, parsed:

{
  "message": "Events processed successfully",
  "result": [
    {
      "id": "01a1e26b-5675-77e1-821c-5a59bce29ac5",
      "externalEventId": "asyncdemo1-COM-001",
      "type": "Commission",
      "status": "Created",
      "eventDate": "2026-11-10T08:00:00+00:00",
      "productInstances": [
        { "quantity": 100, "lotSerial": "asyncdemo1-RAW-001", "status": 0,
          "id": "01a1e26b-5675-703e-aeb6-1bcef510de92", "name": "Whole Salmon",
          "urn": "urn:gdst:wholechain.com:product:lot:class:raindropsolutions.wholesalmon.asyncdemo1-raw-001" }
      ],
      "containers": [], "directShipFallback": null, "externalShipmentFailure": null, "documentsNotAttached": null
    },
    {
      "id": "01a1e26b-56ba-7a56-a598-ff0ad3825626",
      "externalEventId": "asyncdemo1-TRN-001",
      "type": "Transform",
      "status": "Created",
      "eventDate": "2026-11-10T10:00:00+00:00",
      "productInstances": [
        { "quantity": 100, "lotSerial": "asyncdemo1-RAW-001", "status": 0, "name": "Whole Salmon", "...": "..." },
        { "quantity": 70,  "lotSerial": "asyncdemo1-FIL-001", "status": 0, "name": "Salmon Fillet", "...": "..." }
      ],
      "containers": [], "directShipFallback": null, "externalShipmentFailure": null, "documentsNotAttached": null
    },
    {
      "id": "01a1e26b-56d8-7a4a-8227-26a347696592",
      "externalEventId": "asyncdemo1-SHP-001",
      "type": "Ship",
      "status": "Created",
      "eventDate": "2026-11-10T14:00:00+00:00",
      "productInstances": [
        { "quantity": 50, "lotSerial": "asyncdemo1-FIL-001", "status": 0, "name": "Salmon Fillet", "...": "..." }
      ],
      "containers": [], "directShipFallback": null, "externalShipmentFailure": null, "documentsNotAttached": null
    }
  ],
  "locations": [
    { "id": "01a1e26b-50e9-7181-b50d-083af3479625", "status": "Created" },
    { "id": "01a1e26b-51dc-74aa-bbff-c5456dddf6b9", "status": "Created" }
  ],
  "products": [
    { "id": "01a1e26b-5238-7d96-94a8-fb7666bceb66", "status": "Created" },
    { "id": "01a1e26b-5276-7674-80ca-1e294b553b81", "status": "Created" }
  ],
  "errors": [],
  "validations": []
}

Read it the same way as a sync response (see Event Responses):

  • Check each result[].status (Created / Updated / Skipped), matched to your externalEventId.
  • On Ship events, check directShipFallback. A non-null value means the event was created even though inventory was missing.
  • Check documentsNotAttached, externalShipmentFailure, errors and validations.

In the sandbox, jobs moved from submitted to Completed or Failed in about 1–3 seconds.


How a Batch Fails

One Bad Event Fails the Whole Batch

Each batch is processed as one transaction. If any event fails a business rule, the job is Failed and no event in the batch is committed, including the valid ones.

Example: the batch from Example: Three Dependent Events in One Call, but the Ship refers to a lot that doesn't exist (FIL-999 instead of FIL-001):

{ "$type": "ship", "Id": "asyncdemo2-SHP-001",
  "ShipFromLocation": { "Id": "asyncdemo2_plant" },
  "ShipToLocation":   { "Id": "asyncdemo1_buyer_dc" },
  "ProductInstances": [ { "Quantity": 50, "LotSerial": "asyncdemo2-FIL-999", "Product": { "Id": "asyncdemo2_salmon_fillet" } } ],
  "DirectShip": false,
  "EventTime": "2026-11-10T14:00:00", "EventTimeZone": "+00:00" }

Submitting it still returns HTTP 200:

{ "result": "Success", "correlationId": "bc5243cd-2eaf-4fa9-9445-8febd914160c", "validations": [] }

The job shows Failed:

{
  "jobId": "bc5243cd-2eaf-4fa9-9445-8febd914160c",
  "name": "events",
  "status": "Failed",
  "startedAt": "2026-11-16T03:34:28.702253Z",
  "completedAt": "2026-11-16T03:34:29.698485Z",
  "error": "{"title":"Product instance not found: LotSerial: (asyncdemo2-FIL-999), ProductId: (asyncdemo2_salmon_fillet) on location asyncdemo2_plant before 2026-11-10 14:00:00","status":422,"errorDetails":[{"eventId":"asyncdemo2-SHP-001","message":"Product instance not found: ..."}]}",
  "success": null
}

The error string, parsed:

{
  "title": "Product instance not found: LotSerial: (asyncdemo2-FIL-999), ProductId: (asyncdemo2_salmon_fillet) on location asyncdemo2_plant before 2026-11-10 14:00:00",
  "status": 422,
  "errorDetails": [
    { "eventId": "asyncdemo2-SHP-001", "message": "Product instance not found: LotSerial: (asyncdemo2-FIL-999), ..." }
  ]
}
  • errorDetails[].eventId is your event Id and tells you which event to fix.
  • status inside the error is the HTTP code the sync endpoint would have returned.
  • The valid Commission and Transform in this batch were not created.

Failures Caught at Submit (No Job Is Created)

Some problems are rejected before anything is queued. You get a non-200 response and no correlationId. Handle these exactly like sync errors.

CaseHTTPResponse returned by the sandbox
Missing X-API-KEY header400{"title":"One or more validation errors occurred.","status":400,"errors":{"X-API-KEY":["The apiKey field is required."]}, "traceId":"00-85e1…"}
Malformed JSON400{"title":"One or more validation errors occurred.","status":400,"errors":{"":["Expected start of a property name or value, but instead reached end of data. Path: $.Events[0] …"],"request":["The request field is required."]}, "traceId":"…"}
Wrong Content-Type (e.g. text/plain)415Empty body
"Events": []422{"title":"Events must contain at least one event.","status":422,"errorDetails":[{"eventId":null,"message":"Events must contain at least one event."}], "traceId":"…"}
Quantity of 0422{"title":"Quantity must be greater than 0","status":422,"errorDetails":[{"eventId":"asyncdemo3-COM-001","message":"Quantity must be greater than 0"}], "traceId":"…"}