# Update user

**Endpoint**

`PUT/v2/user/{id}`

**Link**

{% embed url="<https://stagep.tst-apidmndelss.com/openapi/v2.html#/operations/Users_Update>" %}

### **Request**

#### **Authentication**

An API key is required for authentication. Include it in the `Authorization` header.

* **Header:** `Authorization`
* **Value:** Your API key token

#### **HTTP Method & URL**

* **Method:** `PUT`
* **URL:** `https://stagep.tst-apidmndelss.com/v2/user/{id}`

#### **Path Parameters**

| Parameter | Type     | Description                                  | Required | Example          |
| --------- | -------- | -------------------------------------------- | -------- | ---------------- |
| **`id`**  | `string` | **Unique identifier of the user to update**. | Yes      | `user_abc123def` |

#### **Headers**

| Key             | Value              | Required |
| --------------- | ------------------ | -------- |
| `Authorization` | `Bearer <JWT>`     | Yes      |
| `Accept`        | `application/json` | Yes      |
| `Content-Type`  | `application/json` | Yes      |

#### **Request Body (JSON)**

Include only the fields you want to update. Omitted fields will remain unchanged.

| Field            | Type      | Description                         | Required | Example                |
| ---------------- | --------- | ----------------------------------- | -------- | ---------------------- |
| **`customerId`** | `string`  | **Associated customer identifier**. | No       | `cust_789xyz`          |
| **`password`**   | `string`  | **New login password**.             | No       | `NewSecurePass123!`    |
| **`status`**     | `string`  | **User status** (see values below). | No       | `ACCEPT`               |
| **`is2fa`**      | `boolean` | **2FA enabled status**.             | No       | `true`                 |
| **`name`**       | `string`  | **User's first name**.              | No       | `John`                 |
| **`lastname`**   | `string`  | **User's last name**.               | No       | `Smith`                |
| **`comment`**    | `string`  | **Administrative comments**.        | No       | `Updated contact info` |

**Status Values**

* `NEW` - Registered user
* `READY_FOR_MODERATION` - Ready for review
* `MODERATED` - Under moderation
* `VERIFY` - Verification in progress
* `ACCEPT` - Approved user
* `REJECT` - Rejected user
* `BANNED` - Banned user

**Example Request Body (Partial Update):**

```json
{
  "status": "ACCEPT",
  "name": "John",
  "lastname": "Smith"
}
```

**Example Request Body (Full Update):**

```json
{
  "customerId": "cust_789xyz",
  "password": "NewSecurePass123!",
  "status": "ACCEPT",
  "is2fa": true,
  "name": "John",
  "lastname": "Smith",
  "comment": "Account upgraded to premium"
}
```

***

### **Response (200 OK)**

Returns the updated user object with all current field values.

#### **Response Fields**

**User Object (`item`)**

| Field          | Type      | Description                      | Example                       |
| -------------- | --------- | -------------------------------- | ----------------------------- |
| **`uuid`**     | `string`  | **Unique user identifier**.      | `user_abc123def`              |
| **`username`** | `string`  | **User's login name**.           | `john.smith`                  |
| **`status`**   | `string`  | **Current user status**.         | `ACCEPT`                      |
| **`is2fa`**    | `boolean` | **2FA enabled status**.          | `true`                        |
| **`createAt`** | `string`  | **Original creation timestamp**. | `2024-01-15T10:30:00Z`        |
| **`updateAt`** | `string`  | **Last update timestamp**.       | `2024-03-20T14:22:00Z`        |
| **`name`**     | `string`  | **User's full name**.            | `John Smith`                  |
| **`comment`**  | `string`  | **Administrative comments**.     | `Account upgraded to premium` |

**Example Response:**

```json
{
  "item": {
    "uuid": "user_abc123def",
    "username": "john.smith",
    "status": "ACCEPT",
    "is2fa": true,
    "createAt": "2024-01-15T10:30:00Z",
    "updateAt": "2024-03-20T14:22:00Z",
    "name": "John Smith",
    "comment": "Account upgraded to premium"
  }
}
```

