# Create a Dispute Case
source: https://developer.mastercard.com/mastercard-processing-dispute/documentation/sandbox-testing/create-dispute-case/index.md

## Test case -- Success {#test-case--success}

This test case describes creating a dispute case for a specified financial transaction stored in the CMS.

**Sample request**

`POST /cases`

```JSON
{
  "caseComments": "transactionDate=2020-06-05;disputedAmount=202.35;caseComments=Product not delivered",
  "financialDocumentId": 2987891,
  "reasonCode": "4837"
}
```

**Sample response**

`201`  

`Location: /cases/80001`

```JSON
{
    "caseId": 80001
}
```

## Test case -- Fail -- Duplicated case {#test-case--fail--duplicated-case}

This test case describes an attempt to create a dispute case for a specified financial transaction stored in the CMS which already has an open case.

For this test case, use the following information in the request:

|         Field         | Available value |
|-----------------------|-----------------|
| `financialDocumentId` | 30004           |

**Sample request**

`POST /cases`

```JSON
{
  "caseComments": "transactionDate=2020-06-05;disputedAmount=202.35;caseComments=Product not delivered",
  "financialDocumentId": 30004,
  "reasonCode": "4837"
}
```

**Sample response**

`400`

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "ANOTHER_OPEN_CASE_ALREADY_EXISTS",
        "Description": "Another open case with id 80001 for the financial transaction with id 30004 already exists.",
        "Recoverable": false
      }
    ]
  }
}
```

## Test case -- Fail -- Financial transaction does not exist {#test-case--fail--financial-transaction-does-not-exist}

This test case describes an attempt to create a dispute case for a specified financial transaction that does not exist in the CMS.

For this test case, use the following information in the request:

|         Field         | Available value |
|-----------------------|-----------------|
| `financialDocumentId` | 30003           |

**Sample request**

`POST /cases`

```JSON
{
  "caseComments": "transactionDate=2020-06-05;disputedAmount=202.35;caseComments=Product not delivered",
  "financialDocumentId": 30003,
  "reasonCode": "4837"
}
```

**Sample response**

`404`

```JSON
{
    "Errors": {
        "Error": [
            {
                "Source": "MASTERCARD PROCESSING",
                "ReasonCode": "DOCUMENT_NOT_FOUND",
                "Description": "For given transaction record id 30003 document not found.",
                "Recoverable": false
            }
        ]
    }
}
```

## Test case -- Fail -- Invalid reason code {#test-case--fail--invalid-reason-code}

This test case describes an attempt to create a dispute case for a specified financial transaction stored in the CMS using an invalid reasonCode value in the request.

For this test case, use the following information in the request:

|   Field    | Available value |
|------------|-----------------|
| reasonCode | INVALID         |

**Sample request**

`POST /cases`

```JSON
{
  "caseComments": "transactionDate=2020-06-05;disputedAmount=202.35;caseComments=Product not delivered",
  "financialDocumentId": 2987891,
  "reasonCode": "INVALID"
}
```

**Sample response**

`400`

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "INVALID_REASON_CODE",
        "Description": "The given reason code INVALID is not supported.",
        "Recoverable": false
      }
    ]
  }
}
```

## Test case -- Fail -- Non-financial document {#test-case--fail--non-financial-document}

This test case describes an attempt to create a dispute case for a non-financial document.

For this test case, use the following information in the request:

|        Field        | Available value |
|---------------------|-----------------|
| financialDocumentId | 30005           |

**Sample request**

`POST /cases`

```JSON
{
  "caseComments": "transactionDate=2020-06-05;disputedAmount=202.35;caseComments=Product not delivered",
  "financialDocumentId": 30005,
  "reasonCode": "4837"
}
```

**Sample response**

`400`

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "NON_FINANCIAL_DOCUMENT",
        "Description": "Cannot create a case for non-financial document.",
        "Recoverable": false
      }
    ]
  }
}
```

