Errors

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 codeTextDescription
401UnauthorizedAuthorization has failed
403Forbidden errorYou are not permitted to access this resource
404Not FoundThe requested resource could not be found.
422Unprocessable entityUnprocessable error. Validation failed.
500Internal Server ErrorThis is an error that's on our side. We instantly track such situations and react as soon as possible.

Error Codes for 422

ReasonDescription
random_part_length_too_shortFor example: When creating vouchers - the "Voucher prefix" is too short.
can_not_be_emptyFor example: When creating a campaign - "Campaign name" is empty.
can_not_be_nullFor example: When creating a campaign - "Campaign name" is null.
not_match_formatFor example: When creating a campaign - "Campaign type" doesn't meet the right format
must_be_uniqueFor example: When creating a campaign - the "Campaign name" is not unique.
invalid_choiceFor example: When creating a campaign - the "Campaign name" is not unique.
not_a_numberFor example: When creating a campaign - "Vouchery maximum number of redemptions per single code" is not a number.
invalid_urlFor example: When editing a campaign - The URL format is broken
value_too_lowFor example: When generating vouchers batch where the prefix is too low to cover all possible vouchers' uniqueness.
value_conflictFor example: When trying to set a sub-campaign budget larger than a main campaign.
length_out_of_rangeFor example: When generating vouchers and their prefix is too short to cover all possible vouchers' uniqueness.
value_out_of_rangeFor example: When generating vouchers and their postfix length is too short to cover all possible vouchers' uniqueness.
already_confirmedFor example: When confirming a redemption - Meaning that redemption has already been confirmed
voucher_inactiveFor example: When creating a redemption - A voucher is NOT active (for example its lifetime passed)
validation_errorFor example: When creating a campaign - "Parent campaign id" is not found.
invalidFor example: When creating a campaign - "Campaign type" doesn't match the expected value.
redemption_rejectedFor example: When creating a redemption - A voucher has already been used.
not_foundFor 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.