HTTP Data API
Legacy HTTP API
Writing: HTTP (Legacy)
ditto provides a robust query engine that allows you to perform various filter operations to carry out traditional create , read , update , and delete (crud) operations for an overview, see ditto basics > docid 1v 23t36jbqegsytqt1yu use the write command to upsert , update , and remove documents from the big peer do not include a find query within a write command in a single operation instead, perform each as separate api calls for instructions, see docid\ vqqyfkwdvy lsez89 qur once changes are made to the big peer, those changes then propagate to all small peers connected to the mesh network write endpoint to access ditto's http api, direct your write requests to the following url endpoint, making sure to replace {app id} with the id ditto generated when you created your app in the portal for instructions on how to get your app id, see docid 67na9lgptqilffugb0y29 https //{app id} cloud ditto live/api/v4/store/write upsert the following snippet demonstrates how to use the curl command to perform a complete upsert operation to explicitly create or replace a document in this example, a friends key contains a register of the array type, alongside ordercount which functions as a counter for more information about registers and counters , see the platform manual > docid 2ys93xtlmb3yi4b4nnoce curl x post 'https //{app id} cloud ditto live/api/v4/store/write' \\ \ header 'content type application/json' \\ \ header 'authorization bearer $api key' \\ \ data raw '{ "commands" \[{ "method" "upsert", "collection" "people", "id" "123abc", "value" { "name" "john", "friends" \["susan"], "ordercount" 5 } }] }' specifying types when invoking upsert , use the valuetypeoverrides payload to create or modify a mutable type, such as a register map or a counter , in your request for example, instead of using the default type, you explicitly specify to create a counter instead in ditto, an array behaves as a register by default this means you do not need to explicitly specify an array as a register in your request for more information, see the platform manual > docid\ lansmjtsczlzvigomk40n curl curl x post 'https //{app id} cloud ditto live/api/v4/store/write' \\ \ header 'content type application/json' \\ \ header 'authorization bearer $api key' \\ \ data raw '{ "commands" \[{ "method" "upsert", "collection" "people", "id" "123abc", "value" { "name" "john", "friends" \["susan"], "ordercount" 5 }, "valuetypeoverrides" { "ordercount" "counter", "friends" "register" } }] }' update subcommands when using update to make changes in the big peer, you can include any of the following subcommands within your update command to perform specific actions subcommand description set sets a specific value for a given field property increment increments the value of a counter replacewithcounter replaces the current value with the counter https //{app id} cloud ditto live/api/v4/store/findbyid remove use the remove command to delete documents from the big peer and all small peers connected in the mesh network once deleted, ditto indicates a document's removal by creating a tombstone document a tombstone contains metadata indicating that the associated data has been removed ditto creates a single tombstone for each document id that matches the specified query to ensure that all small peers connected in the mesh network are aware that the document has been deleted, the tombstone, once created, triggers a change event that propagates across the mesh network as a record of its removal although each tombstone document is not very large, there is no way to evict or remove them, so over time, if a user keeps doing remove operations, tombstones will be an "invisible" source of disk usage with no upper bound for this reason, we strongly encourage the use of evict (combined with a thoughtful subscription and soft delete strategy) instead learn more about docid 2ixfv6yfqikjrobx0cujd for example, the following snippet demonstrates how to remove a document from the people collection where the name field is set to the value of john curl curl x post 'https //{app id} cloud ditto live/api/v4/store/write' \\ \ header 'authorization bearer $api key' \\ \ header 'content type application/json' \\ \ data raw '{ "commands" \[{ "method" "remove", "collection" "people", "query" "name==\\'john\\'" }] }'