Newer Version Available

This content describes an older version of this product. View Latest

Change Event Message Structure

A change event message has the following structure. All change events contain the same header fields.
1{
2  "data": {
3    "schema": "<schema_ID>", 
4    "payload": {
5      "ChangeEventHeader": {
6         "entityName" : "...",
7         "recordIds" : "...",
8         "changeType" : "...",
9         "changedFields": [...],
10         "changeOrigin" : "...",
11         "transactionKey" : "...",
12         "sequenceNumber" : "...",
13         "commitTimestamp" : "...",
14         "commitUser" : "...",
15         "commitNumber" : "..."
16      }, 
17     "field1":"...",
18     "field2":"...",
19     . . .
20    }, 
21    "event": {
22      "replayId": <replayID>
23    }
24  }, 
25  "channel": "/data/<channel>"
26}

The order of the fields in the JSON event message is not guaranteed. The order is based on the underlying Avro schema that change events are based on. When an event is expanded into JSON format, the order of the fields might not match the schema depending on the client used to receive the event.

Note

To get the full schema of a change event message, make a GET request to the REST API that includes the schema ID sent in the event message:

1/vXX.X/event/eventSchema/<Schema_ID>?payloadFormat=COMPACT

Or make a GET request to this resource:

1/vXX.X/sobjects/<EventName>/eventSchema?payloadFormat=COMPACT

<EventName> is the name of a change event, such as AccountChangeEvent.

The event schema REST API resources are also used for platform events. For more information, see Platform Event Schema by Event Name and Platform Event Schema by Schema ID in the REST API Developer Guide.

Change Event Example

The following event is sent for a new account.

1{
2  "schema": "I8b-dYxvxs5wOtCBr4qsew",
3  "payload": {
4    "ChangeEventHeader": {
5      "entityName": "Account",
6      "changeType": "CREATE",
7      "changedFields": [],
8      "changeOrigin": "com/salesforce/api/soap/47.0;client=SfdcInternalAPI/",
9      "transactionKey": "000177a7-c079-6e50-73af-5af790992cc1",
10      "sequenceNumber": 1,
11      "commitTimestamp": 1564443438000,
12      "commitNumber": 74523894988,
13      "commitUser": "<User_ID>",
14      "recordIds": [
15        "<record_ID>"
16      ]
17    },
18    "Name": "Acme",
19    "Description": "Everyone is talking about the cloud. But what does it mean?",
20    "OwnerId": "<Owner_ID>",
21    "CreatedDate": "2019-07-29T23:37:18.000Z",
22    "CreatedById": "<User_ID>",
23    "LastModifiedDate": "2019-07-29T23:37:18.000Z",
24    "LastModifiedById": "<User_ID>",
25  },
26  "event": {
27    "replayId": 10
28  }
29}