Skip to main content

GRPC

Services

EventService

The event API provides a mechanism for you to subscribe and publish events between your backend services and the composition, as well as receive events from the live and layout api.

Method NameRequest TypeResponse TypeDescription
StreamEventsStreamRequest streamEventsStreamResponse streamStream Events

PublishPublishEventRequestPublishEventResponsePublish Event

Messages

EventTarget

Targetting for an event Event targetting allows you to listen or publish an event against a specific target. You can assume that: When subscribing, you will receive events for the chosen scope and any higher scope that isn't targetted. This means

  • An event published against a layoutId can be listened to by targetting the given layoutId, projectId or collectionId
  • An event published against a collectionId can be subscribed by scoping to any given projectId or layoutId under the collection.
FieldTypeLabelDescription
collection_idstringoptionalSubscribe to events in a given collection.
project_idstringoptionalSubscribe to events in a given project.
layout_idstringoptionalStream events to a specific layout.
Note: when specified, collectionid and project_id are implictly defined. If you choose
to define them, you they _must
match the layout.

EventsStreamError

Indicates an error with a message sent to the Event API. Tie correlation_id on the message sent to the Event API and the correlation_id on the parent message to understand which request this error is for.

FieldTypeLabelDescription
codeint32The GRPC error code for the event.
messagestringA mesasage indicating what the error is.

EventsStreamReconnectRequest

Indicate to the client that they should re-open their connection

FieldTypeLabelDescription
reauthenticateboolWhether the access token needs to be refreshed before reconnecting.
before_timestampstringA timestamp indicating when the connection should be reconnected by.
If you're maintaining multiple connections, you should reconnect at a random interval within this time range.

EventsStreamRequest

Payload sent to the event API

FieldTypeLabelDescription
correlation_idstringoptionalOptional value to tag any return values with. This can be any string-based value
that your are able to track.
subscribeSubscribePayloadSubscribe to a new event.
unsubscribeSubscribePayloadUnsubscribe from an event.
publishPublishEventRequestPublish a new event.
pingstringInitiate a ping-pong message.

EventsStreamResponse

Payload returned from the event API.

FieldTypeLabelDescription
correlation_idstringoptionalOptional value to tag any return values with.
Correlation ID should be used to correlate requests sent down the socket,
enabling you to tie a PUBLISH to a `PUBLISHED``
session_idstringoptionalOptional session id
This is set by sending the SessionId header for any HTTP requests
and the sessionId query parameter for websockets.
eventPublishEventResponseCustom event emitted
pongstringPing payload
errorEventsStreamErrorNon-blocking streaming error
subscribedSubscribePayloadSubscribe to a new event.
unsubscribedSubscribePayloadUnsubscribe from an event.
publishedPublishEventResponsePublish a new event.
reconnect_beforeEventsStreamReconnectRequestInform the client should reoconnect before a timestamp.

PublishEventRequest

Publish a custom event

FieldTypeLabelDescription
namestringName of the event.
payloadgoogle.protobuf.StructValue of the event. This can be a free-form value which we do not inspect.
request_metadatagoogle.protobuf.ValueoptionalMetadata associated with the publishing of the event.
Typically this is information about why the event happened. Use payload for
what the event is.
targetEventTargetoptionalScope the event to a specific target

PublishEventResponse

Response of an event being forwarded to a subscription. note: if this socket is also the publisher, this payload will be sent twice. Once for published and once for event. You can use correlation_id to identify the published event.

FieldTypeLabelDescription
namestringName of the event.
payloadgoogle.protobuf.StructValue of the event.
targetEventTargetoptionalCustom scoping parameters.
request_metadatagoogle.protobuf.ValueoptionalMetadata associated with the publishing of the event
idstringInternal ID of the event.

SubscribePayload

Payload to subscribe or unsubscribe from an event

FieldTypeLabelDescription
namestringEvent name to subscribe to for custom events.
This can be a wildcard my_service:* or multiple events `my_event
targetEventTargetoptionalThe target to subscribe to.

Enums

EventsStreamMessageType

NameNumberDescription
EVENTS_STREAM_MESSAGE_TYPE_UNSPECIFIED0
EVENTS_STREAM_MESSAGE_TYPE_PING1
EVENTS_STREAM_MESSAGE_TYPE_ERROR2
EVENTS_STREAM_MESSAGE_TYPE_SUBSCRIBED3
EVENTS_STREAM_MESSAGE_TYPE_UNSUBSCRIBED4
EVENTS_STREAM_MESSAGE_TYPE_PUBLISHED5

Scalar Value Types (Reference)

.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)