# How to call the Aggregate Carbon Score API source: https://developer.mastercard.com/priceless-planet-carbon-tracker/tutorial/test-cases/step5/index.md ### Allow users to view their carbon footprint {#allow-users-to-view-their-carbon-footprint} The **Aggregate Carbon Scores** service allows the issuer to fetch aggregate carbon scores for enrolled consumers based on transactions of the current month. ## Pre-requisites {#pre-requisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [View Aggregate Carbon Scores](https://developer.mastercard.com/priceless-planet-carbon-tracker/documentation/use-cases/aggregate_carbon_scores/index.md) * [Aggregate Carbon Scores URL Parameters](https://developer.mastercard.com/priceless-planet-carbon-tracker/documentation/parameters/index.md#aggregate-carbon-score/) ## Fetch the aggregate carbon scores {#fetch-the-aggregate-carbon-scores} 1. To fetch the aggregate carbon scores, send a GET request. 2. To create a GET request, provide the `userid` as the path parameter. ```py GET https://sandbox.api.mastercard.com/cts/issuers/users/f5d88571-ac15-465a-a0d8-1ad1327b9a06/aggregate-carbon-scores ``` 3. A successful request returns the `HTTP 200 Success` status code and a JSON response body that includes a unique user identifier. ```json { "carbonEmissionInGrams": "32.76", "aggregateDate": "December|2024" } ``` ## Failed scenarios {#failed-scenarios} This section discusses some of the failed scenarios and the error messages expected. ### Fetch the aggregate score with an invalid user ID {#fetch-the-aggregate-score-with-an-invalid-user-id} 1. To fetch the aggregate carbon scores, send a GET request. 2. Provide an invalid user ID as the path parameter. ```py GET https://sandbox.api.mastercard.com/cts/issuers/users/khiy88571-ac15-465a-a0d8-1ad1327b9a06/aggregate-carbon-scores ``` 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": "UserId should be of size 36" } ] } } ``` ### Fetch the aggregate carbon scores of a non-existent user {#fetch-the-aggregate-carbon-scores-of-a-non-existent-user} 1. To fetch the aggregate carbon scores, send a GET request. 2. Provide the `userid` of a user who is deleted from the platform as the path parameter. ```py GET https://sandbox.api.mastercard.com/cts/issuers/users/4ba581a55-bcea-4c3e-8e0f-9b4726e5e6d3/aggregate-carbon-scores ``` 3. This request fails with the error code `HTTP 400 Bad Request` as the response. ```json { "Errors": { "Error": [ { "Source": "CARBON CALCULATOR EXPERIENCE", "ReasonCode": "USER_NOT_FOUND", "Description": "We cannot find user details for provided userId. Kindly register user through enrolment process.", "Recoverable": false, "Details": "Make sure user is enrolled through /issuers/users API endpoint." } ] } } ```