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. |
Endpoint |
|
Content-type |
|
Method |
|
Required scope(s) |
|
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"}
}'
| Parameter | Optional? | Description |
|---|---|---|
|
No |
The path at which the topic must be added. |
|
No |
The value to set the topic to. |
|
Yes |
The topic type. The default value is |
|
Yes |
A map of topic properties. The default value is |
| Code | Description |
|---|---|
|
The topic was added (or a topic already exists), and its value was set successfully. |
|
There was a problem adding the topic due to the parameters supplied. See |
|
There was an unexpected problem adding the topic. See |
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.