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.

Send message API

Endpoint

https://api.diffusion.cloud/messages/send

Content-type

application/json

Method

POST

Required scope(s)

rest-api/sendRequestToPath

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"}}'
Send message parameters
Parameter Optional? Default Description

path

No

—

The message path to send the request to.

request

No

—

The request payload.

requestType

Yes

json

The type of the request payload. Either json or string.

responseType

Yes

—

The type of the expected response payload. Either json or string.

Send message response status
Code Description

200

A response was received from a handler registered on the message path.

400

There was a problem sending the request due to the parameters supplied, or no handler was registered for the given path. See message for more details

500

There was an unexpected problem sending the request. See message for more details

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.