The following document presents reference information about error status codes and messages that are used in Vouchery. All responses that start with 4xx or 5xx are considered failures. Each response includes an error code and an error message.
The following example based on the "Create a campaign" endpoint presents a basic structure.
- Please mind that header information is omitted.
- as a result, we get 422 responses, saying that the "type" of a campaign is invalid (for example instead of "SubCampaign", "SubCampaignEE" was passed)
422 Unprocessable Entity
{
"type": "error",
"error": true,
"code": "invalid_type",
"message": "Invalid object type.",
"errors": [
{
"attribute": "type",
"code": "invalid",
"message": "value not supported"
}
],
"object": null
}
HTTP Status Codes
HTTP Status code | Text | Description |
---|---|---|
401 | Unauthorized | Authorization has failed |
403 | Forbidden error | You are not permitted to access this resource |
404 | Not Found | The requested resource could not be found. |
422 | Unprocessable entity | Unprocessable error. Validation failed. |
500 | Internal Server Error | This is an error that's on our side. We instantly track such situations and react as soon as possible. |
Error Codes for 422
Reason | Description |
---|---|
random_part_length_too_short | For example: When creating vouchers - the "Voucher prefix" is too short. |
can_not_be_empty | For example: When creating a campaign - "Campaign name" is empty. |
can_not_be_null | For example: When creating a campaign - "Campaign name" is null. |
not_match_format | For example: When creating a campaign - "Campaign type" doesn't meet the right format |
must_be_unique | For example: When creating a campaign - the "Campaign name" is not unique. |
invalid_choice | For example: When creating a campaign - the "Campaign name" is not unique. |
not_a_number | For example: When creating a campaign - "Vouchery maximum number of redemptions per single code" is not a number. |
invalid_url | For example: When editing a campaign - The URL format is broken |
value_too_low | For example: When generating vouchers batch where the prefix is too low to cover all possible vouchers' uniqueness. |
value_conflict | For example: When trying to set a sub-campaign budget larger than a main campaign. |
length_out_of_range | For example: When generating vouchers and their prefix is too short to cover all possible vouchers' uniqueness. |
value_out_of_range | For example: When generating vouchers and their postfix length is too short to cover all possible vouchers' uniqueness. |
already_confirmed | For example: When confirming a redemption - Meaning that redemption has already been confirmed |
voucher_inactive | For example: When creating a redemption - A voucher is NOT active (for example its lifetime passed) |
validation_error | For example: When creating a campaign - "Parent campaign id" is not found. |
invalid | For example: When creating a campaign - "Campaign type" doesn't match the expected value. |
redemption_rejected | For example: When creating a redemption - A voucher has already been used. |
not_found | For example: When creating a redemption - A voucher does not exist. |
Example: Create a redemption
Let's examine error responses based on one of the most commonly used "create a redemption" endpoints.
Assumptions:
- The campaign uses a generic voucher named: "SALE-20".
- The total transaction cost must be higher than 30$.
- The customer needs to belong to the "VIP client" segment.
Step 1: Let's try to redeem with a fault Voucher name like: "SALE-200". As a result, we get the 422 error with a message that Voucher can not be found.
422 Unprocessable Entity
{
"type": "error",
"error": true,
"code": "not_found",
"message": "Voucher was not found"
}
Step 2: Let's fix the voucher name to "SALE-20" and try to redeem with a "total transaction cost" lower than 30$. As a result, we get 422 error with a message that "Order value is lower than the required minimum value for the campaign"
422 Unprocessable Entity
{
"type": "error",
"error": true,
"code": "redemption_rejected",
"message": "Order value is lower than required minium value for the campaign"
}
Step 3: Let's now try to redeem with a "total transaction cost" higher than 30$, but without the "VIP client" segment. As a result, we get the 422 error with a message that the "Customer segment" rule was not satisfied.
422 Unprocessable Entity
{
"type": "error",
"error": true,
"code": "redemption_rejected",
"message": "Customer categories rule wasn't satisfied""
}
Head over to Rejected Redemptions Messages for a further possible explanation of the 422 error.