Use this endpoint to modify specific keys within the JSON object structure, you deliver a series of instructions that perform different functions over the defined dot separated keys for the provided modifier values. You can even reference another key within the either the same mossByte object as your new value or even reference a different mossByte object by defining its {read_key} along with the {object_key}
Attention: The Modify endpoint is currently free for all to use but soon will be part of our paid model which allows extra functionality beyond POST, GET, PUT and DELETE. We encourage you to test out this function and know that we are wanting to look for a simple and low price paid model for this feature.
You provide the {admin_key} in the URI, this validates your access and looks up the mossByte record.
Request ( BODY )
key |
required |
description |
rollback |
optional |
If set to true then any single error with an instruction will cause the whole stack of instructions to fail and roll back to their original state. ( some of the dynamic values do not fail and instead just return blanks ) |
instructions |
yes |
Here you provide a json structured array of instructions, see below for examples and for a full list of functions and behaviours scroll to the bottom. |
Functions
function |
parameters |
behaviour |
set |
key: {string|int} value: {string|int|float|bool|array|object} |
key's value gets overwritten with new defined value |
unset |
key: {string|int} |
key gets overwritten with defined value |
append |
key: {string|int} value: {string|int|float} |
key gets defined value added to the end of key's existing value |
prepend |
key: {string|int} value: {string|int|float} |
key gets defined value added to the start of key's existing value |
addition |
key: {string|int} value: {int|float} |
key gets defined value mathematically added to the key's existing value |
subtract |
key: {string|int} value: {int|float} |
key gets defined value mathematically subtracted off the key's existing value |
multiply |
key: {string|int} value: {int|float} |
key gets defined value mathematically multiplied to the key's existing value |
divide |
key: {string|int} value: {int|float} |
key gets defined value mathematically divided on the key's existing value |
toggle |
key: {string|int} |
if key is of type boolean then this will change the state of the key to its opposite state |
yesterday |
key: {string|int} value: {timezone} ( optional, default UTC ) |
key gets set to the current date and time for yesterday based on the defined or default timezone |
now |
key: {string|int} value: {timezone} ( optional, default UTC ) |
key gets set to the current date and time for now based on the defined or default timezone |
tomorrow |
key: {string|int} value: {timezone} ( optional, default UTC ) |
key gets set to the current date and time for tomorrow based on the defined or default timezone |
seconds minutes hours days weeks months years |
key: {string|int} value: {int} |
if key is of date and/or time following a parsable format, then the defined number is added to the keys parsed date and time as additional units. ( this supports signed values so you can add a negative integer ) |
array:clear |
key: {string|int} |
the value defined at the key is cleared to be an empty array, regardless of the original value you will get an empty array. |
array:add |
key: {string|int} subkey: {string|int} value: {string|int|float|bool|array|object} |
the value will be set against the subkey position within the defined keys array |
array:remove |
key: {string|int} subkey: {string|int} |
the subkey will be removed from the primary key's array |
array:prepend |
key: {string|int} value: {string|int|float|bool|array|object} |
the defined value will be prepended to the array |
array:append |
key: {string|int} value: {string|int|float|bool|array|object} |
the defined value will be appended to the array |
array:slice |
key: {string|int} offset: {int} ( optional if length ) length: {int} ( optional if offset ) |
this will slice the array from the offset position ( or zero index ) for the length ( or remainder ) of the items in the array. |
array:sort |
key: {string|int} direction: {asc|desc} ( optional, default asc ) mode: {default|key|subkey} ( optional, default to value) |
this will sort an array ( for mode key or default value ) or an object ( for mode subkey ) by the subkey values in the direction you define ( asc or desc ) |
Response ( BODY )
key |
description |
status |
Indicates the overall requests success status as a boolean value. |
message |
Indicates any issues if the returned status is not true. |
data.instructions |
This will be the original list less the values and with a status boolean indicator of their success. Reason keys will exist when the status is not true. |