---
title: "Update user by ID"
method: PUT
path: "/users/{id}"
tags: ["Users"]
---

# Update user by ID

`PUT /users/{id}`

## Path parameters

- `id` string, required — MongoDB ObjectId represented as a hexadecimal string

## Request body

- User
  - `_id` string — MongoDB ObjectId represented as a hexadecimal string
  - `username` string
  - `password` string
  - `email` string, email
  - `role` string
  - `role_id` string — MongoDB ObjectId represented as a hexadecimal string
  - `root_admin_role` boolean
  - `created_at` string, date-time
  - `updated_at` string, date-time
  - `created_by` string — MongoDB ObjectId represented as a hexadecimal string
  - `updated_by` string — MongoDB ObjectId represented as a hexadecimal string

## Response `200`

User updated successfully

- object
  - `code` integer
  - `message` string
  - `data` object
    - `_id` string — MongoDB ObjectId represented as a hexadecimal string
    - `username` string
    - `password` string
    - `email` string, email
    - `role` string
    - `role_id` string — MongoDB ObjectId represented as a hexadecimal string
    - `root_admin_role` boolean
    - `created_at` string, date-time
    - `updated_at` string, date-time
    - `created_by` string — MongoDB ObjectId represented as a hexadecimal string
    - `updated_by` string — MongoDB ObjectId represented as a hexadecimal string

## Other responses

- `404` — User not found

## Changes

- **2025-03-03** `14e4eafea538` — 1 breaking, 3 warning, 1 info
  - the response's body type/format changed from `object`/`` to ``/`` for status `200`
  - removed the optional property `code` from the response with the `200` status
  - removed the optional property `data` from the response with the `200` status
  - removed the optional property `message` from the response with the `200` status
  - …1 more
- **2025-03-02** `526e5bdf6dee` — 2 breaking, 17 warning, 18 info
  - request body became required
  - added the pattern `^[0-9a-fA-F]{24}$` to the `path` request parameter `id`
  - removed the request property `data`
  - removed the optional property `data/_id` from the response with the `200` status
  - …33 more

[Change history](https://skmtc.dev/crawlab-team/apis/crawlab-api/changes/users/:id/put.md)

---

[API](https://skmtc.dev/crawlab-team/apis/crawlab-api.md) · [All operations](https://skmtc.dev/crawlab-team/apis/crawlab-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/crawlab-team/crawlab-api/revisions/14e4eafea538/schema)
