Newer Version Available

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

Platform Event Schema by Schema ID

Gets the definition of a platform event in JSON format for a given schema ID.

Syntax

URI
/vXX.X/event/eventSchema/Schema_ID
Available since release
40.0
Formats
JSON
HTTP methods
GET
Authentication
Authorization: Bearer token

Example

This URI gets the schema of a platform event whose schema ID is dffQ2QLzDNHqwB8_sHMxdA. This schema ID is a sample ID. Replace it with a valid schema ID for your event.

1/services/data/v42.0/event/eventSchema/dffQ2QLzDNHqwB8_sHMxdA

The returned response looks like the following.

1{
2  "name" : "Low_Ink__e",
3  "namespace" : "com.salesforce.event.org00DD00000008Xay",
4  "type" : "record",
5  "fields" : [ {
6    "name" : "CreatedDate",
7    "type" : "string"
8  }, {
9    "name" : "CreatedById",
10    "type" : "string"
11  }, {
12    "name" : "Printer_Model__c",
13    "type" : [ "null", "string" ],
14    "default" : null
15  }, {
16    "name" : "Serial_Number__c",
17    "type" : [ "null", "string" ],
18    "default" : null
19  }, {
20    "name" : "Ink_Percentage__c",
21    "type" : [ "null", "double" ],
22    "default" : null
23  } ],
24  "uuid" : "dffQ2QLzDNHqwB8_sHMxdA"
25}
The fields in the returned response adhere to the open-source Apache Avro specification for the record complex type (see Avro Records in the Apache Avro specification). Note the following:
  • name is the name of the platform event.
  • namespace qualifies the event name and is in the format com.salesforce.event.{orgId}.
  • type is the Avro complex type.
  • fields is a JSON array containing the fields of the platform event. For each field, type indicates that the field can be either null or have a value of the specified type. Also, default is a default value for the field when the field is not present.

The response contains one more field, uuid, which contains the schema ID that you appended to the request URI.

The ReplayId standard field isn’t returned in the schema because the system generates it after events are published.

If you change the definition of a platform event, the schema ID for this platfom event changes.

Note

If you don’t have the schema ID, you can get the schema by supplying the platform event name. Make a GET request to /vXX.X/sobjects/Platform_Event_Name__e/eventSchema. See Platform Event Schema by Event Name.