Event API (2.0)
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.
Publish Event
Request Body schema: application/json
name required | string [ 1 .. 128 ] characters Name of the event. |
payload required | object Value of the event. This can be a free-form value which we do not inspect. |
requestMetadata | object Metadata associated with the publishing of the event.
Typically this is information about why the event happened. Use |
object (v2EventTarget) 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
|
Responses
Request samples
- Payload
{- "name": "my_app:user_chat",
- "payload": {
- "custom_event": true
}, - "requestMetadata": {
- "example_data": true
}, - "target": {
- "collectionId": "624c6f475887b2894ed87c89",
- "projectId": "624c6f465887b2894ed87c87",
- "layoutId": "713f6e91-3831-4421-a720-1c8084d10525"
}
}
Response samples
- 200
- 404
- default
{- "name": "my_app:user_chat",
- "payload": {
- "custom_event": true
}, - "target": {
- "collectionId": "624c6f475887b2894ed87c89",
- "projectId": "624c6f465887b2894ed87c87",
- "layoutId": "713f6e91-3831-4421-a720-1c8084d10525"
}, - "requestMetadata": {
- "example_data": true
}, - "id": "7f23f76c-1990-4a50-b3b9-d615703c777f"
}
Stream Events
query Parameters
correlationId | string Optional value to tag any return values with. This can be any string-based value that your are able to track. |
subscribe.name required | string Event name to subscribe to for custom events.
This can be a wildcard |
subscribe.target.collectionId | string Subscribe to events in a given collection. |
subscribe.target.projectId | string Subscribe to events in a given project. |
subscribe.target.layoutId | string <uuid> Stream events to a specific layout. Note: when specified, collection_id and project_id are implictly defined. If you choose to define them, you they must match the layout. |
unsubscribe.name required | string Event name to subscribe to for custom events.
This can be a wildcard |
unsubscribe.target.collectionId | string Subscribe to events in a given collection. |
unsubscribe.target.projectId | string Subscribe to events in a given project. |
unsubscribe.target.layoutId | string <uuid> Stream events to a specific layout. Note: when specified, collection_id and project_id are implictly defined. If you choose to define them, you they must match the layout. |
publish.name required | string Name of the event. |
publish.target.collectionId | string Subscribe to events in a given collection. |
publish.target.projectId | string Subscribe to events in a given project. |
publish.target.layoutId | string <uuid> Stream events to a specific layout. Note: when specified, collection_id and project_id are implictly defined. If you choose to define them, you they must match the layout. |
ping | string Initiate a ping-pong message. |
Responses
Response samples
- 200
- default
{- "result": {
- "correlationId": "7a59c49f-c0bb-4f94-9cbe-73af126dd1ea",
- "sessionId": "0c596f1b-3428-47bb-a673-563211ca0c75",
- "event": {
- "name": "my_app:user_chat",
- "payload": {
- "custom_event": true
}, - "target": {
- "collectionId": "624c6f475887b2894ed87c89",
- "projectId": "624c6f465887b2894ed87c87",
- "layoutId": "713f6e91-3831-4421-a720-1c8084d10525"
}, - "requestMetadata": {
- "example_data": true
}, - "id": "7f23f76c-1990-4a50-b3b9-d615703c777f"
}, - "pong": "string",
- "error": {
- "code": 13,
- "message": "INTERNAL: Something went wrong"
}, - "subscribed": {
- "name": "my_app:user_chat|other_events:*",
- "target": {
- "collectionId": "624c6f475887b2894ed87c89",
- "projectId": "624c6f465887b2894ed87c87",
- "layoutId": "713f6e91-3831-4421-a720-1c8084d10525"
}
}, - "unsubscribed": {
- "name": "my_app:user_chat|other_events:*",
- "target": {
- "collectionId": "624c6f475887b2894ed87c89",
- "projectId": "624c6f465887b2894ed87c87",
- "layoutId": "713f6e91-3831-4421-a720-1c8084d10525"
}
}, - "published": {
- "name": "my_app:user_chat",
- "payload": {
- "custom_event": true
}, - "target": {
- "collectionId": "624c6f475887b2894ed87c89",
- "projectId": "624c6f465887b2894ed87c87",
- "layoutId": "713f6e91-3831-4421-a720-1c8084d10525"
}, - "requestMetadata": {
- "example_data": true
}, - "id": "7f23f76c-1990-4a50-b3b9-d615703c777f"
}, - "reconnectBefore": {
- "reauthenticate": false,
- "beforeTimestamp": "1649179486223"
}
}, - "error": {
- "code": 0,
- "message": "string",
- "details": [
- {
- "@type": "string",
- "property1": null,
- "property2": null
}
]
}
}