Skip to content

Unredeem a huggg

Overview

PATCH /api/v2/hugggs/{hugggId}/redemptions/{redemptionId}
PATCH /api/v2/hugggs/{hugggId}/redemptions/latest

An endpoint which takes a huggg ID or shortcode and redemption ID or 'latest' alias. This endpoint is intended for use by ePOS systems to unredeem a huggg.

Request

Note that the access token must be for a user that has permission to unredeem hugggs on behalf of a specific merchant.

URL Parameters

Key Value Description
{huggg_id} String REQUIRED identifier for the huggg; either an Id or shortcode.
{redemption_id} String REQUIRED Either a redemption id, or the alias latest.

Typically, API users will use the latest alias, which returns the most recent redemption on a huggg if one exists. Only the most recent redemption will be unredeemable, and re-redemption of an unredeemed huggg can be performed through the regular redeem endpoint.

Data Parameters

The request data should be a partial redemption entity. The only valid patch is to set the "redeemed" value to false.

Example

PATCH /api/v2/hugggs/abc123/redemptions/latest
Authorization: Bearer abc123
Content-Type: application/json

{
    "redeemed" : false
}

Response

This endpoint returns the updated Redemption entity, which will have the redeemed status set to false and the updated_at field populated with the time that the update occurred.

HTTP/1.1 200 OK

{
    "data" : {
        "id" : "b1b04370-610c-4261-b547-75952566d77c",
        "huggg_id" : "c86f2c57-f232-11e8-8aba-0aac06f9ab10",
        "redeemed" : false,
        "creation_at" : "2018-11-20T17:34:08Z",
        "updated_at" : "2018-12-15T10:18:45Z",
        "location_id" : "bristol17"
    }
}

If the logged in user does not have permission to unredeem for this huggg's merchant, HTTP 403 will be returned.

HTTP/1.1 403 Forbidden

{
    "error" : "Cannot unredeem this huggg."
}

If the huggg id or shortcode is invalid, the redemption id is invalid, or the /latest alias is used with an unredeemed huggg, the response will be HTTP 404:

HTTP/1.1 404 Not Found

{
    "error" : "huggg not found"
}

HTTP/1.1 404 Not Found

{
    "error" : "Redemption not found"
}

If the specific redemption is not redeemed, HTTP 422 will be returned:

HTTP/1.1 422 Unprocessable Entity

{
    "error" : "huggg not redeemed."
}