Updating topics

You can set and update the value of a topic with the REST API.

Set topic value API

Endpoint

https://api.diffusion.cloud/topics/set

Content-type

application/json

Method

POST

curl --include                                                          \
     --request POST                                                     \
     --url https://api.diffusion.cloud/topics/set                       \
     --header 'authorization: Bearer <TOKEN>'                           \
     --header 'content-type: application/json'                          \
     -d '{"path":"my-topic", "type":"json",  "value": {"foo": "bar"}}'
Set topic value parameters
Parameter Optional? Default Description

path

No

The Diffusion topic path as a string.

value

No

The value to set the topic to.

type

Yes

json

The type of topic. This can be either json or string.

Set topic value response status
Code Description

200

The topic was updated successfully (or already has the value supplied).

400

There was a problem updating the topic due to the parameters supplied. See message for more details

500

There was an unexpected problem updating the topic. See message for more details

Updating a topic that may not exist

You can set the value of a topic, even if it doesn’t exist with the REST API. If no topic exists, one will be created and set to the value specified. If a compatible topic already exists, the topic will be updated to the new value.

In order to update an already existing topic, the topic type and properties in the request must be compatible with the existing topic.
Add and set topic value API

Endpoint

https://api.diffusion.cloud/topics/addAndSet

Content-type

application/json

Method

POST

curl --include                                              \
     --request POST                                         \
     --url https://api.diffusion.cloud/topics/addAndSet     \
     --header 'authorization: Bearer <TOKEN>'               \
     --header 'content-type: application/json'              \
     -d '{"path":"my-topic",
          "type":"json",
          "properties":{ "VALIDATE_VALUES":"true" },
          "value":{"foo": "bar"},
         }'
Add and set topic value parameters
Parameter Optional? Description

path

No

The path at which the topic must be added.

value

No

The value to set the topic to.

type

Yes

The topic type. The default value is json.

properties

Yes

A map of topic properties. The default value is {}.

Add and set topic value response status
Code Description

200

The topic was added (or a topic already exists), and its value was set successfully.

400

There was a problem adding the topic due to the parameters supplied. See message for more details.

500

There was an unexpected problem adding the topic. See message for more details.