Newer Version Available
Platform Event Schema by Event Name
| 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. |
Syntax
- URI
- /services/data/vXX.X/sobjects/eventName/eventSchema
- 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 isn’t specified in API version 43.0 and later. The expanded event schema is in the open-source Apache Avro format but doesn’t strictly adhere to the record complex type. For more information about the schema fields, see Apache Avro Format.
- COMPACT—The JSON representation of the event schema that adheres to the open-source Apache Avro specification for the record complex type. For more information about the schema fields, see Apache Avro Format. Subscribers use the compact schema format to deserialize compact events received in binary form.
Examples for API Version 43.0 and Later
This URI gets the schema of a platform event named Low_Ink__e. In API version 43.0 and later, the default response format is the JSON representation of the event schema.
1curl https://MyDomainName.my.salesforce.com/services/data/v61.0/sobjects/Low_Ink__e/eventSchema -H "Authorization: Bearer token"Or:
1curl https://MyDomainName.my.salesforce.com/services/data/v61.0/sobjects/Low_Ink__e/eventSchema?payloadFormat=EXPANDED -H "Authorization: Bearer token"The returned response for the expanded format looks like the following in API version 61.0.
1{
2 "name": "Low_Ink__e",
3 "namespace": "com.sforce.eventbus",
4 "type": "expanded-record",
5 "fields": [
6 {
7 "name": "data",
8 "type": {
9 "type": "record",
10 "name": "Data",
11 "namespace": "",
12 "fields": [
13 {
14 "name": "schema",
15 "type": "string"
16 },
17 {
18 "name": "payload",
19 "type": {
20 "type": "record",
21 "name": "Payload",
22 "doc": "",
23 "fields": [
24 {
25 "name": "CreatedDate",
26 "type": "string",
27 "doc": "CreatedDate:DateTime"
28 },
29 {
30 "name": "CreatedById",
31 "type": "string",
32 "doc": "CreatedBy:EntityId"
33 },
34 {
35 "name": "Printer_Model__c",
36 "type": [
37 "null",
38 "string"
39 ],
40 "doc": "Data:Text:00NRM000001krnv",
41 "default": null
42 },
43 {
44 "name": "Serial_Number__c",
45 "type": [
46 "null",
47 "string"
48 ],
49 "doc": "Data:Text:00NRM000001kro0",
50 "default": null
51 },
52 {
53 "name": "Ink_Percentage__c",
54 "type": [
55 "null",
56 "double"
57 ],
58 "doc": "Data:Double:00NRM000001kro5",
59 "default": null
60 }
61 ]
62 }
63 },
64 {
65 "name": "event",
66 "type": {
67 "type": "record",
68 "name": "Event",
69 "fields": [
70 {
71 "name": "replayId",
72 "type": "long"
73 }
74 ]
75 }
76 }
77 ]
78 }
79 },
80 {
81 "name": "channel",
82 "type": "string"
83 }
84 ]
85}To get the compact (Apache Avro) format, use the following URI.
1curl https://MyDomainName.my.salesforce.com/services/data/v61.0/sobjects/Low_Ink__e/eventSchema?payloadFormat=COMPACT -H "Authorization: Bearer token"The returned response for the compact format looks like the following in API version 61.0.
1{
2 "name": "Low_Ink__e",
3 "namespace": "com.sforce.eventbus",
4 "type": "record",
5 "fields": [
6 {
7 "name": "CreatedDate",
8 "type": "long",
9 "doc": "CreatedDate:DateTime"
10 },
11 {
12 "name": "CreatedById",
13 "type": "string",
14 "doc": "CreatedBy:EntityId"
15 },
16 {
17 "name": "Printer_Model__c",
18 "type": [
19 "null",
20 "string"
21 ],
22 "doc": "Data:Text:00NRM000001krnv",
23 "default": null
24 },
25 {
26 "name": "Serial_Number__c",
27 "type": [
28 "null",
29 "string"
30 ],
31 "doc": "Data:Text:00NRM000001kro0",
32 "default": null
33 },
34 {
35 "name": "Ink_Percentage__c",
36 "type": [
37 "null",
38 "double"
39 ],
40 "doc": "Data:Double:00NRM000001kro5",
41 "default": null
42 }
43 ],
44 "uuid": "5E5OtZj5_Gm6Vax9XMXH9A"
45}Examples 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.
1curl https://MyDomainName.my.salesforce.com/services/data/v42.0/sobjects/Low_Ink__e/eventSchema -H "Authorization: Bearer token"The returned response looks like the following in API version 42.0.
1{
2 "name": "Low_Ink__e",
3 "namespace": "com.sforce.eventbus",
4 "type": "record",
5 "fields": [
6 {
7 "name": "CreatedDate",
8 "type": "long",
9 "doc": "CreatedDate:DateTime"
10 },
11 {
12 "name": "CreatedById",
13 "type": "string",
14 "doc": "CreatedBy:EntityId"
15 },
16 {
17 "name": "Printer_Model__c",
18 "type": [
19 "null",
20 "string"
21 ],
22 "doc": "Data:Text:00NRM000001krnv",
23 "default": null
24 },
25 {
26 "name": "Serial_Number__c",
27 "type": [
28 "null",
29 "string"
30 ],
31 "doc": "Data:Text:00NRM000001kro0",
32 "default": null
33 },
34 {
35 "name": "Ink_Percentage__c",
36 "type": [
37 "null",
38 "double"
39 ],
40 "doc": "Data:Double:00NRM000001kro5",
41 "default": null
42 }
43 ],
44 "uuid": "5E5OtZj5_Gm6Vax9XMXH9A"
45}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 isn’t present, the value is default.
- doc describes the field data type and includes the field ID for custom fields. This field is intended for internal use. For example, Salesforce uses the data type information 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.