Skip to content

PatchUser

Walter Lara edited this page May 27, 2022 · 11 revisions

Patch User

Allows to update an existing User. Only allowed if the requestor is the same as the target User.

Request

URLs:

/v1/users/me

/v1/users/{userId}

Method: PATCH

Path Parameters:

Parameter Type Description
userId string UUID of the User to update (notice that only requester ID is allowed).

Query Parameters: None

Headers:

Authorization: Bearer {accessToken}

Content-Type: application/json

Content:

Field Type Description Requirement Type
firstName string User first name. Optional
lastName string User last name. Optional
nickname string User nickname. Optional
pictureUrl string Valid URL of image file. Optional
role string User role. Optional
genre string User genre. Optional
email string Valid email address. Optional
newPassword string Plaintext password. Optional
confirmPassword string Plaintext password confirmation. Required ony if newPassword specified.
authCode string 2FA Code. Required only if email specified.

Content example:

{
    "firstName": "John",
    "lastName": "Doe",
    "nickname": "Johnny"
    "pictureUrl": "https://somewebsite/john-doe.png",
    "role": "Producer",
    "genre": "Pop",
    "email": "[email protected]",
    "newPassword": "abc1@23",
    "confirmPassword": "abc@123",
    "authCode": "123456"
}

✅ Success Response

Code: 204 NO CONTENT

Headers: None

❌ Error Responses

1. Bad Request

Code: 400 BAD REQUEST

Condition: If a mandatory content field is missing.

Headers:

Content-Type: application/json

Content example:

{
    "code": 400,
    "description": "Bad Request",
    "cause": "Missing authCode"
}

2. Unauthorized

Code: 401 UNAUTHORIZED

Condition: If {accessToken} is invalid or expired.

3. Forbidden

Code: 403 FORBIDDEN

Condition: If 2FA failed because authCode is invalid or if requestor is not the same as target User.

Headers:

Content-Type: application/json

Content example:

{
    "code": 403,
    "description": "Forbidden",
    "cause": "2FA failed"
}

4. Conflict

Code: 409 CONFLICT

Condition: If email is already registered to another user.

Headers:

Content-Type: application/json

Content example:

{
    "code": 409,
    "description": "Conclict",
    "cause": "Already exists: [email protected]"
}

5. Unprocessable Entity

Code: 422 UNPROCESSABLE ENTITY

Condition: If a content field is malformed or invalid.

Headers:

Content-Type: application/json

Content example:

{
    "code": 422,
    "description": "Unprocessable Entity",
    "cause": "Invalid email: john.doe!gmail.com"
}

See Also

Put User (Add New User)

Get User

Delete User

Put User Password (Reset Password)

Clone this wiki locally