Errors

Vouchery API will return error responses on invalid requests. Each response will include error_code and message. For POST and PATCH requests, a list of detailed errors will be returned, including attribute name and, in some cases, expected value or range.
Please keep in mind, however, the rejected voucher response is not considered an error.

"responses": {
      "401": {
        "description": "Not authorized"
      },
      "404": {
        "description": "Not found"
      },
      "422": {
        "description": "Unprocessable entity",
        "content": {
          "type": "Error",
          "error": true,
          "code": "invalid",
          "message": "Redemption is invalid",
          "errors": [
              {
                  "attribute": "transaction_id",
                  "code": "must_be_unique",
                  "message": "Transaction must be unique"
              }
          ]
        }
      },
      "500": {
        "description": "Internal error"
      }
    }

Example of 422 error response body:

{
    "type": "Error",
    "error": true,
    "code": "invalid",
    "message": "Redemption is invalid",
    "errors": [
        {
            "attribute": "transaction_id",
            "code": "must_be_unique",
            "message": "Transaction must be unique"
        }
    ],
    "object": "Object that was to be updated"
}

Here are other scenarios that may occur in the case of the 422 error response:

redemption:
          attributes:
            base:
              can_not_delete_already_confirmed: "was already previously confirmed and can not be updated or deleted"
            confirmed:
              already_confirmed: "was already previously confirmed"
            expires_at:
              expired: "date has already passed"
            voucher:
              not_valid_at_this_time: "is not valid at this time"
              expired: "has expired"
              unique_code_already_used: "was already used"
              no_value_left: "has no value left"
            campaign:
              maximum_redemptions_exceeded: "maximum number of redemptions has been reached"
              budget_exceeded: "maximum budget has already been reached"
              no_rewards: "doesn't have any reward"
              no_reward_matched: "doesn't have any reward that fits trigger conditions"
            customer:
              blank: "identifier is required to redeem this voucher"
              not_match: "identifier is not valid. Voucher is related to a different customer."
            total_transaction_cost:
              not_a_number: "must be a decimal number"
              below_campaign_minimum: "must be greater than or equal to the campaign minimum of %{count}"
            transaction_id:
              blank: "is required"
              taken: "must be unique"