POST
/
admin
/
users
/
{id}
JS SDK
import Medusa from "@medusajs/js-sdk"

export const sdk = new Medusa({
  baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
  debug: import.meta.env.DEV,
  auth: {
    type: "session",
  },
})

sdk.admin.user.update("user_123", {
  first_name: "John",
  last_name: "Doe",
})
.then(({ user }) => {
  console.log(user)
})
{
"user": {
"id": "<string>",
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"avatar_url": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}

Authorizations

connect.sid
string
cookie
required

Path Parameters

id
string
required

The user's ID.

Query Parameters

fields
string

Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.

Body

application/json

The properties to update in a user.

first_name
string

The user's first name.

last_name
string

The user's last name.

avatar_url
string

The URL of the user's avatar.

metadata
object

The user's metadata, can hold custom key-value pairs.

Response

OK

The user's details.

user
object
required

The user's details.