***

### **Examples**

#### **Update User Status (cURL)**

```bash
curl --request PUT \
  --url https://stagep.tst-apidmndelss.com/v2/user/user_abc123def \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer eyJhbGci...wNLGA' \
  --header 'Content-Type: application/json' \
  --data '{
    "status": "ACCEPT"
  }'
```

#### **Update Password and Personal Info**

```bash
curl --request PUT \
  --url https://stagep.tst-apidmndelss.com/v2/user/user_456ghi \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer eyJhbGci...wNLGA' \
  --header 'Content-Type: application/json' \
  --data '{
    "password": "NewSecurePass456!",
    "name": "Jane",
    "lastname": "Doe"
  }'
```

#### **Complete User Profile Update**

```bash
curl --request PUT \
  --url https://stagep.tst-apidmndelss.com/v2/user/user_789jkl \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer eyJhbGci...wNLGA' \
  --header 'Content-Type: application/json' \
  --data '{
    "customerId": "cust_789xyz",
    "status": "ACCEPT",
    "is2fa": true,
    "name": "Robert",
    "lastname": "Wilson",
    "comment": "Enterprise account - priority support"
  }'
```

***

### **Error Responses**

1. **User Not Found**:

   ```json
   { "error": "User not found: user_invalid_id" }
   ```
2. **Invalid Status**:

   ```json
   { "error": "Invalid status value: INVALID_STATUS" }
   ```
3. **Password Complexity Error**:

   ```json
   { "error": "Password does not meet complexity requirements" }
   ```
4. **Unauthorized**:

   ```json
   { "error": "Unauthorized" }
   ```
5. **Customer Not Found**:

   ```json
   { "error": "Customer not found: cust_invalid_id" }
   ```

***

### **Notes**

#### **Update Behavior**

* **Partial update** - only included fields are modified
* **`updateAt`** timestamp is automatically updated
* Some status transitions may have business logic restrictions
* Password changes may require additional verification

#### **Password Requirements**

* Minimum length (typically 8-12 characters)
* Requires uppercase and lowercase letters
* Requires numbers and/or special characters
* Cannot contain username or common patterns

#### **Best Practices**

* Use partial updates to avoid overwriting unchanged fields
* Validate status transitions according to business rules
* Consider user notification for password changes
* Use comments to document reasons for changes

**Common Use Cases**:

* User account moderation and approval
* Password reset operations
* User profile information updates
* Account status management (activation/deactivation)
* 2FA enrollment management

**Status Transition Rules**:

* Some status changes may require additional verification
* Certain statuses may be irreversible
* Business rules may restrict certain transitions

**Security Considerations**:

* Password changes should trigger session invalidation
* Status changes to `BANNED` or `REJECTED` may restrict access immediately
* 2FA enrollment may require user confirmation

Request sample

```postman_json
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE2NCwiZXhwIjoxNzYxNTcyNjY1LCJrZXkiOiI1Y2ZiOGZjN2RmYjk4ZjVkYmIyZTgwNTVkZWFhN2U2Zjk4MzEyYmE3Iiwib3RwX3ZlcmlmaWVkIjpmYWxzZX0.-SZ9Vc_BimN9juZElxhZeMQV5Hbb1WqUY2b8xwOSZLo
userId*: 158a190e-c4a9-4e6c-bf9b-4ef74ae345eb
```

```postman_json
{
  "customerId": "Dnewcvn-euuI-vG0FZCRDjLXS",
  "password": "testpassword",
  "status": "NEW",
  "is2fa": false,
  "name": "111",
  "lastname": "222",
  "comment": "test"
}
```

Response sample

```postman_json
{
  "item": {
    "userId": "158a190e-c4a9-4e6c-bf9b-4ef74ae345eb",
    "username": "testeu@gmail.com",
    "status": "NEW",
    "is2fa": false,
    "createAt": "2025-01-28T12:53:10Z",
    "updateAt": "2025-10-27T13:39:33Z",
    "name": "111",
    "comment": "test"
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.delos.financial/users/update-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
