Add and set a topic value

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

Required scope(s)

rest-api/add and rest-api/set (both required)

curl --include                                              \
     --request POST                                         \
     --url https://api.diffusion.cloud/topics/addAndSet     \
     --header 'authorization: Apikey <TOKEN>'               \
     --header 'content-type: application/json'              \
     -d '{"path":"my-upserted-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.

Further reading

This endpoint is implemented using the same JavaScript client SDK method as Set a topic value - see TopicUpdate.set in the JavaScript SDK reference for more detail on how a topic specification can be supplied alongside a value to create-or-update in one call.