Skip to content

Redeem a huggg

Overview

This endpoint facilitates redemption of a specific huggg at a given location.

POST /api/v2/hugggs/{id}/redemptions

Request

Note that the access token provided to this request must be for the customer that owns the huggg, or for a session that has permission to redeem hugggs on behalf of a merchant that the huggg is valid for. That is: a user can redeem their own huggg at any location; a merchant can redeem a huggg on behalf of a user at any of their locations.

URL Parameters

Key Value Description
{id} String REQUIRED unique identifier for the huggg. This could be a huggg Id or shortcode.

Data Parameters

Key Value Description
{location_id} String The huggg-provided unique identifier that references the redemption location.

location_id must be provided in order for the request to be valid. Appropriate values will have been provided by huggg when the location is registered on the API.

Examples

POST /api/v2/hugggs/abc123/redemptions

{
    "location_id" : "bristol17"
}

Response

The successful response returns the newly-created Redemption entity.

HTTP/1.1 201 Created

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

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

HTTP/1.1 403 Forbidden

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

If the huggg id or shortcode is invalid, the response will be HTTP 404:

HTTP/1.1 404 Not Found

{
    "error" : "huggg not found"
}

If the huggg has already been redeemed, HTTP 405 will be returned, indicating that the POST request is not valid.

HTTP/1.1 405 Method not allowed

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

Similarly, if the huggg has expired without being redeemed, HTTP 405 will be returned, indicating that the POST request is not valid.

HTTP/1.1 405 Method not allowed

{
    "error" : "huggg is expired and cannot be redeemed."
}

If the location id is invalid, HTTP 422 will be returned.

HTTP/1.1 422 Unprocessable Entity

{
    "error" : "Invalid location."
}