# Auto-Enrollment
source: https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md

### Prerequisites {#prerequisites}

* Get [onboarded with Mastercard Click to Pay](https://developer.mastercard.com/issuer-enrollment/tutorial/issuer-onboarding-click2pay/index.md).
* Familiarize yourself with the [Use Cases](https://developer.mastercard.com/issuer-enrollment/documentation/use-cases/auto-enrollment/index.md).
* Learn about [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/use-cases/auto-enrollment/enroll_api_async/index.md).

|                                                         Scenarios                                                          |                                    Description                                     |
|----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [Scenario 1](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-1) | Valid batch request.                                                               |
| [Scenario 2](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-2) | Invalid batch request.                                                             |
| [Scenario 3](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-3) | Unsuccessful batch enrollment status response.                                     |
| [Scenario 4](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-4) | Successful batch enrollment status response.                                       |
| [Scenario 5](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-5) | Consumer opts out of Click to Pay profile and Issuer needs to delete the profile.  |
| [Scenario 6](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-6) | Issuer wants to delete a specific card from the cardholder's Click to Pay profile. |
| [Scenario 7](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-7) | Issuer wants to update a cardholder's Click to Pay Profile.                        |
| [Scenario 8](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#scenario-8) | Issuer wants to review an enrolled cardholder's specific card details.             |

## Scenario 1 {#scenario-1}

**Assumptions**

* Issuer has read and followed the [Prerequisites](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#prerequisites).

**When**   
> Issuer calls [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) and passes all the [required details](https://developer.mastercard.com/issuer-enrollment/documentation/use-cases/auto-enrollment/enroll_api_async/index.md#detailed-steps) including `externalBatchId` and `enrollmentData`.

```json
{
"srcClientId": "eccbf087-f159-4d69-b31d-00bec75c0474",
"serviceId": "SRC_C2P#CBA#01",
"externalBatchId": "9d56d47e-70d6-470f-a0a6-c0fccb7e3a43",
"enrollmentData": [
  {
    "consumer": {
      "externalConsumerId": "e8cbf087-f159-4d69-b31d-00bec75c0476",
      "emailAddress": "abc@xyz.com",
      "mobileNumber": {
        "countryCode": "1",
        "phoneNumber": "7321112222"
      },
      "countryCode": "US",
      "languageCode": "en",
      "firstName": "abc",
      "lastName": "def"
    },
    "cards": [
      {
        "externalCardId": "64cbf087-f159-4d69-b31d-00bec75c0686",
        "primaryAccountNumber": "5186000000008888",
        "panExpirationMonth": "12",
        "panExpirationYear": "2026",
        "cardholderFirstName": "Abc2",
        "cardholderLastName": "xyz2",
        "billingAddress": {
          "name": "cde",
          "line1": "line1",
          "line2": "line2",
          "line3": "line3",
          "city": "Edison",
          "state": "NJ",
          "countryCode": "US",
          "zip": "08820"
        }
      },
      {
        "externalCardId": "48ebf087-f159-4d69-b31d-00bec75c0478",
        "primaryAccountNumber": "5186000000009999",
        "panExpirationMonth": "12",
        "panExpirationYear": "2026",
        "cardholderFirstName": "Abc2",
        "cardholderLastName": "xyz2",
        "billingAddress": {
          "name": "cde",
          "line1": "line1",
          "line2": "line2",
          "line3": "line3",
          "city": "Edison",
          "state": "NJ",
          "countryCode": "US",
          "zip": "08817"
        }
      }
    ]
  },
  {
    "consumer": {
      "externalConsumerId": "eccbf087-f159-4d69-b31d-00bec75c0576",
      "emailAddress": "xyz@abc.com",
      "mobileNumber": {
        "countryCode": "1",
        "phoneNumber": "7321112222"
      },
      "countryCode": "US",
      "languageCode": "en",
      "firstName": "abc",
      "lastName": "def"
    },
    "cards": [
      {
        "externalCardId": "84ebf087-f159-4d69-b31d-00bec75c0478",
        "primaryAccountNumber": "5186000000008888",
        "panExpirationMonth": "12",
        "panExpirationYear": "2026",
        "cardholderFirstName": "Abc2",
        "cardholderLastName": "xyz2",
        "billingAddress": {
          "name": "cde",
          "line1": "line1",
          "line2": "line2",
          "line3": "line3",
          "city": "Edison",
          "state": "NJ",
          "countryCode": "US",
          "zip": "08820"
        }
      },
      {
        "externalCardId": "6ecbf087-f159-4d69-b31d-00bec75c0476",
        "primaryAccountNumber": "5186000000009999",
        "panExpirationMonth": "12",
        "panExpirationYear": "2026",
        "cardholderFirstName": "Abc2",
        "cardholderLastName": "xyz2",
        "billingAddress": {
          "name": "cde",
          "line1": "line1",
          "line2": "line2",
          "line3": "line3",
          "city": "Edison",
          "state": "NJ",
          "countryCode": "US",
          "zip": "08817"
        }
      }
    ]
  }
]
}
```

**Then**   
> Mastercard accepts the batch enrollment request and sends back the `batchId` and `externalBatchId` in response denoting successful enrollment.

```json
{
  "batchId": "6b45c47e-70d6-470f-a0a6-c0fccb7e3a43",
  "externalBatchId": "6ecbf087-f159-4d69-b31d-00bec75c0478"
}
```

## Scenario 2 {#scenario-2}

**Assumptions**

* Issuer has read and followed the [Prerequisites](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#prerequisites).

**When**   
> * Issuer invokes the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) and passes incorrectly-formatted information or missing details (for example, invalid email address).
> * The Enroll API-Asynchronous returns `202` status, along with the `batchId` and the `externalBatchId`.

```json
{
  "batchId": "6b45c47e-70d6-470f-a0a6-c0fccb7e3a43",
  "externalBatchId": "6ecbf087-f159-4d69-b31d-00bec75c0478"
}
```

**Then**   
> * To understand if the batch values are correctly processed and are successfully enrolled, Issuers must call the Batch Status API.
> * Issuer invokes the [Batch Status API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) with the batch ID, Mastercard responds back with an error message to notify what is missing or incorrect.

```json
{
  "status": 400,
  "reason": "INVALID_ARGUMENT",
  "message": "Cannot process the request because it is malformed or has incorrect/missing fields or values.",
  "errorDetail": [
    {
      "reason": "CANNOT_BE_NULL",
      "source": "serviceId",
      "message": "serviceId is required",
      "sourceType": "BODY"
    }
  ]
}
```

## Scenario 3 {#scenario-3}

**Assumptions**

* Issuer has read and followed the [Prerequisites](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#prerequisites).
* Issuer has invoked the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) to enable single or multiple cardholders, and received the `batchId` and the `externalBatchId`.
* Batch enrollment has entirely or partially failed.

**When**   
> Issuer invokes the [Batch Status API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) with the batch ID, and entire/partial records in the batch result in failure due to reasons such as invalid/incorrect card data or invalid/incorrect cardholder details.

**Then**   
> Mastercard responds with `COMPLETED_WITH_FAILURES` along with the status, failure message, failure reason, and details of the error to notify what is missing or incorrect.

```json
{
  "status": 400,
  "reason": "INVALID_ARGUMENT",
  "message": "Cannot process the request because it is malformed or has incorrect/missing fields or values.",
  "errorDetail": [
    {
      "reason": "INVALID_PAN",
      "source": "enrollmentRecords",
      "message": "This entity has invalid PAN for the requested operation",
      "sourceType": "BODY"
    }
  ]
}
```

## Scenario 4 {#scenario-4}

**Assumptions**

* Issuer has read and followed the [Prerequisites](https://developer.mastercard.com/issuer-enrollment/documentation/testing/auto-enrollment/index.md#prerequisites).
* Issuer has invoked the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) to enable single or multiple cardholders, and received the `batchId` and the `externalBatchId`.
* Batch enrollment has succeeded.

**When**   
> Issuer requests the [Batch Status API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) with the batch ID, Mastercard responds back with the valid values.

**Then**   
> Mastercard responds with `COMPLETED_SUCCESSFULLY` along with the `batchId`, `externalBatchId`, `status`, and `enrollmentRecords`.

```json
{
  "srcClientId": "eccbf087-f159-4d69-b31d-00bec75c0474",
  "serviceId": "SRC_C2P#CBA#01",
  "srcCorrelationId": "abcdf069-e245-3c54-a265-00def57e0576",
  "batchId": "33242abc",
  "externalBatchId": "baecf087-f159-4d69-b31d-00bec75c0347",
  "status": "COMPLETED_SUCCESSFULLY",
  "enrollmentRecords": [
    {
      "consumer": {
        "externalConsumerId": "e6cbf087-f159-4d69-b31d-00bec75c0478",
        "srcConsumerId": "30bf50ec-0e8b-414f-8cfc-63e9c3fb9d48",
        "status": "SUCCESS"
      },
      "cards": [
        {
          "externalCardId": "ebcaf087-f159-4d69-b31d-00bec75c0886",
          "srcDigitalCardId": "68bf50ec-0e8b-414f-8cfc-63e9c3fb9d48",
          "status": "SUCCESS"
        },
        {
          "externalCardId": "54be50ec-0e8b-414f-8cfc-63e9c3fb8c49",
          "srcDigitalCardId": "24ec50ec-0e8b-414f-8cfc-63e9c3fd458",
          "status": "SUCCESS"
        },
        {
          "externalCardId": "56cf50ec-0e8b-414f-8cfc-63e9c3fb6dec",
          "srcDigitalCardId": "45bf50ec-0e8b-414f-8cfc-63e9c3fb9d62",
          "status": "SUCCESS"
        }
      ]
    },
    {
      "consumer": {
        "externalConsumerId": "be8af087-f159-4d69-b31d-00bec75c0668",
        "srcConsumerId": "64bf50ec-0e8b-414f-8cfc-63e9c3fb9d84",
        "status": "SUCCESS"
      },
      "cards": [
        {
          "externalCardId": "ea8bf087-f159-4d69-b31d-00bec75cd576",
          "srcDigitalCardId": "74ac50ec-0e8b-414f-8cfc-63e9c3fb9c56",
          "status": "SUCCESS"
        },
        {
          "externalCardId": "ebc8f50ec-0e8b-414f-8cfc-63e9c3fb9d96",
          "srcDigitalCardId": "78bf50ec-0e8b-414f-8cfc-63e9c3fb9d84",
          "status": "SUCCESS"
        },
        {
          "externalCardId": "56bf50ec-0e8b-414f-8cfc-63e9c3fb9d44",
          "srcDigitalCardId": "48bf50ec-0e8b-414f-8cfc-63e9c3fb9d78",
          "status": "SUCCESS"
        }
      ]
    }
  ]
}
```

## Scenario 5 {#scenario-5}

**Assumptions**

* Issuer has invoked the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous), successfully enrolled the cardholders, and received the `batchId` and the `externalBatchId`.
* Issuer has set up each cardholder's profile with their cards, email addresses, and other required details.

**When**   
> After successful enrollment in Click to Pay, cardholder opts out of Click to Pay from their banking app/website.

**Then**   
> Issuer invokes the [Delete Consumer Profile API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#lifecycle-management-apis) to remove the cardholder's Click to Pay profile, along with the associated cards.
> Issuer sends the `srcClientId`, `serviceID`, `identityType`, and `identityValue` as required parameters while calling the API.
> Mastercard sends back the appropriate API response.

```json
{
  "srcCorrelationId": "779165e0-1905-4edd-89fa-be46497b5044"
}
```

> In case the Issuer sends the API request wherein the mandatory parameters are either missing or incorrect, Mastercard sends the error response denoting the missing/incorrect field, and error reason.

```json
{
  "status": 400,
  "reason": "INVALID_ARGUMENT",
  "message": "Cannot process the request because it is malformed or has incorrect/missing fields or values.",
  "errorDetail": [
    {
      "reason": "CANNOT_BE_NULL",
      "source\"": "srcClientId",
      "message\"": "srcClientId is required",
      "sourceType": "QUERY"
    }
  ]
}
```

## Scenario 6 {#scenario-6}

**Assumptions**

* Issuer has enrolled a profile with associated cards along with other profiles while calling the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous). After successfully enabling the cardholders, Issuer has received the `batchId` and the `externalBatchId`.

**When**   
> After successfully enabling a profile with associated card in Click to Pay, the Issuer needs to delete a specific card from the cardholder's profile.

**Then**   
> Issuer invokes the [Delete Consumer Card API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#lifecycle-management-apis) to remove a previously-enrolled card with the specific card identifier.
> Issuer sends the `cardId`, `srcClientId`, and `serviceID` as required parameters while calling the Delete Card API.
> Mastercard sends back the appropriate API response.

```json
{
  "srcCorrelationId": "779165e0-1905-4edd-89fa-be46497b5044"
}
```

> In case the Issuer sends the API request wherein the mandatory parameters are either missing or incorrect, Mastercard sends the error response denoting the missing/incorrect field, and error reason.

```json
{
  "errorDetail": [
    {
      "message": "Required request parameter 'srcClientId' for method parameter type String is not present",
      "reason": "CANNOT_BE_NULL",
      "source": "srcClientId",
      "sourceType": "QUERY"
    }
  ],
  "message": "Http request query parameter is missing",
  "reason": "INVALID_ARGUMENT",
  "status": 400
}
```

## Scenario 7 {#scenario-7}

**Assumptions**

* Issuer has enrolled a profile with associated cards within a batch while calling the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous) and after successfully enabling the cardholders, Issuer has received the `batchId` and the `externalBatchId`.

**When**   
> After successfully enabling a profile with associated cards in Click to Pay, the Issuer needs to update a specific cardholder's profile.

**Then**   
> Issuer invokes the [Update Consumer Card API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#lifecycle-management-apis) to update a previously-enrolled card with the specific card identifier (cardId).
> Issuer sends the `cardId` as required parameters while calling the API.

```json
{
  "srcClientId": "eccbf087-f159-4d69-b31d-00bec75c0474",
  "srcCorrelationId": "779165e0-1905-4edd-89fa-be46497b5044",
  "serviceId": "SRC_C2P#CBA#01",
  "encryptedBillingAddress": "eyJraWQiOiIyMDIzMDIwNzIyMzUyMS1zYW5kYm94LWZwYW4tZW5jcnlwdGlvbi1zcmMtbWFzdGVyY2FyZC1pbnQiLCJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMTI4R0NNIn0.oqSHc4aGbk7FUPcZOUuOerJnVGd867ajauCN2eHFDJXQSv80DpdXZPnGtPNDWGL9Akp8gLshUFOs6vLDEFhdjnanlPwW6KLZGH3dS6XbCEj243Pdt75H8nJ038t9pCZs4OE1LqvAn5lB9Zk1_xCSvrj7xXgnrXbVPIup6ZXFUOSQbtDQNAyrWa_pgoxPpv2QUiaXMtmkRujAJcdwNFBSgJ39krOiNT7bRsO6tINi1GPksnaNsKooFHdnDpXphNlpETLBzBDrojOlHQjMfqVIC8fV1Fl1PJmbbr4I3WesyfZepOoT4FAOEX3qyKhHqrC5hc0OzwlEJz_Lpk5JRlA.kknX-HU5G_7FFut2.kpg2xkuwSTfWrIliaLLnPoloWkD92OmA9PjcLlFj5HZ56iucjwMRIyf4rSa-rRXgrrobeC1K03tSX-7wpCCe_H7TDyITHcUcjU6Sag31SySWvR-tPxRzH0MdomxCv6IfJ_0DHW-RfCA0kn4iF7hQa5wVc8sWW1q8XT6k2nRmfq8.TwALu-sHaFPMLO4Dr4h62Q"
}
```

> Mastercard sends back the appropriate API response if successful.

```json
{
  "srcCorrelationId": "779165e0-1905-4edd-89fa-be46497b5044"
}
```

> In case the Issuer sends the API request with either missing or incorrect cardId, Mastercard sends the error response denoting the missing/incorrect field, and error reason.

```json
{
  "status": 400,
  "reason": "INVALID_ARGUMENT",
  "message": "Cannot process the request because it is malformed or has incorrect/missing fields or values.",
  "errorDetail": [
    {
      "reason": "CANNOT_BE_NULL",
      "source": "cardId",
      "message": "srcDigitalCardId cannot be null",
      "sourceType": "PATH"
    }
  ]
}
```

## Scenario 8 {#scenario-8}

**Assumptions**

* Issuer has enrolled a profile with associated cards along with other profiles while calling the [Enroll API-Asynchronous](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#enroll-api-asynchronous). After successfully enabling the cardholders, Issuer has received the `batchId` and the `externalBatchId`.

**When**   
> After successfully enabling a profile with associated cards in Click to Pay, the Issuer needs to review a specific card from the cardholder's profile.

**Then**   
> Issuer invokes the [Get Consumer Card API](https://developer.mastercard.com/issuer-enrollment/documentation/api-reference/apis/index.md#lifecycle-management-apis) to retrieve the latest card information for a specific enrolled card.
> Issuer sends the `srcDigitalCardId`, `srcClientId`, and `serviceID` as required parameters while calling the API.
> Mastercard sends back the appropriate API response.

```json
{
  "srcCorrelationId": "779165e0-1905-4edd-89fa-be46497b5044",
  "maskedCard": {
    "srcDigitalCardId": "68bf50ec-0e8b-414f-8cfc-63e9c3fb9d48",
    "panBin": "520473",
    "panLastFour": "4601",
    "tokenUniqueReference": "DM4MMC0000000001cd2826c715b7475bb089b7622366ebe4",
    "tokenLastFour": "7217",
    "tokenExpirationMonth": "10",
    "tokenExpirationYear": "2022",
    "digitalCardData": {
      "status": "ACTIVE",
      "descriptorName": "Bank Rewards Mastercard",
      "artUri": "https://assets.mastercard.com/card-art/combined-image-asset/MyBank-mastercard.png",
      "pendingEvents": [
        "PENDING_AVS"
      ],
      "isCoBranded": true,
      "coBrandedName": "Very Nice Hotels",
      "authenticationMethods": [
        {
          "authenticationMethodType": "3DS",
          "authenticationSubject": "CARDHOLDER",
          "uriData": {
            "uri": "https://sandbox.mastercard.com/"
          }
        }
      ],
      "issuerName": "My Bank",
      "longDescription": "Bank Double Cash Back Rewards Mastercard",
      "foregroundColor": "FF5733"
    },
    "panExpirationMonth": "05",
    "panExpirationYear": "2022",
    "paymentCardDescriptor": "mastercard",
    "paymentCardType": "CREDIT",
    "countryCode": "string",
    "serviceId": "SECURE_COF_MERCHANT_OBO#SRC4M-OBO-ALL4PETS#01",
    "paymentAccountReference": "5001EUMYTT3AESCZGUEC77KPCLETI",
    "dateOfCardCreated": "2021-11-25T14:51:03.811Z",
    "dateOfCardLastUsed": "string",
    "delegatedAuthenticationModels": [
      {
        "modelType": "AE_TYPE_3",
        "isSupported": true
      }
    ],
    "mfaEligibility": [
      {
        "authenticatingEntityId": "A3001",
        "certifiedMfaMethodId": "43SA5",
        "isMultiFactorAuthenticationSupported": true,
        "isLiabilityShiftEligible": true
      }
    ]
  },
  "encryptedPaymentData": "eyJ0eXBlIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiI4NTIxNDY4OCJ9.eyJzdWIiOiI1OTY3OGJmNS00ODcxLTQ5M2MtOWUwYi0",
  "keyFingerprintId": "nwzNuN9upxolVsr6q0I/phcnfA/ZlaJ2gmAJiogMCwM"
}
```

> In case the Issuer sends the API request wherein the mandatory parameters are either missing or incorrect, Mastercard sends the error response denoting the missing/incorrect field, and error reason.

```json
{
  "errordetail": [
    {
      "message": "Required request parameter 'srcClientId' for method parameter type String is not present",
      "reason": "CANNOT_BE_NULL",
      "source": "srcClientId",
      "sourceType": "QUERY"
    }
  ],
  "message": "Http request argument type is mismatched at this service",
  "reason": "INVALID_ARGUMENT",
  "status": 400
}
```

