# Pre-compliance and compliance case filing tutorial
source: https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingcomp-tutorial/index.md

## Overview {#overview}

This tutorial will show you the process of senders and receivers managing pre-compliance and compliance cases.

#### What you will learn {#what-you-will-learn}

> * How to create a pre-compliance or compliance case
> * How to update or respond to a compliance case
> * How to retrieve details for an existing case

## Before you start {#before-you-start}

Before starting this tutorial, ensure that you have already completed the following:

* [Mastercom Extended API Client Generation Tutorial](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/clientgeneration-tutorial/index.md)
* [Quick Start Guide](https://developer.mastercard.com/mastercom-extended/documentation/quick-start-guide/index.md)

## Step 1: Upload documents {#step-1-upload-documents}

The sender uploads documents.

API Reference: `POST /documents`

**Refer to [Step 1](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/documents-tutorial/index.md) of the [Documents](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/documents-tutorial/index.md) tutorial for more specific information on how to utilize this endpoint.**

## Step 2: Create a new pre-compliance case {#step-2-create-a-new-pre-compliance-case}

The sender uses this endpoint to create a new pre-compliance case.

API Reference: `POST /cases/compliances`

To create a pre-compliance case, create a `CaseFilingApi` object. Then use method `caseFilingApi.createPreCompOrCompCase`.

This method expects the request body to be provided alongside the type of compliance case being created. The request body is an instantiation of `ComplianceCaseCreate` object.

```java
public class Main {
  public static void main(String[] args) {
    // API client set up here...    
    CaseFilingApi caseFilingApi = new CaseFilingApi(BaseClassUtil.getClient());
    
    ComplianceCaseCreate body = new ComplianceCaseCreate();
    body.setCaseDisputeAmount("12300");
    body.setFilingAs(ComplianceCaseCreate.FilingAsEnum.ISSUER);
    body.setViolationCode(ComplianceCaseCreate.ViolationCodeEnum.ALL_OTHER);
    body.setViolationDate(LocalDate.now());
    body.setMemo("This is a sample memo");
    try {
      CaseCreateCaseId result = caseFilingApi.createPreCompOrCompCase("PRE-COMPLIANCE", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling CaseFilingApi#createPreCompOrCompCase");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Review the possible error codes associated with this request {#review-the-possible-error-codes-associated-with-this-request}

| HTTP Code |                    Error                     |                                                          Error Description                                                          | Error Code |
|-----------|----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|------------|
| 400       | INVALID_REQUEST                              | filing_as:Field Data is Invalid case_type:Field Data is Invalid                                                                     | 200001     |
| 400       | INVALID_REQUEST                              | source:Field Data is Invalid                                                                                                        | 200001     |
| 400       | INVALID_REQUEST                              | violation_code:Invalid Violation Code Provided                                                                                      | 200001     |
| 400       | INVALID_REQUEST                              | filingIca:Length of field is not valid                                                                                              | 200001     |
| 400       | INVALID_REQUEST                              | violation_date:Violation date is greater than file submission date                                                                  | 200001     |
| 400       | INVALID_REQUEST                              | violation_date:Field Data is Invalid                                                                                                | 200001     |
| 400       | INVALID_REQUEST                              | Invalid `claimId` Provided                                                                                                          | 200001     |
| 400       | INVALID_REQUEST                              | User does not have provision for the requested data.                                                                                | 200001     |
| 400       | INVALID_REQUEST                              | `claimId` is already associated with a case                                                                                         | 200001     |
| 400       | INVALID_REQUEST                              | Currency Details not found for given ICAs                                                                                           | 200001     |
| 400       | INVALID_REQUEST                              | User Id does not exist OR User is not provisioned for this filing ICA                                                               | 200001     |
| 400       | INVALID_INPUT_LENGTH                         | Invalid input length for field `fieldName`                                                                                          | 210000     |
| 400       | CRTE_CMP_CASE_REQ_PAN_ARN_FIELDS             | When you do not provide `claimId`, you must provide `primaryAccountNumber` and `acquirerReferenceNumber` for DUAL_MESSAGE.          | 220026     |
| 400       | CRTE_COMPLIANCE_CASE_REQ_CURRENCY_FIELD      | When you do not provide `claimId`, you must provide `caseDisputeAmountAlphaCurrencyCode` or `caseDisputeAmountNumericCurrencyCode`. | 220008     |
| 400       | CRTE_COMPLIANCE_CASE_INCORRECT_CURRENCY_COMB | Only one of the `caseDisputeAmountAlphaCurrencyCode` and `caseDisputeAmountNumericCurrencyCode` should be provided.                 | 220009     |
| 400       | CRTE_COMPLIANCE_CASE_REQ_FILING_INFO         | When you do not provide `claimId`, you must provide `filingICA` and `filedAgainstICA`.                                              | 220010     |
| 400       | INVALID_INPUT_VALUE                          | Invalid input value for field `caseDisputeAmount`                                                                                   | 230000     |
| 400       | INVALID_INPUT_VALUE                          | Invalid input value for field `violationCode`                                                                                       | 230000     |
| 400       | INVALID_INPUT_VALUE                          | Invalid input value for field `fieldName`                                                                                           | 230000     |
| 400       | MISSING_REQUIRED_INPUT                       | Missing required field `violationDate`                                                                                              | 250000     |

Review additional error codes [here](https://developer.mastercard.com/mastercom-extended/documentation/code-and-formats/errorsandexceptions/index.md).

#### Verify response {#verify-response}

You should receive a 201 Created response and the `caseId`.

## Step 3: Retrieve the document processing details {#step-3-retrieve-the-document-processing-details}

The sender uses this endpoint to retrieve the processing status of the documents associated with the case.

API Reference: `GET /cases/documents/attributes`

**Refer to [Step 3](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingdocuments-tutorial/index.md) of the [Case filing documents](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingdocuments-tutorial/index.md) tutorial for more specific information on how to use this endpoint.**

## Step 4: Retrieve details for existing case {#step-4-retrieve-details-for-existing-case}

The sender uses this endpoint to retrieve the details for an existing case.

API Reference: `GET /cases/{case_id}`

To retrieve case details, create a `CaseFilingApi` object. Then use method `caseFilingApi.retrieveCaseDetails`.

This method only expects a `caseId` as part of the path. The `caseId` can be obtained from [Step 2](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingcomp-tutorial/index.md) leveraging `POST /cases/compliances`.

```java
public class Main {
  public static void main(String[] args) {
    // API client set up here...    
    CaseFilingApi caseFilingApi = new CaseFilingApi(BaseClassUtil.getClient());
    try {
      CaseDetails result = caseFilingApi.retrieveCaseDetails("5415063");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling CaseFilingApi#retrieveCaseDetails");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Review the possible error codes associated with this request {#review-the-possible-error-codes-associated-with-this-request-1}

| HTTP Code |       Error Code       |    Description     |
|-----------|------------------------|--------------------|
| 400       | BAD_REQUEST            | Bad request        |
| 401       | NOT_AUTHORIZED_REQUEST | Unauthorized       |
| 403       | FORBIDDEN              | Forbidden          |
| 404       | RESOURCE_UNKNOWN       | Resource not found |

Review additional error codes [here](https://developer.mastercard.com/mastercom-extended/documentation/code-and-formats/errorsandexceptions/index.md).

#### Verify response {#verify-response-1}

You should receive a 200 OK response. Returns case details.

## Step 5: Retrieve list of claims within a queue {#step-5-retrieve-list-of-claims-within-a-queue}

The receiver uses this endpoint to request claims within a date range from the Receiver Case Filing queue.

API Reference: `GET /queues/{queue_id}/claims`

**Refer to [Step 4](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/queues-tutorial/index.md) of the [Queues](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/queues-tutorial/index.md) tutorial for more specific information on how to utilize this endpoint.**

## Step 6: Retrieve details for existing case {#step-6-retrieve-details-for-existing-case}

The receiver uses this endpoint to retrieve the case details for an existing case.

API Reference: `GET /cases/{case_id}`

**Refer to [Step 4](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingcomp-tutorial/index.md) for more specific information on how to use this endpoint.**

## Step 7: Retrieve processed documents associated with a case {#step-7-retrieve-processed-documents-associated-with-a-case}

The receiver uses this endpoint to retrieve all documents from a case. The documents include all documents whether attached by the sender or receiver.

API Reference: `GET /cases/{case_id}/documents`

**Refer to [Step 1](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingdocuments-tutorial/index.md) of the [Case filing documents](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingdocuments-tutorial/index.md) tutorial for more specific information on how to use this endpoint.**

## Step 8: Update or respond to a pre-compliance case {#step-8-update-or-respond-to-a-pre-compliance-case}

The receiver uses this endpoint to respond to a pre-compliance case and either accept or reject the case.

API Reference: `PUT /cases/{case_id}/compliances`

To update or respond to a pre-compliance case, create a `CaseFilingApi` object. Then use method `caseFilingApi.takeActionOnComplianceCase`.

This method expects the request body to be provided. The request body is an instantiation of `CaseTakeAction` object.

This method does not have any response body.

```java
public class Main {
    public static void main(String[] args) {
        // API client set up here...    
        CaseFilingApi caseFilingApi = new CaseFilingApi(BaseClassUtil.getClient());
        CaseTakeActionCompliance body = new CaseTakeActionCompliance();
        body.documentUploadedId("e59c3a2a9f4311ee8855eeee0afc63f1");
        body.rebuttalParty(CaseTakeActionCompliance.RebuttalPartyEnum.RECEIVER);
        body.memo("This is a sample memo");
        try {
            caseFilingApi.takeActionOnComplianceCase("5415063", body);
        } catch (ApiException e) {
            System.err.println("Exception when calling CaseFilingApi#takeActionOnComplianceCase");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
```

#### Review the possible error codes associated with this request {#review-the-possible-error-codes-associated-with-this-request-2}

| HTTP Code |       Error Code       |    Description     |
|-----------|------------------------|--------------------|
| 400       | BAD_REQUEST            | Bad request        |
| 401       | NOT_AUTHORIZED_REQUEST | Unauthorized       |
| 403       | FORBIDDEN              | Forbidden          |
| 404       | RESOURCE_UNKNOWN       | Resource not found |

Review additional error codes [here](https://developer.mastercard.com/mastercom-extended/documentation/code-and-formats/errorsandexceptions/index.md).

#### Verify response {#verify-response-2}

You should receive a 204 Success - No Content response.

## Step 9: Retrieve list of claims within a queue {#step-9-retrieve-list-of-claims-within-a-queue}

The sender uses this endpoint to request claims within a date range from the Sender Case Filing queue.

API Reference: `GET /queues/{queue_id}/claims`

**Refer to [Step 4](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/queues-tutorial/index.md) of the [Queues](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/queues-tutorial/index.md) tutorial for more specific information on how to utilize this endpoint.**

## Step 10: Retrieve details for existing case {#step-10-retrieve-details-for-existing-case}

The sender uses this endpoint to retrieve the details for an existing case.

API Reference: `GET /cases/{case_id}`

**Refer to [Step 4](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingcomp-tutorial/index.md) for more specific information on how to use this endpoint.**

## Step 11: Retrieve processed documents associated with a case {#step-11-retrieve-processed-documents-associated-with-a-case}

The sender uses this endpoint to retrieve all documents from a case, whether attached by the sender or receiver.

API Reference: `GET /cases/{case_id}/documents`

**Refer to [Step 1](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingdocuments-tutorial/index.md) of the [Case filing documents](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingdocuments-tutorial/index.md) tutorial for more specific information on how to use this endpoint.**

## Step 12: Update or respond to a pre-compliance case {#step-12-update-or-respond-to-a-pre-compliance-case}

If the sender wants to continue the dispute, the sender updates the pre-compliance case to escalate the case to a compliance case.

API Reference: `PUT /cases/{case_id}/compliances`

**Refer to [Step 8](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingcomp-tutorial/index.md) for more specific information on how to use this endpoint.**

## Step 13: Create a new compliance case {#step-13-create-a-new-compliance-case}

The sender uses this endpoint to create a new compliance case.

API Reference: `POST /cases/compliances`

Note: The sender can withdraw a case at any time prior to receiving an accepted response by the receiver or a ruling by Dispute Resolution Management (DRM).

To create a compliance case, create a `CaseFilingApi` object. Then use method `caseFilingApi.createPreCompOrCompCase`.

This method expects the request body to be provided alongside the type of compliance case being created. The request body is an instantiation of `ComplianceCaseCreate` object.

```java
public class Main {
  public static void main(String[] args) {
    // API client set up here...    
    CaseFilingApi caseFilingApi = new CaseFilingApi(BaseClassUtil.getClient());
    
    ComplianceCaseCreate body = new ComplianceCaseCreate();
    body.setCaseDisputeAmount("12300");
    body.setFilingAs(ComplianceCaseCreate.FilingAsEnum.ISSUER);
    body.setViolationCode(ComplianceCaseCreate.ViolationCodeEnum.ALL_OTHER);
    body.setViolationDate(LocalDate.now());
    body.setMemo("This is a sample memo");
    try {
      CaseCreateCaseId result = caseFilingApi.createPreCompOrCompCase("COMPLIANCE", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling CaseFilingApi#createPreCompOrCompCase");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Review the possible error codes associated with this request {#review-the-possible-error-codes-associated-with-this-request-3}

| HTTP Code |       Error Code       |    Description     |
|-----------|------------------------|--------------------|
| 400       | BAD_REQUEST            | Bad request        |
| 401       | NOT_AUTHORIZED_REQUEST | Unauthorized       |
| 403       | FORBIDDEN              | Forbidden          |
| 404       | RESOURCE_UNKNOWN       | Resource not found |

Review additional error codes [here](https://developer.mastercard.com/mastercom-extended/documentation/code-and-formats/errorsandexceptions/index.md).

#### Verify response {#verify-response-3}

You should receive a 201 Created response and the `caseId`.

### Dispute Resolution Management is notified of a case. {#dispute-resolution-management-is-notified-of-a-case}

## Step 14: Update or respond to a compliance case. {#step-14-update-or-respond-to-a-compliance-case}

The receiver uses this endpoint to respond and accept the case. The sender uses this endpoint to withdraw the case.

API Reference: `PUT /cases/{case_id}/compliances`

To update or respond to a compliance case, create a `CaseFilingApi` object. Then use method `caseFilingApi.takeActionOnComplianceCase`.

This method expects the request body to be provided. The request body is an instantiation of a `CaseTakeAction` object.

This method does not have any response body.

```java
public class Main {
    public static void main(String[] args) {
        // API client set up here...    
        CaseFilingApi caseFilingApi = new CaseFilingApi(BaseClassUtil.getClient());
        CaseTakeActionCompliance body = new CaseTakeActionCompliance();
        body.documentUploadedId("e59c3a2a9f4311ee8855eeee0afc63f1");
        body.rebuttalParty(CaseTakeActionCompliance.RebuttalPartyEnum.RECEIVER);
        body.memo("This is a sample memo");
        try {
            caseFilingApi.takeActionOnComplianceCase("5415063", body);
        } catch (ApiException e) {
            System.err.println("Exception when calling CaseFilingApi#takeActionOnComplianceCase");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
```

#### Review the possible error codes associated with this request {#review-the-possible-error-codes-associated-with-this-request-4}

| HTTP Code |       Error Code       |    Description     |
|-----------|------------------------|--------------------|
| 400       | BAD_REQUEST            | Bad request        |
| 401       | NOT_AUTHORIZED_REQUEST | Unauthorized       |
| 403       | FORBIDDEN              | Forbidden          |
| 404       | RESOURCE_UNKNOWN       | Resource not found |

Review additional error codes [here](https://developer.mastercard.com/mastercom-extended/documentation/code-and-formats/errorsandexceptions/index.md).

#### Verify response {#verify-response-4}

You should receive a 204 Success - No Content response.

\***Dispute Resolution Management rules on the case**

## Step 15: Retrieve list of claims within a queue {#step-15-retrieve-list-of-claims-within-a-queue}

The receiver uses this endpoint to request to retrieve claims from the Receiver Case Filing queue.

The sender uses this endpoint to request to retrieve claims from the Sender Case Filing queue.

API Reference: `GET /queues/{queue_id}/claims`

**Refer to [Step 4](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/queues-tutorial/index.md) of the [Queues](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/queues-tutorial/index.md) tutorial for more specific information on how to utilize this endpoint.**

## Step 16: Retrieve details for existing case {#step-16-retrieve-details-for-existing-case}

The sender or receiver uses this endpoint to retrieve case details, including the outcome of the case.

API Reference: `GET /cases/{case_id}`

**Refer to [Step 4](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/casefilingcomp-tutorial/index.md) for more specific information on how to use this endpoint.**

Return to [Tutorials](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/index.md).
