# User Management
source: https://developer.mastercard.com/user-account-management-service/documentation/use-cases/user-management/index.md

## Enroll User {#enroll-user}

Allows for enrollment of a user and account record into the Rewards system. This use case uses payload encryption.

Householding in a reward program refers to linking multiple accounts from individuals within the same household, such as family members, into a single, shared account. This enables the household to pool, track, and redeem rewards collectively, enhancing the overall value and efficiency of their participation in the loyalty program.

### Pre-requisites {#pre-requisites}

Following are the pre-requisites for the customer to use this endpoint:

Refer to payload encryption in [Use Cases](https://developer.mastercard.com/user-account-management-service/documentation/use-cases/index.md).

### Sequence Diagram {#sequence-diagram}

Diagram enrollment

##### Following are the execution steps: {#following-are-the-execution-steps}

1. The cardholder signs into the customer application.
2. The customer authenticates the cardholder.
3. The customer sends an encrypted request to the User Account Management for enrollment.
   * The enrollment request requires the following mandatory input parameters:
     * companyIca - Interbank Card Association number assigned by Mastercard to the financial institution or partner.
     * userId - Unique identifier for the user.
     * userIdType - Identifier type for the given user.
     * accountId - The unique identifier for the given account.
     * accountIdType - Identifier type for the given account.
     * status - Status of the user's account.
     * productCode - The account's associated reward product identifier.
     * programIdentifier - Program identifier for the program in which the cardholder is enrolled.
4. The Mastercard API Gateway validates the customer's information and routes the request to the User Account Management in the case of a valid customer.
5. The User Account Management Service validates the encrypted request received through the `/users` endpoint.
6. The User Account Management Service enrolls the user.
7. The User Account Management Service sends a response with user details (200).
8. The User Account Management Service sends a response with a status code of 4xx/5xx in case of an invalid request.

You receive an error response for an invalid request or any missing request parameter. In that case, you need to update the input and perform step 3 again.
Note: This call enrolls both a user and their account. It is not possible to add a new user without an account.

### Endpoint {#endpoint}


API Reference: `POST /users`

## Update User {#update-user}

This use case is used when a user wants to update personal information for currently enrolled cardholders, including their name, contact information, security question, and more.

### Sequence Diagram {#sequence-diagram-1}

Diagram update-user

##### Following are the execution steps: {#following-are-the-execution-steps-1}

1. The cardholder signs into the customer application.
2. The customer authenticates the cardholder.
3. The customer sends an encrypted request to the User Account Management for account details.
   * The request for updating user details requires the following mandatory input parameters:
     * userId - Unique identifier for the user.
     * userIdType - Identifier type of the user.
4. The Mastercard API Gateway validates the customer's information and routes the request to the User Account Management in the case of a valid customer.
5. The User Account Management Service validates the encrypted request received through the `/users` endpoint.
6. The User Account Management Service updates the user details.
7. The User Account Management Service sends a response with a successfully updated user message (200).
8. The User Account Management Service sends a response with a status code of 4xx/5xx in case of an invalid request.

You will receive an error response for an invalid request or any missing request parameter. In that case, you need to update the input and perform step 3 again.

### Endpoint {#endpoint-1}


API Reference: `PUT /users`

## Retrieve User {#retrieve-user}

This use case is used when a user wants to retrieve a cardholder's information, including their name, address, verification questions, communication preferences, and more. Each user can have multiple accounts.

### Sequence Diagram {#sequence-diagram-2}

Diagram get-user

##### Following are the execution steps: {#following-are-the-execution-steps-2}

1. The cardholder signs into the customer application.
2. The customer authenticates the cardholder.
3. The customer sends a signed request to the User Account Management for user details.
   * The request for user details requires the following mandatory request parameters:
     * userId - The unique identifier for the given user.
4. The Mastercard Network API Gateway authenticates and authorizes the customer and routes the request to the User Account Management in the case of a valid customer.
5. The User Account Management Service validates the request parameters received through the `/users/{id}` endpoint.
6. The User Account Management Service retrieves the user details.
7. The User Account Management Service sends an unencrypted response with user details (200).
8. The User Account Management Service sends an encrypted response with user details (200), if the request has optional query parameter `include_verification_details` set to true and if the cardholder needs to be authenticated with verification questions.
9. The User Account Management Service sends a response with a status code of 4xx/5xx in case of an invalid request.

You will receive an error response for an invalid request or any missing request parameter. In that case, you need to update the input and perform step 3 again.
Note: Use the Mastercard encryption keys downloaded from the developer dashboard to decrypt the response payload. Refer to [Tutorials and Guides](https://developer.mastercard.com/user-account-management-service/documentation/tutorials-and-guides/index.md) for details.

### Endpoint {#endpoint-2}


API Reference: `GET /users/{id}`

## Verify User {#verify-user}

This use case is used when a user wants to verify the information based on the security questions and answers sent in the request.

### Sequence Diagram {#sequence-diagram-3}

Diagram verify-user

##### Following are the execution steps: {#following-are-the-execution-steps-3}

1. The cardholder signs into the customer application.
2. The customer authenticates the cardholder.
3. The customer sends an encrypted request to the User Account Management for verifying user details.
   * The request for user details requires the following mandatory request parameters:
     * userId - The unique identifier for the given user.
     * user_id_type - Determines the type of user or account identification.
   * The request includes the body with the following parameters:
     * code - User verification question.
     * answer - Answer to the User verification question.
4. The Mastercard Network API Gateway authenticates and authorizes the customer and routes the request to the User Account Management in the case of a valid customer.
5. The User Account Management Service validates the request parameters received through the `/users/{id}/verifications` endpoint.
6. The User Account Management Service retrieves the user details and verifies the user based on the security questions code and answers sent in the request.
7. The User Account Management Service sends a response with a successfully verified user (200).
8. The User Account Management Service sends a response with a status code of 4xx/5xx in case of an invalid request.

You will receive an error response for an invalid request or any missing request parameter. In that case, you need to update the input and perform step 3 again.
Note: Use the Mastercard encryption keys downloaded from the developer dashboard to decrypt the response payload. Refer to [Tutorials and Guides](https://developer.mastercard.com/user-account-management-service/documentation/tutorials-and-guides/index.md) for details.

### Endpoint {#endpoint-3}


API Reference: `GET /users/{id}/verifications`

Note: For more information about the error codes, refer to the [Code and Formats](https://developer.mastercard.com/user-account-management-service/documentation/code-and-formats/index.md) section.
