Newer Version Available
Platform Event Schema by Schema ID
Syntax
- URI
- /services/data/vXX.X/event/eventSchema/schemaId
- Available since release
- 40.0
- Formats
- JSON
- HTTP methods
- GET
- Authentication
- Authorization: Bearer token
- Parameters
-
Parameter Description payloadFormat (Optional query parameter. Available in API version 43.0 and later.) The format of the returned event schema. This parameter can take one of the following values. - EXPANDED—The JSON representation of the event schema, which is the default format when payloadFormat is not specified in API version 43.0 and later.
- COMPACT—A format that adheres to the open-source Apache Avro specification for the record complex type (see Apache Avro Format). Subscribers use the compact schema format to deserialize compact events received in binary form.
Error Codes
| 400 Bad Request | Description |
|---|---|
| In API version 43.0 and later | The request was formatted incorrectly—an invalid value was passed for the payloadFormat parameter in the URI. |
| In API version 42.0 and earlier | The request was formatted incorrectly—the payloadFormat parameter was passed in the URI but this API version doesn’t support this parameter. |
Examples for API Version 43.0 and Later
This URI gets the schema of a platform event whose schema ID is 5E5OtZj5_Gm6Vax9XMXH9A. This schema ID is a sample ID. Replace it with a valid schema ID for your event.
1/services/data/v54.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9AOr:
1/services/data/v54.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9A?payloadFormat=EXPANDEDIn API version 43.0 and later, the response format is the JSON representation of the event schema by default. The returned response looks like the following in API version 54.0.
1{
2 "name" : "Low_Ink__e",
3 "namespace" : "com.sforce.eventbus",
4 "type" : "expanded-record",
5 "fields" : [ {
6 "name" : "data",
7 "type" : {
8 "type" : "record",
9 "name" : "Data",
10 "namespace" : "",
11 "fields" : [ {
12 "name" : "schema",
13 "type" : "string"
14 }, {
15 "name" : "payload",
16 "type" : {
17 "type" : "record",
18 "name" : "Payload",
19 "doc" : "",
20 "fields" : [ {
21 "name" : "CreatedDate",
22 "type" : "string",
23 "doc" : "CreatedDate:DateTime"
24 }, {
25 "name" : "CreatedById",
26 "type" : "string",
27 "doc" : "CreatedBy:EntityId"
28 }, {
29 "name" : "Printer_Model__c",
30 "type" : [ "null", "string" ],
31 "doc" : "Data:Text",
32 "default" : null
33 }, {
34 "name" : "Serial_Number__c",
35 "type" : [ "null", "string" ],
36 "doc" : "Data:Text",
37 "default" : null
38 }, {
39 "name" : "Ink_Percentage__c",
40 "type" : [ "null", "double" ],
41 "doc" : "Data:Double",
42 "default" : null
43 } ]
44 }
45 }, {
46 "name" : "event",
47 "type" : {
48 "type" : "record",
49 "name" : "Event",
50 "fields" : [ {
51 "name" : "replayId",
52 "type" : "long"
53 } ]
54 }
55 } ]
56 }
57 }, {
58 "name" : "channel",
59 "type" : "string"
60 } ]
61}To get the compact (Apache Avro) format, use the following URI.
1/services/data/v54.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9A?payloadFormat=COMPACTThe returned response for the compact format looks like the following in API version 54.0.
1{
2 "name" : "Low_Ink__e",
3 "namespace" : "com.sforce.eventbus",
4 "doc" : "54.0",
5 "type" : "record",
6 "fields" : [ {
7 "name" : "CreatedDate",
8 "type" : "long",
9 "doc" : "CreatedDate:DateTime"
10 }, {
11 "name" : "CreatedById",
12 "type" : "string",
13 "doc" : "CreatedBy:EntityId"
14 }, {
15 "name" : "Printer_Model__c",
16 "type" : [ "null", "string" ],
17 "doc" : "Data:Text",
18 "default" : null
19 }, {
20 "name" : "Serial_Number__c",
21 "type" : [ "null", "string" ],
22 "doc" : "Data:Text",
23 "default" : null
24 }, {
25 "name" : "Ink_Percentage__c",
26 "type" : [ "null", "double" ],
27 "doc" : "Data:Double",
28 "default" : null
29 } ],
30 "uuid" : "5E5OtZj5_Gm6Vax9XMXH9A"
31}Example for API Version 42.0 and Earlier
In API version 42.0 and earlier, the response format adheres to the open-source Apache Avro specification for the record complex type.
This URI gets the schema of a platform event whose schema ID is 5E5OtZj5_Gm6Vax9XMXH9A. This schema ID is a sample ID. Replace it with a valid schema ID for your event.
1/services/data/v42.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9AThe returned response looks like the following in API version 42.0.
1{
2 "name" : "Low_Ink__e",
3 "namespace" : "com.sforce.eventbus",
4 "doc" : "42.0",
5 "type" : "record",
6 "fields" : [ {
7 "name" : "CreatedDate",
8 "type" : "long",
9 "doc" : "CreatedDate:DateTime"
10 }, {
11 "name" : "CreatedById",
12 "type" : "string",
13 "doc" : "CreatedBy:EntityId"
14 }, {
15 "name" : "Printer_Model__c",
16 "type" : [ "null", "string" ],
17 "doc" : "Data:Text",
18 "default" : null
19 }, {
20 "name" : "Serial_Number__c",
21 "type" : [ "null", "string" ],
22 "doc" : "Data:Text",
23 "default" : null
24 }, {
25 "name" : "Ink_Percentage__c",
26 "type" : [ "null", "double" ],
27 "doc" : "Data:Double",
28 "default" : null
29 } ],
30 "uuid" : "5E5OtZj5_Gm6Vax9XMXH9A"
31}If you don’t have the schema ID, you can get the schema by supplying the platform event name. Make a GET request to /services/data/vXX.X/sobjects/eventName/eventSchema. See Platform Event Schema by Event Name.
Apache Avro Format
- name is the name of the platform event.
- namespace corresponds to com.sforce.eventbus.
- 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. When the field is not present, the value is default.
- doc is the field data type. This field is intended for internal use. For example, the data type information is used to convert DateTime fields from long to DateTime. We recommend that you don't rely on this field's value because it might change in the future.
The response also includes the uuid field, which contains the schema’s ID. The ID is the MD5 fingerprint of the normalized Avro schema encoded as a base-64 URL variant. You can append this ID to the /vXX.X/event/eventSchema/ URI to retrieve the schema.