# Errors

Requests made to our APIs can result in several different error responses. The following document describes the recovery tactics and provides a list of error values with a map of the most common recovery tactic to use.

Suppose you want to integrate [i18n](https://phrase.com/blog/posts/i18n-a-simple-definition/) in your application with the error message. Currently, we support i18n for all error messages. You can see the link:.... and visit this [link](https://jframework.gitbook.io/developers/guide) to learn how to integrate i18n.

## Error codes

This document contains a complete list of all errors that the Jframework API returns.

All errors contain the follow fields:

<table><thead><tr><th width="162.9765625">Property</th><th>Description</th></tr></thead><tbody><tr><td><code>code</code></td><td>The error code.</td></tr><tr><td><code>message</code></td><td>A short description of what caused this error. Sometimes this contains dynamically-generated information about your specific error.</td></tr><tr><td><code>correlationId</code></td><td>A unique identifier for this error. This can be used by JFW Support to help with troubleshooting.</td></tr></tbody></table>

#### API Response Format

```
>{
>  "success": bool,
>  "statusCode": number,
>  "message": text,
>  "data": null,
>  "errors": [
>    {
>      "code": text,
>      "details": text,
>      "correlationId": text
>    }
>  ]
>}
```

#### Ads

| Code                | HTTP status | Message                                                                                |
| ------------------- | ----------- | -------------------------------------------------------------------------------------- |
| AdsNotFound         | 404         | The ads was not found in the system.                                                   |
| AdsInvalidStartDate | 400         | The start date is invalid.                                                             |
| AdsInvalidEndDate   | 400         | The end date is invalid.                                                               |
| InvalidTargetURL    | 400         | The target URL is invalid                                                              |
| InvalidCountryCode  | 400         | The country code is invalid format. This should be an ISO 3166-1 alpha-2 country code. |
| InvalidLanguageCode | 400         | The language code is invalid format. This should be an ISO 639 set 1 language code.    |
| DomainRequired      | 400         | The domains is required.                                                               |

#### AppIntegration

| Code                                   | HTTP status | Message                                                                           |
| -------------------------------------- | ----------- | --------------------------------------------------------------------------------- |
| AppIntegrationNotFound                 | 404         | The AppIntegration was not found in the system.                                   |
| AppIntegrationConflictSetting          | 409         | The app integration request was conflict setting.                                 |
| AppIntegrationUnsupported              | 409         | The app integration is unsupported.                                               |
| AppIntegrationAnalyticsNotFound        | 400         | The Analytics setting was not found in the system.                                |
| AppIntegrationAuthenticationNotFound   | 404         | The app authentication was not found in the system.                               |
| BrandNotConfiguredApp                  | 409         | The brand was not configured with app integration authentication.”                |
| BrandAlreadyConfiguredApp              | 409         | The brand had already been configured with app integration authentication.        |
| AppIntegrationPushNotificationNotFound | 404         | The app push notification was not found in the system.                            |
| AppIntegrationSMSNotFound              | 404         | The app SMS was not found in the system.                                          |
| AppIntegrationSMSNameRequired          | 400         | The name is required.                                                             |
| UsernameRequired                       | 400         | The username is required.                                                         |
| PasswordRequired                       | 400         | The password is required.                                                         |
| PhoneNumberRequired                    | 400         | The phone number is required.                                                     |
| AppIntegrationSMSInvalidPhoneNumber    | 400         | The phone number is invalid. The phone number must be following the E.164 format. |
| AppIntegrationSMTPNotFound             | 404         | The app SMTP was not found in the system.                                         |

#### API Key

| Code              | HTTP status | Message                                  |
| ----------------- | ----------- | ---------------------------------------- |
| APIKeyNotFound    | 404         | The API key was not found in the system. |
| InvalidAPIKey     | 401         | The API key is invalid.                  |
| APIKeyUnavailable | 401         | The API key is unavailable.              |
| APIKeyExpired     | 401         | The API key is expired.                  |
| NameAlreadyExists | 409         | The name already exists.                 |
| InvalidExpiryDate | 400         | The expiration date is invalid.          |

#### Token

| Code                   | HTTP status | User Message                                                                             |
| ---------------------- | ----------- | ---------------------------------------------------------------------------------------- |
| InvalidToken           | 401         | Your token was invalid.                                                                  |
| TokenExpired           | 401         | Your token has expired.                                                                  |
| InvalidReason          | 400         | The token was invalid because the reason is invalid.                                     |
| InvalidUserId          | 400         | The token was invalid because the user Id is invalid.                                    |
| InvalidFormat          | 400         | The token was invalid because the user Id is invalid.                                    |
| InvalidFormat          | 400         | The token was invalid because the provided reason is valid but content is invalid.       |
| ReferencedUserMismatch | 400         | The token was invalid because the given user does not match the token's referenced user. |
| ReasonMismatch         | 400         | The token was invalid because the reason was mismatch.                                   |

#### Brand

| Code                      | HTTP Status | User Message                                                                          |
| ------------------------- | ----------- | ------------------------------------------------------------------------------------- |
| BrandNotFound             | 404         | The brand was not found in the system.                                                |
| CrossOperationNotAllowed  | 405         | We cannot perform the operation because the operation is not allowed to cross brands. |
| BrandRequired             | 400         | The brand input is required                                                           |
| CodeAlreadyExists         | 409         | The brand code is already in use.                                                     |
| NameRequired              | 400         | The name is required.                                                                 |
| DomainNotFound            | 404         | The domain was not found in the system.                                               |
| InvalidDomain             | 400         | The domain is invalid.                                                                |
| DomainAlreadyExists       | 409         | The domain '{0}' is already exists in the system.                                     |
| BrandEmailAddressNotFound | 404         | The email address was not found in the system.                                        |
| TitleRequired             | 400         | The title is required.                                                                |
| EmailAddressRequired      | 400         | The email address is required.                                                        |
| InvalidEmailAddressFormat | 400         | The EmailAddress field is not a valid e-mail address.                                 |
| BrandLinkNotFound         | 404         | The brand link was not found in the system.                                           |

#### Invoice

| Code            | HTTP Status | User Message                             |
| --------------- | ----------- | ---------------------------------------- |
| InvoiceNotFound | 404         | The invoice was not found in the system. |

#### License

| Code                                 | HTTP Status | User Message                                                           |
| ------------------------------------ | ----------- | ---------------------------------------------------------------------- |
| LicenseNotFound                      | 404         | The license was not found in the system.                               |
| LicenseExpired                       | 400         | The license has expired.                                               |
| LicenseNotReady                      | 400         | The license start date is not yet reached.                             |
| LicenseInvalidStartDate              | 400         | The license start date is invalid.                                     |
| LicenseInvalidEndDate                | 400         | The license end date is invalid.                                       |
| InvalidUsedDate                      | 400         | The license used date is invalid.                                      |
| InvalidStartDateEndDate              | 400         | The start date must be less than the end date.                         |
| InvalidQuantityGreaterThanZero       | 400         | The quantity to create must be greater than 0.                         |
| InvalidLicenseCode                   | 400         | The license code format is incorrect.                                  |
| InvalidAmountWalletToPurchaseLicense | 400         | The amount of the wallet doesn't enough to purchase the license.       |
| ApplyLicenseTestModeMismatch         | 403         | The user cannot apply the license in test mode.                        |
| LicenseCodeAlreadyExists             | 409         | The license code already exists in the system.                         |
| LicenseAlreadyUsed                   | 409         | The license is in use by another user.                                 |
| LicenseInactiveStatus                | 400         | Cannot apply the license, because this license has status is Inactive. |
| LicenseCreatePackageFreeNotAllowed   | 400         | Cannot create the license with package free provide.                   |

#### System/Platform Errors

| Code                | HTTP Status | User Message                              |
| ------------------- | ----------- | ----------------------------------------- |
| InternalServerError | 500         | An unexpected server error occurred.      |
| InputInvalid        | 400         | The input is invalid.                     |
| RouteNotFound       | 404         | The requested API endpoint was not found. |

#### Device

| Code                     | HTTP Status | User Message                                               |
| ------------------------ | ----------- | ---------------------------------------------------------- |
| DeviceNotFound           | 404         | The device was not found in the system.                    |
| DeviceInvalidCode        | 400         | The device code is invalid.                                |
| DeviceLimitExceeded      | 403         | The user have reached the maximum number of device active. |
| TypeResponseStatsInvalid | 400         | The type response stats is invalid.                        |

#### Role & Permission

| Code                        | HTTP Status | User Message                             |
| --------------------------- | ----------- | ---------------------------------------- |
| PermissionNotFound          | 404         | The specified permission does not exist. |
| PermissionNameRequired      | 400         | The name is required.                    |
| PermissionCodeRequired      | 400         | The code is required.                    |
| PermissionCodeAlreadyExists | 409         | The code is already in use.              |
| RoleNotFound                | 404         | The role was not found in the system.    |
| RoleNameRequired            | 400         | The name is required.                    |
| RoleCodeRequired            | 400         | The code is required.                    |
| RoleCodeAlreadyExists       | 409         | The code is already in use.              |

#### Package & Feature

| Code                       | HTTP Status | User Message                                                                             |
| -------------------------- | ----------- | ---------------------------------------------------------------------------------------- |
| PackageNotFound            | 404         | The package was not found in the system.                                                 |
| PackagePriceMismatch       | 409         | The package and price requests were in conflict.                                         |
| FeatureAlreadyAdded        | 409         | The feature is already added for this package.                                           |
| NotAllowedDowngradePackage | 403         | You cannot downgrade your package to a lower tier while you have an active subscription. |
| FeatureNotFound            | 404         | The feature was not found in the system.                                                 |
| PriceNotFound              | 404         | The price was not found in the system.                                                   |
| SubscriptionTypeNotFound   | 404         | The SubscriptionType was not found in the system.                                        |

#### PhoneTemplate

| Code                             | HTTP Status | User Message                                                         |
| -------------------------------- | ----------- | -------------------------------------------------------------------- |
| PhoneTemplateNotFound            | 404         | The PhoneTemplate was not found in the system.                       |
| PhoneTemplateUnsupportedLanguage | 400         | The phone template is not supported in the specified '{0}' language. |

#### EmailTemplate

| Code                             | HTTP Status | User Message                                                         |
| -------------------------------- | ----------- | -------------------------------------------------------------------- |
| EmailTemplateNotFound            | 404         | The PhoneTemplate was not found in the system.                       |
| EmailTemplateUnsupportedLanguage | 400         | The email template is not supported in the specified '{0}' language. |
| EmailTemplateUnsupportedEvent    | 400         | The email template is not supported in the specified '{0}' event.    |

#### Payment

| Code                      | HTTP Status | User Message                                                            |
| ------------------------- | ----------- | ----------------------------------------------------------------------- |
| PaymentNotFound           | 400         | The payment was not found in the system.                                |
| InvalidPaymentStatus      | 400         | Payment cannot be processed in its current status                       |
| AppPaymentGatewayRequired | 400         | The AppIntegrationId is required before process generate checkout link. |

#### User

| **Code**                    | **HTTP Status** | **User Message**                                                                                                  |
| --------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------- |
| UserNotFound                | 404             | The user was not found in the system.                                                                             |
| AccessDenied                | 403             | The user's access was denied.                                                                                     |
| Unauthorized                | 401             | The user is not authorized to access the requested resource. The request is missing the required Auth-Key header. |
| InvalidCredentials          | 403             | Invalid credentials. The username or password is incorrect.                                                       |
| EmailAddressAlreadyExists   | 409             | The email address already exists in the system.                                                                   |
| InvalidEmailAddress         | 400             | The email address is not in the correct format.                                                                   |
| UsernameAlreadyExists       | 409             | The username already exists in the system.                                                                        |
| InvalidUsername             | 400             | The username is not in the correct format.                                                                        |
| UsernameInvalid             | 400             | The username is invalid.                                                                                          |
| EmailAddressAlreadyVerified | 400             | The email address is already verified.                                                                            |
| PhoneNumberAlreadyExists    | 409             | The phone number already exists in the system.                                                                    |
| PhoneNumberAlreadyVerified  | 409             | The phone number is already verified.                                                                             |
| UserInvalidPhoneNumber      | 400             | The phone number is not in the correct format. The phone number must be following the E.164 format.               |
| UserLocked                  | 403             | The user is locked. Please contact support.                                                                       |
| UserSuspended               | 403             | The user is suspended. Please contact support.                                                                    |
| UserDeleted                 | 403             | The user is deleted.                                                                                              |
| UserInactive                | 403             | The user status is inactive.                                                                                      |
| DeviceAlreadyAdded          | 409             | The device has already been added for this user.                                                                  |
| InvalidPassword             | 400             | The password is not in the correct format.                                                                        |
| PasswordMismatch            | 400             | The password and confirm password do not match.                                                                   |
| RateLimitExceeded           | 429             | API call exceeded rate limit due to too many requests.                                                            |
| ExternalLoginFailed         | 400             | There was an error while creating the external login.                                                             |
| InvalidLoginName            | 400             | The login name is not in the correct format or not enough data.                                                   |
| MFARequired                 | 401             | Multi-factor authentication is required.                                                                          |
| InvalidOTPCode              | 400             | The OTP code is invalid.                                                                                          |
| OTPCodeExpired              | 400             | The OTP code has expired.                                                                                         |
| DeviceNotYetConfigured      | 409             | The device has not yet been configured for this user.                                                             |
| UserAlreadyAddedDevice      | 409             | The device has already been added for this user.                                                                  |
| UserActivateFailed          | 403             | Activate failed. User must be in Inactive status, but current status is {Status}.                                 |
| UserDeactivateFailed        | 403             | Deactivate failed. User must be in Active status, but current status is {Status}.                                 |
| UserLockFailed              | 403             | Lock failed. User must be in Active status, but current status is {Status}.                                       |
| UserUnlockFailed            | 403             | Unlock failed. User must be in Locked status, but current status is {Status}.                                     |
| UserSuspendFailed           | 403             | Suspend failed. User must be in Active status, but current status is {Status}.                                    |
| UserUnsuspendedFailed       | 403             | Unsuspended failed. User must be in *Suspended* status, but current status is {Status}.                           |

#### Wallet

| Code                       | HTTP status | User message                                                                 |
| -------------------------- | ----------- | ---------------------------------------------------------------------------- |
| WalletEarningEventNotFound | 404         | The WalletEarningEvent was not found in the system.                          |
| WalletNotFound             | 404         | The Wallet was not found in the system.                                      |
| WalletActionRequired       | 400         | Please choose a wallet to use for the refund after the package upgrade.      |
| InvalidAmount              | 400         | The amount input must be less than the current wallet and greater than zero. |
