Skip to main content

updateUser

Updates the authenticated user. 🔐 This method requires authorization.

Description​

Updates the authenticated user's data and resolves to true on success.

Only the fields you pass change: form fields are matched by marker, state is merged, and fields you omit keep their values. notificationData is the exception: it replaces the stored object, including the FCM tokens in phonePush, so omit it unless you send every field.

If you change the form field that serves as the login (isLogin in the attribute set), the user's identifier changes too. The API refuses a login that another user already has (400 A user with this login has existed), and you can't change the login of an OAuth account.

.updateUser(

,

);

Parameters schema​

Schema

body(required): IUserBody
Request body.
example:

{
"formIdentifier": "reg",
"authData": [
{
"marker": "email_reg",
"value": "your-email@oneentry.cloud"
},
{
"marker": "password_reg",
"value": "12345"
}
],
"formData": [
{
"marker": "last_name",
"type": "string",
"value": "Username"
}
],
"notificationData": {
"email": "john@example.com",
"phonePush": [
"fcm_token_1234567890abcdefg"
],
"phoneSMS": "+12025550147"
},
"state": {}
}

body.formIdentifier(required): string
Marker of the form.
example: "form_12345"

body.langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).

body.authData: IAuthData[]
Used only to change the password. Pass one entry whose marker is the password field of the auth form and whose value is the new password. Omit it for other updates.
example:

[
{
"marker": "password",
"value": "12345"
}
]

authData.marker(required): string
Marker of the auth form field.
example: "login"

authData.value(required): string
The value of the auth field.
example: "john@example.com"

body.formData: FormDataType | FormDataType[]
One form field object or an array of them. Field values: FormDataType — a value shaped by the field type (a string, a date object, a text object, a list, a file descriptor), not only a string. A file goes in as the descriptor FileUploading.upload returns: these methods do not upload a File/Blob themselves.
example:

[
{
"marker": "first_name",
"type": "string",
"value": "John"
},
{
"marker": "last_name",
"type": "string",
"value": "Doe"
}
]

body.notificationData: object
Notification contacts: email and phone numbers.
example:

{
"email": "john@example.com",
"phonePush": [
"fcm_token_1234567890abcdefg"
],
"phoneSMS": "+12025550147"
}

body.state: object
Custom key-value data stored with the user. Merged one top-level key at a time: a key set to null is removed, other keys replace their stored values (nested objects are replaced whole), and omitted keys are kept.
example:

{
"orderCount": 1
}

langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"

Examples​

Minimal example​


// 1. Sign in
await AuthProvider.(
,
{
{
,
,
},
{
,
}
]
}
);

// 2. Update the user
const body = {
,
{
,
,
}
]
};

const response = await Users.updateUser(body);

Change the password​

authData is used only to change the password. Pass one entry: the password field of the form linked to the auth provider, using that field's marker (here password_reg), and the new password as its value. Omit authData for any other update.

const response = await Users.updateUser({
formIdentifier: "reg",
authData: [{ marker: "password_reg", value: "newPassword123" }],
});

Body examples for different attribute types​

Simple types: "string", "integer", "float"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "last_name",
"type": "string",
"value": "Smith"
}
]
};

const response = await Users.updateUser(body);

"date", "dateTime", "time"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "birthday",
"type": "date",
"value": {
"fullDate": "2024-05-07T21:02:00.000Z",
"formattedValue": "05-07-2024 21:02",
"formatString": "MM-DD-YYYY HH:mm"
}
}
]
};

const response = await Users.updateUser(body);

"text"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "about",
"type": "text",
"value": [
{
"htmlValue": "<p>About me</p>",
"params": {
"isImageCompressed": true,
"editorMode": "html"
}
}
]
}
]
};

const response = await Users.updateUser(body);

"textWithHeader"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "about",
"type": "textWithHeader",
"value": [
{
"header": "Heading",
"htmlValue": "<p>About me</p>",
"params": {
"isImageCompressed": true,
"editorMode": "html"
}
}
]
}
]
};

const response = await Users.updateUser(body);

"image" and "groupOfImages"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "avatar",
"type": "image",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585,
"previewLink": "",
"params": {
"isImageCompressed": true
}
}
]
}
]
};

const response = await Users.updateUser(body);

"file"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "picture",
"type": "file",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585
}
]
}
]
};

const response = await Users.updateUser(body);

"radioButton"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "selector",
"type": "radioButton",
"value": "1"
}
]
};

const response = await Users.updateUser(body);

"list"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "selector",
"type": "list",
"value": [
"1"
]
}
]
};

const response = await Users.updateUser(body);

"entity" (nested list)​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "entity-selector",
"type": "entity",
"value": [
1,
2
]
}
]
};

const response = await Users.updateUser(body);

"timeInterval"​

const body = {
"formIdentifier": "reg",
"formData": [
{
"marker": "interval",
"type": "timeInterval",
"value": [
[
"2025-02-11T16:00:00.000Z",
"2025-02-13T16:00:00.000Z"
]
]
}
]
};

const response = await Users.updateUser(body);

Example response​

true

Usage examples​

A step-by-step walkthrough:

  • Update user: change a user attribute such as the phone number on the authenticated account.

Try it live​

Run this method interactively in the JS SDK sandbox. Connect your Project URL and App Token on first visit, then open:

  • Update user: change a user attribute such as the phone number on the authenticated account.