update-user
Method: PUT
Path: /auth/user/{id}
Tags: Users
Summary
Update a user
Description
Updates the user's profile and their customer's data. Returns the updated User object. metadata merges into the customer's metadata and attributes sets attribute values, as PUT /auth/user/\{id\}/attributes does; any user of the customer may send them. business and customer_group_id are for the primary user only. Keep at least one phone number or email address. Notification preferences are validated before any profile changes are saved.
Storefront SDK Usage
SDK Method: sdk.auth.updateUserDetails()
Example:
// Update user profile information
const { data, error } = await sdk.auth.updateUserDetails(
{ id: "01H9XYZ12345USERID" },
{
first_name: "John",
last_name: "Doe",
email: "john.doe@example.com",
phone: "9876543210",
country_code: "+91"
}
);
if (error) {
console.error("Failed to update user:", error.message);
} else {
console.log("User updated successfully:", data.user.first_name);
}TypeScript Definition
"update-user": {
parameters: {
query?: never;
header?: never;
path: {
/** @description user ID */
id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["UpdateUserRequest"];
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the Registration process. */
message: string;
/** @description Indicates whether the request was successful or failure (true for success, false for failure). */
success: boolean;
/** @description An object containing the response content. */
content: {
/** @description An object containing the response content. */
user: components["schemas"]["UserDetail"];
};
};
};
};
/** @description Invalid profile or preferences, no contact remaining, or duplicate contact (duplicate-email, duplicate-phone, duplicate-user). */
400: components["responses"]["AuthBadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
404: components["responses"]["NotFound"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["UpdateUserRequest"] | UpdateUserRequest |
components["schemas"]["UserDetail"] | UserDetail |
components["responses"]["AuthBadRequest"] | AuthBadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["NotFound"] | NotFound |
components["responses"]["InternalServerError"] | InternalServerError |
components["responses"]["GatewayTimeout"] | GatewayTimeout |
Parameters
- id (path): user ID
Request Body
Content Types: application/json
Responses
200
OK
400
Bad request
401
Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.
403
Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.
404
Requested resource not found
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
{
"tags": [
"Users"
],
"operationId": "update-user",
"summary": "Update a user",
"description": "Updates the user's profile and their customer's data. Returns the updated `User` object. `metadata` merges into the customer's metadata and `attributes` sets attribute values, as `PUT /auth/user/{id}/attributes` does; any user of the customer may send them. `business` and `customer_group_id` are for the primary user only. Keep at least one phone number or email address. Notification preferences are validated before any profile changes are saved.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/update-user",
"description": "API reference for the update-user operation"
},
"parameters": [
{
"name": "id",
"in": "path",
"description": "user ID",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateUserRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A descriptive message confirming the success or failure of the Registration process.",
"type": "string"
},
"success": {
"description": "Indicates whether the request was successful or failure (true for success, false for failure).",
"type": "boolean"
},
"content": {
"description": "An object containing the response content.",
"properties": {
"user": {
"description": "An object containing the response content.",
"$ref": "#/components/schemas/UserDetail"
}
},
"required": [
"user"
],
"type": "object"
}
}
}
}
}
},
"400": {
"description": "Invalid profile or preferences, no contact remaining, or duplicate contact (duplicate-email, duplicate-phone, duplicate-user).",
"$ref": "#/components/responses/AuthBadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "updateUser"
}Auto-generated from OpenAPI spec and TypeScript definitions