# Code and Formats
source: https://developer.mastercard.com/bs-creditor-api/documentation/code-and-formats/index.md

## Business Error Codes {#business-error-codes}

The MandateStatus has a statusCode field with the values:

| Status code |                                      Description                                       |
|-------------|----------------------------------------------------------------------------------------|
| RECEIVED    | Mandate request received and ready to be validated.                                    |
| VALIDATED   | Mandate request received and successfully validated.                                   |
| FAILED      | Mandate request received but failed validation. Check the error code for more details. |

When the statusCode is FAILED the mandate status errorCode can be:

|                Error code                 |                               Description                               |
|-------------------------------------------|-------------------------------------------------------------------------|
| MANDATE_ALREADY_EXISTS                    | The mandate already exists in the system and cannot be created again.   |
| BANK_IS_NOT_WITHIN_BETALINGSSERVICE       | The specified bank is not part of the Betalingsservice agreement.       |
| CREDITORS_DEBTOR_REFERENCE_IS_NOT_CORRECT | The creditor's debtor reference provided is invalid or incorrect.       |
| DEBTOR_ACCOUNT_INFORMATION_IS_NOT_CORRECT | The account information for the debtor is invalid or incomplete.        |
| DEBTOR_IDENTITY_IS_NOT_CORRECT            | The debtor's identity details do not match or are incorrect.            |
| CREDITOR_DATA_IS_NOT_CORRECT              | The creditor's data provided is invalid, incomplete, or does not match. |
| DEBTOR_GROUP_CLOSED                       | The debtor group associated with this operation has been closed.        |
| UNKNOWN_VALIDATION_ERROR                  | An unknown error occurred during validation. Please review the inputs.  |

It is allowed to send a new mandate request for the same (debtorGroupNumber, pbsNumber, creditorDebtorReference) key
after the previous request has been processed:

* To correct data if previous request was FAILED.
* To create again if previous request was VALIDATED and then cancelled through some other channel.
* In other cases the MANDATE_ALREADY_EXISTS could be returned.

## Error Codes {#error-codes}

### Error Structure {#error-structure}

Mastercard returns errors in the following structure.

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "<source>",
        "ReasonCode": "<unique code>",
        "Description": "<short description of the error>",
        "Recoverable": true false,
        "Details": "<Optional detailed description of the issue>"
      }
    ]
  }
}
```

### Gateway Error Codes {#gateway-error-codes}

In addition to service error codes, error codes can also be returned by Mastercard's Gateway, which is used to verify your request's signature, and route it to the correct location.

You can find a list of the errors returned by our Gateway, as well as resolutions to each, on the following page [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/).

### Reason Codes {#reason-codes}

Here is a description of the commonly encountered errors and their resolution.

|           Reason/Error Code           | HTTP Status Code |                                                                                                                      Description                                                                                                                      |                                                                                                                                               Resolution                                                                                                                                                |
|---------------------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| BAD_REQUEST                           | 400              | Error occurred due to OpenAPI contract validations. For example, specified criteria for length, pattern, and type of fields are not met.                                                                                                              | Revisit the Open API specification (see the [API Reference](https://developer.mastercard.com/bs-creditor-api/documentation/api-reference/index.md#APIs) section) and ensure that the request adheres to it.                                                                                             |
| NOT_FOUND                             | 404              | Entity not found. For example, DebtorGroup identified by pbsNumber and debtorGroupNumber is not found.                                                                                                                                                | Verify that the endpoint URL and the resource identifier are accurate. Also, ensure that the resource exists.                                                                                                                                                                                           |
| OPERATION_NOT_ALLOWED                 | 400              | Operation is not allowed for the creditor.                                                                                                                                                                                                            | Contact [Mastercard Customer Service](/documentation/support/#Contact Us) and inquire about obtaining permission to create mandates without Strong Customer Authentication (SCA).                                                                                                                       |
| DEV_ZONE_CLIENT_INACTIVE              | 400              | Mastercard Developers client not activated for the creditor.                                                                                                                                                                                          | To use the BS Creditor API, the Mastercard Developers client must be activated for the creditor. See the [Tutorials and Guides](https://developer.mastercard.com/bs-creditor-api/documentation/tutorials-and-guides/index.md#Guides) section to learn how to activate the Mastercard Developers client. |
| CLIENT_CREDITOR_DATA_ERROR            | 403              | Error occurs when the client request contains creditor data that it does not manage. For example, if the specified agreement does not belong to the authorized creditor or the requested delegated mandates do not belong to the authorized creditor. | Make sure you are using the correct credentials and request data. Also, verify that you have the required permissions.                                                                                                                                                                                  |
| CREDITOR_CLOSED                       | 400              | Creditor is obsolete.                                                                                                                                                                                                                                 | Contact [Mastercard Customer Service](/documentation/support/#Contact Us).                                                                                                                                                                                                                              |
| BS_AGREEMENT_CLOSED                   | 400              | The BS Agreement is obsolete.                                                                                                                                                                                                                         | Contact [Mastercard Customer Service](/documentation/support/#Contact Us).                                                                                                                                                                                                                              |
| DEBTOR_GROUP_CLOSED                   | 400              | Debtor Group is obsolete.                                                                                                                                                                                                                             | Contact [Mastercard Customer Service](/documentation/support/#Contact Us).                                                                                                                                                                                                                              |
| DELEGATED_MANDATE_UUID_ALREADY_EXISTS | 400              | The Delegated Mandate UUID already exists.                                                                                                                                                                                                            | Resend the request with a different UUID.                                                                                                                                                                                                                                                               |
| DELEGATED_MANDATE_ALREADY_EXISTS      | 400              | Another DelegatedMandate request identified by (debtorGroupNumber, pbsNumber, creditorDebtorReference) is in VALIDATED state.                                                                                                                         | Contact [Mastercard Customer Service](/documentation/support/#Contact Us).                                                                                                                                                                                                                              |
| DELEGATED_MANDATE_ALREADY_IN_PROCESS  | 400              | Another Delegated Mandate request identified by (debtorGroupNumber, pbsNumber, creditorDebtorReference) is being processed (in RECEIVED state).                                                                                                       | Contact [Mastercard Customer Service](/documentation/support/#Contact Us).                                                                                                                                                                                                                              |

