Update user metadata
Updates the metadata object stored about the user by doing a shallow merge of the stored and the update JSONs and removing properties set to null on the root level of the update object. The merged object is then reserialized and stored.
e.g.:
-
stored:
{ "preferences": { "theme":"dark" }, "notifications": { "email": true }, "todos": ["example"] } -
update:
{ "notifications": { "sms": true }, "todos": null } -
result:
{ "preferences": { "theme":"dark" }, "notifications": { "sms": true } }
PUT
/appid-{appId}/recipe/user/metadataAuthorization
api-keyAPI key · headerrequiredThe core service API token. If you are using a self-hosted core service and you have not generated a token, you can omit the header.
Header parameters
ridstringcdi-versionstringX.Y of the X.Y.Z CDI version.
Request body
application/jsonuserIduserIdmetadataUpdateuserMetadataUpdateshould be a JSON object (not a JSON literal nor an array)
Responses
200The operation was successful
statusstatusOKAllowed:
OKmetadatauserMetadatashould be a JSON object (not a JSON literal nor an array)
400error code 400
string401error code 401
string404error code 404
string500error code 500
stringTry it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X PUT "/appid-{appId}/recipe/user/metadata" \
-H "api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"userId": "fa7a0841-b533-4478-95533-0fde890c3483",
"metadataUpdate": {
"notifications": {
"sms": true
},
"todos": null
}
}'const response = await fetch("/appid-{appId}/recipe/user/metadata", {
method: "PUT",
headers: {
"api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"userId": "fa7a0841-b533-4478-95533-0fde890c3483",
"metadataUpdate": {
"notifications": {
"sms": true
},
"todos": null
}
})
});import requests
response = requests.put(
"/appid-{appId}/recipe/user/metadata",
headers={
"api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"userId": "fa7a0841-b533-4478-95533-0fde890c3483",
"metadataUpdate": {
"notifications": {
"sms": True
},
"todos": None
}
},
)Response
{
"status": "OK",
"metadata": {
"preferences": {
"theme": "dark"
},
"notifications": {
"email": true
},
"todos": [
"example"
]
}
}"string""Invalid API key""Not Found""Internal Error"