Send a message
This endpoint uses Diffusion’s request-response messaging feature (see Request-response) to send a message to a message path. This is entirely separate from topics and pub-sub - the message is delivered to a client session that has registered a handler for the path, and its response is returned in the REST API response.
Endpoint |
|
Content-type |
|
Method |
|
Required scope(s) |
|
curl --include \
--request POST \
--url https://api.diffusion.cloud/messages/send \
--header 'authorization: Apikey <TOKEN>' \
--header 'content-type: application/json' \
-d '{"path":"my-message-path", "request":{"foo": "bar"}}'
| Parameter | Optional? | Default | Description |
|---|---|---|---|
|
No |
— |
The message path to send the request to. |
|
No |
— |
The request payload. |
|
Yes |
json |
The type of the request payload. Either |
|
Yes |
— |
The type of the expected response payload. Either |
| Code | Description |
|---|---|
|
A response was received from a handler registered on the message path. |
|
There was a problem sending the request due to the parameters supplied, or no handler was registered for the given path. See |
|
There was an unexpected problem sending the request. See |
Further reading
This endpoint is a thin wrapper around the JavaScript client SDK’s request-response messaging feature - see Messages.sendRequest in the JavaScript SDK reference for more detail, including sending to a specific session or a session filter, options not available through this REST endpoint.