# Profiles
source: https://developer.mastercard.com/carbon-calculator/documentation/use-cases/engagement-services/profiles/index.md

The **Profiles** service calculates a climate profile based on the answers from a survey obtained from the Surveys service.

By analyzing non-PII (Personal Identifiable Information) data points we receive from users through survey answers, we can build up a climate profile, that gives users access to a personalized experience when using the engagement services.

The profile can further evolve during interaction with the engagement services and more personalized recommendations can be achieved.

The climate profile should be stored by the issuer and should be sent to each of the endpoints that will operate based on the profile. If the profile is updated because of an interaction, then the updated profile will be sent back in the response and the issuer is responsible for storing it on their side.

The climate profile can also be used with the [Transaction Footprints Calculation](https://developer.mastercard.com/carbon-calculator/documentation/use-cases/txn_footprint_calculation/index.md) to enable climate-based transaction scoring.

## Pre-requisites {#pre-requisites}

Following are the pre-requisites for the issuer to use this service:

1. The issuer must have the consumer's payment transactions ready for carbon scoring.
2. The issuer must call the GET surveys API to get the survey questions, complete the survey using [surveyjs.io](https://surveyjs.io/), and generate a JSON response containing the answers to the survey questions. The response JSON strings should be changed to the values as mentioned in the specification which then can be used as the request body for the profiles endpoint. Refer [Surveys](https://developer.mastercard.com/carbon-calculator/documentation/use-cases/engagement-services/surveys/index.md) to know more.   

**Steps to generate request body for POST profiles API:**

1. Copy the response from the GET surveys API and paste it into the JSON editor of [surveyjs.io](https://surveyjs.io/).
2. Go to the 'Preview' section and fill out the survey in its entirety.
3. Once the survey is submitted, you get a JSON response representing the answer choices filled by you.
4. The JSON representation of the survey answers must be changed in the format specified in the API specification. As an example:

```json
{
    "a:sex": "demo.m",
    "a:age": "demo.lt30",
    "a:country": "IN",
    "interest": "somewhatAgree",
    "knowledge": "neutral",
    "a:diet": "diet.noRed",
    "a:renewable_electricity": "energy.selfProduced",
    "a:have_car": "transport.noCar",
    "a:fly_frequency": "transport.secondMonth",
    "a:shop_frequency": "lifestyle.shopSeldom",
    "difference": "neutral",
    "conscious-purchasing-decisions": "somewhatDisagree",
    "explain-carbon-footprint": "neutral"
}
```

will be changed to:

```json
{
    "sex": "demo.m",
    "age": "demo.lt30",
    "country": "IN",
    "interest": "somewhatAgree",
    "knowledge": "neutral",
    "diet": "diet.noRed",
    "renewableElectricity": "energy.selfProduced",
    "haveCar": "transport.noCar",
    "flyFrequency": "transport.secondMonth",
    "shopFrequency": "lifestyle.shopSeldom",
    "difference": "neutral",
    "consciousPurchasingDecisions": "somewhatDisagree",
    "explainCarbonFootprint": "neutral"
}
```

Finally, the above JSON object will be used as the object "surveyioResults" in the overall request body.

Note:   
Failing to change the string names in the request will result in a bad request error.

<br />

Tip: To create your project on Mastercard Developers, refer to the [Before You Start](https://developer.mastercard.com/carbon-calculator/documentation/index.md#before-you-start) section for more information.

## Sequence Diagram {#sequence-diagram}

The following sequence diagram shows the order of events for a solution that uses the `profiles` endpoint.

Diagram engagement-profiles

**Following are the execution steps:**

1. The consumer is prompted to fill out a survey questionnaire by the issuer.
2. Consumer answers the survey and survey data is made available on the issuer server.
3. The issuer sends the request to Carbon Calculator with the survey answers.
4. The Carbon Calculator application validates the request.
5. The Carbon Calculator application calculates the climate profile as per request.
6. The Carbon Calculator application sends the climate profile to the issuer server.


Note:   
The received climate profile in the response should be persisted by the issuer and should be used for use cases where a climate profile is required. You will receive an error response for an invalid request or any missing request parameter.

<br />

Note:   

* For more information about the error codes, refer to [Code and Formats](https://developer.mastercard.com/carbon-calculator/documentation/code-and-formats/index.md).

## Endpoint {#endpoint}


API Reference: `POST /profiles`

