Console
CloudStore

Merge

Apply partial, atomic updates to an existing object without resending the whole thing. Use this instead of set.php whenever more than one user or device can write to the same cloudkey at once.

POST /api/cloudstore/merge.php
Requires Authorization: AppID:AppKey + user token

Request body

FieldTypeRequiredDescription
tokenstringrequiredUser session token
cloudkeystringrequiredKey to modify
opsarrayrequired1 to 25 operations, applied in order, on the server
create_if_missingbooloptionalDefault true; set false to get 404 instead of auto-creating an empty object
owner_useridintoptionalID of another user who authorized your email via share.php. If omitted, operates on the token owner's own CloudStore

Operations (ops)

Each item is an object with an op and a path. path uses dot notation to reach nested keys — e.g. "items.item_42.qty".

opExtra fieldsEffect
setvalueSets the value at path, replacing (or creating) it
incrementdeltaAdds delta to the current number at path. Treated as 0 if it doesn't exist yet
appendvaluePushes value onto the array at path. Creates a new array if it doesn't exist
removeRemoves the key at path

Example

POST /api/cloudstore/merge.php
Authorization: com.myapp:MyAppKey12345678901234
Content-Type: application/json

{
  "token": "USER_TOKEN",
  "cloudkey": "item-42",
  "ops": [
    { "op": "increment", "path": "qty", "delta": -1 },
    { "op": "set", "path": "last_moved_at", "value": "2026-08-07" }
  ]
}

Success response 200

{
  "success": true,
  "message": "Cloud data merged successfully.",
  "cloudkey": "item-42",
  "dataobject": { "qty": 6, "last_moved_at": "2026-08-07" }
}

The response already returns the resulting dataobject — no need to call get.php afterward to see the new value.

How it stays safe under concurrency

The read, operation, and write happen atomically on the server against the most recent value of that cloudkey — never against a copy the client might have in memory. Two merge.php calls for the same cloudkey arriving at the same time are processed one after the other, never overwriting each other's result. Concurrent merge.php and set.php calls on the same key are also serialized against each other — but remember that set.php, when its turn comes, still replaces the entire object.

Errors

CodeMessage
400Missing required parameters 'cloudkey' and 'ops' (array).
400'ops' must contain between 1 and 25 operations.
400Invalid operation. Allowed: set, increment, append, remove
404Data not found for the specified cloudkey and create_if_missing is false.