# How to call the Enroll User API source: https://developer.mastercard.com/priceless-planet-carbon-tracker/tutorial/test-cases/step1/index.md ### Register users to allow them to track their carbon footprints {#register-users-to-allow-them-to-track-their-carbon-footprints} The **Enroll User** service allows an issuer to register a consumer in the Carbon Calculator Experience platform. ## Pre-requisites {#pre-requisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [Enroll User](https://developer.mastercard.com/priceless-planet-carbon-tracker/documentation/use-cases/enroll_user/index.md) * [Enroll User Parameters](https://developer.mastercard.com/priceless-planet-carbon-tracker/documentation/parameters/index.md#user-enrollment/) ## Enroll a user {#enroll-a-user} 1. To enroll a user on the Carbon Calculator Experience platform, send a POST request. 2. To create a POST request, fill out the details as shown in the request. ```py POST https://sandbox.api.mastercard.com/cts/issuers/users ``` ```json { "email": { "type": "home", "value": "johnn.dooe@gmail.com" }, "name": { "firstName": "Johnn", "lastName": "Dooe" }, "cardholderName": "Johnn Dooe", "cardNumber": "2223006448842520", "cardBaseCurrency": "USD", "expiryInfo": { "month": "01", "year": "2039" }, "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. Copy and store the user identifier returned in the response field `userid`. 4. You will need this `userid` to make calls to other endpoints. ```json { "userid": "c8b38606-12b2-43c6-a641-be8eb0ab9dec", "cardNumberLastFourDigits": "2520", "status": "ACTIVE" } ``` ## Enroll a user with the donation flow disabled {#enroll-a-user-with-the-donation-flow-disabled} The issuer can enroll a user while disabling the donation flow at the time of onboarding. In this case, the billing address, name, and locale are not mandatory fields. 1. Send a POST request to enroll a user after disabling the donation flow. 2. To create a POST request, fill out the details as shown in the request. ```py POST https://sandbox.api.mastercard.com/cts/issuers/users ``` ```json { "email": { "type": "home", "value": "johnn.dooe@gmail.com" }, "cardholderName": "Johnn Dooe", "cardNumber": "2223006448842520", "cardBaseCurrency": "USD", "expiryInfo": { "month": "01", "year": "2039" } } ``` 3. A successful request returns the `HTTP 200 Success` status code and a JSON response body that includes a unique user identifier. Copy and store the user identifier returned in the response field `userid`. 4. You will need this donorId to make calls to other endpoints. ```json { "userid": "866e39dd-f95b-4418-9e6a-7b1b96f16908", "cardNumberLastFourDigits": "2520", "status": "ACTIVE" } ``` ## Failed scenarios {#failed-scenarios} This section discusses some of the failed scenarios and the error messages expected. ### Enroll a user with an invalid card number {#enroll-a-user-with-an-invalid-card-number} 1. Send a POST request to enroll a user after disabling the donation flow. 2. To create a POST request, fill out the details as shown in the request. ```py POST https://sandbox.api.mastercard.com/cts/issuers/users ``` ```json { "email": { "type": "home", "value": "johnn.dooe@gmail.com" }, "name": { "firstName": "Johnn", "lastName": "Dooe" }, "cardholderName": "Johnn Dooe", "cardNumber": "22230064488425200", "cardBaseCurrency": "USD", "expiryInfo": { "month": "01", "year": "2039" }, "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": "Card Number must match \"^[0-9]{16}$\"" } ] } } ``` ### Enroll a user with an invalid format for the Card Base Currency {#enroll-a-user-with-an-invalid-format-for-the-card-base-currency} 1. Send a POST request to enroll a user after disabling the donation flow. 2. To create a POST request, fill out the details as shown in the request. ```py POST https://sandbox.api.mastercard.com/cts/issuers/users ``` ```json { "email": { "type": "home", "value": "johnn.dooe@gmail.com" }, "name": { "firstName": "Johnn", "lastName": "Dooe" }, "cardholderName": "Johnn Dooe", "cardNumber": "2223006448842520", "cardBaseCurrency": "USDA", "expiryInfo": { "month": "01", "year": "2039" }, "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 `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": "CardBaseCurrency must be in the format: \"XYZ\"" } ] } } ```