# How to call the Update User API source: https://developer.mastercard.com/priceless-planet-carbon-tracker/tutorial/test-cases/step2/index.md ### Update user profiles to maintain up-to-date information {#update-user-profiles-to-maintain-up-to-date-information} The **Update User** service allows an issuer to update enrolled user information in the Carbon Calculator Experience platform. ## Pre-requisites {#pre-requisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [Update User](https://developer.mastercard.com/priceless-planet-carbon-tracker/documentation/use-cases/update_user/index.md) * [Update User Parameters](https://developer.mastercard.com/priceless-planet-carbon-tracker/documentation/parameters/index.md#update-user/) ## Update a user profile {#update-a-user-profile} 1. To update a user on the Carbon Calculator Experience platform, send a PUT request. 2. To create a PUT request, provide the `userid` as a path parameter when updating user information. ```py https://api.mastercard.com/cts/issuers/users/c8b38606-12b2-43c6-a641-be8eb0ab9dec ``` ```json { "name": { "firstName": "Johnn", "lastName": "Dooe" }, "billingAddress": { "countryCode": "USA", "locality": "Rly Station", "postalCode": "11746", "state": "Huntington", "city": "Brooklyn", "line1": "83 Mayfair Street", "line2": "Main Road", "line3": "Snake Hill Ave", "type": "work" }, "locale": "en-US" } ``` 3. A successful request returns the `HTTP 200 Success` status code and a JSON response body that includes a unique user identifier. ```json { "userid": "c8b38606-12b2-43c6-a641-be8eb0ab9dec", "cardNumberLastFourDigits": "2520", "status": "ACTIVE" } ``` ## Failed scenarios {#failed-scenarios} This section discusses some of the failed scenarios and the error messages expected. ### Update a user with invalid lastName {#update-a-user-with-invalid-lastname} 1. Send a PUT request with an invalid value in the `lastName` parameter as shown in the request. 2. Provide the `userid` as a path parameter. ```py https://api.mastercard.com/cts/issuers/users/c8b38606-12b2-43c6-a641-be8eb0ab9dec ``` ```json { "name": { "firstName": "Johnn", "lastName": "444555454" }, "billingAddress": { "countryCode": "USA", "locality": "Rly Station", "postalCode": "11746", "state": "Huntington", "city": "Brooklyn", "line1": "83 Mayfair Street", "line2": "Main Road", "line3": "Snake Hill Ave", "type": "work" }, "locale": "en-US" } ``` 3. This request fails with the error code `HTTP 400 Bad Request` as the response. ```json { "Errors": { "Error": [ { "Source": "CARBON CALCULATOR EXPERIENCE", "ReasonCode": "INVALID_REQUEST_PARAMETER", "Description": "One of the request parameters is invalid, try again with correct request.", "Recoverable": false, "Details": "Username must only contain alphanumeric (A-Z, a-z, 0-9) and the characters ('), (,) and (')" } ] } } ``` ### Update a user with invalid format for locale {#update-a-user-with-invalid-format-for-locale} 1. Send a PUT request with an invalid value in the `locate` parameter as shown in the request. 2. Provide the `userid` as a path parameter. ```json { "name": { "firstName": "Johnn", "lastName": "Dooe" }, "billingAddress": { "countryCode": "USA", "locality": "Rly Station", "postalCode": "11746", "state": "Huntington", "city": "Brooklyn", "line1": "83 Mayfair Street", "line2": "Main Road", "line3": "Snake Hill Ave", "type": "work" }, "locale": "455666" } ``` 3. This request fails with the error code `HTTP 400 Bad Request` as the response. ```json { "Errors": { "Error": [ { "Source": "CARBON CALCULATOR EXPERIENCE", "ReasonCode": "INVALID_REQUEST_PARAMETER", "Description": "One of the request parameters is invalid, try again with correct request.", "Recoverable": false, "Details": "Locale must be in the format: \"ab-YZ\"" } ] } } ``` ### Update a user with donation flow disabled {#update-a-user-with-donation-flow-disabled} Assume that the issuer has disabled the donation flow at the time of onboarding. 1. Send a PUT request with the parameters as shown in the request. 2. Provide the `userid` as a path parameter. ```json { "name": { "firstName": "Johnn", "lastName": "Dooe" }, "billingAddress": { "countryCode": "USA", "locality": "Rly Station", "postalCode": "11746", "state": "Huntington", "city": "Brooklyn", "line1": "96 Mayfair Street", "line2": "Main Road", "line3": "Park Hill Ave", "type": "home" }, "locale": "en-US" } ``` 3. This request fails with the error code `HTTP 400 Bad Request` as the response. ```json { "Errors": { "Error": [ { "Source": "CARBON CALCULATOR EXPERIENCE", "ReasonCode": "UPDATE_USER_NOT_ACCESSIBLE", "Description": "You do not have permission to access this API. The Donate feature for your bank is disabled.", "Recoverable": false, "Details": "You do not have permission to access this API. The Donate feature for your bank is disabled." } ] } } ```