🔌 Base endpoint: /mockoon-admin/events
This endpoint allows you to subscribe to real-time events from your mock server. It uses the Server-sent events (SSE) protocol to send the events in real-time.
To subscribe to the events, call the following endpoint:
GET/mockoon-admin/eventsmaxlogs (optional): The maximum number of logs to retrieve upon connection. If not specified, all logs will be sent, limited by the server's configuration.Example request:
CopyGET /mockoon-admin/events?maxlogs=100
Both header and query parameter can be used to provide the admin API token:
CopyGET /mockoon-admin/events?maxlogs=100&token=mytoken Authorization: Bearer mytoken
The events are sent in the JSON format:
Copydata: {"event":"{EVENT_NAME}","{DATA_PROPERTY}":...}
The event names and properties are following the same structure as the MockoonServer events. Currently, the following events are sent:
transaction-complete: sent when a transaction is completed. Contains the transaction data in a transaction property.data-bucket-processed: sent when the data buckets are processed when launching the server. Contains the data buckets statuses in a dataBuckets property.Example of a transaction complete (log) event:
Copy{ "event": "transaction-complete", "transaction": { "request": { "method": "get", "urlPath": "/test", "route": "/test", "params": [], "query": "", "queryParams": {}, "body": "", "headers": [ { "key": "accept", "value": "*/*" }, { "key": "accept-encoding", "value": "gzip, br, deflate" }, { "key": "Authorization", "value": "Bearer [REDACTED]" } ] }, "response": { "statusCode": 200, "statusMessage": "OK", "headers": [{ "key": "content-type", "value": "application/json; charset=utf-8" }], "body": "" }, "routeResponseUUID": "24571b2f-25ce-4107-9bc7-e24913d21fc4", "routeUUID": "1803af89-c34c-45ac-a019-e856f137e3b2", "proxied": false, "timestampMs": 1741706443013 } }
The data in the transaction property is following the Transaction model similar to the one used in the /mockoon-admin/logs endpoint.
Upon connection, the server will send the last maxlogs transactions (if specified) and then continue to send new transactions as they are completed.
💡 Transaction logs returned by this endpoint and the GET /logs endpoint have known-sensitive headers redacted (authorization, proxy-authorization, cookie, set-cookie, x-api-key, api-key, x-auth-token). For authorization / proxy-authorization, the auth scheme is preserved (e.g. Bearer [REDACTED]). Request and response bodies are not modified.
This event is triggered when the data buckets are processed during the server launch. It contains details about the statuses of the data buckets in a dataBuckets property:
Copy{ "event": "data-bucket-processed", "dataBuckets": [ { "uuid": "3b95903c-4291-4cee-bcf3-824e6793b8a7", "id": "jb18", "name": "data 1", "parsed": true, "validJson": true }, { "uuid": "7b5ad631-1936-4b37-9334-2bad9fb97c88", "id": "fhcj", "name": "data 2", "parsed": true, "validJson": true } ] }
This event is also re-emitted every time a new client subscribes to the events.