Globagift Docs
API / Developers

Quickstart

Make your first Globagift API calls in the sandbox. Check your key, find a product, issue a gift card, claim it and read its balance.

This walkthrough uses the sandbox and a merchant test key. Every response shown here came from a sandbox run; codes and secrets are replaced with placeholders.

Before you start

You need a test API key for a sandbox brand. In the merchant portal, open Integrations, go to API access and create a key with these scopes:

  • products:read
  • cards:issue
  • cards:read

The full key is shown once. Store it in your secret manager and never put it in client-side code. If API access is not shown for your brand, contact Globagift.

Set two shell variables for the examples:

export GG_BASE=https://engine-sandbox.globagift.io
export GG_KEY=gg_your_test_key

Check your key

curl -s "$GG_BASE/v1/me" -H "Authorization: Bearer $GG_KEY"
{ "merchant_id": "3f0c2b1e-8d4a-4c55-9a1e-6b2d7e9f1a20" }

A 401 with code authentication_failed means the key is missing, mistyped or revoked.

Find a product

curl -s "$GG_BASE/v1/card-products?status=active" -H "Authorization: Bearer $GG_KEY"
{
  "data": [
    {
      "id": "7a9e4c12-5b3d-4f8e-a6c1-2d9b0e7f4c35",
      "name": "Preview gift card",
      "currency": "EUR",
      "min_amount": 500,
      "max_amount": 50000,
      "status": "active"
    }
  ]
}

Amounts are integer minor units, so 500 is EUR 5.00. Fields not needed here are left out.

Issue a card

curl -s -X POST "$GG_BASE/v1/cards" \
  -H "Authorization: Bearer $GG_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1001" \
  -d '{"card_product_id":"7a9e4c12-5b3d-4f8e-a6c1-2d9b0e7f4c35","amount":5000}'
{
  "id": "c41d8e2a-0b6f-4a3c-9e57-1f2a8b6d3e90",
  "state": "active",
  "currency": "EUR",
  "amount": 5000,
  "balance": 5000,
  "claim_code": "CLAIM_CODE",
  "redemption_code": "GG-REDEMPTION-CODE",
  "redemption_code_last4": "WS8X",
  "expires_at": null
}

claim_code is returned once. If you repeat the request with the same Idempotency-Key, you get the same card back without the claim code, so save it from the first response.

Claim the card

The cardholder claims the card with its claim code. This endpoint is public, so call it from your claim page without a key.

curl -s -X POST "$GG_BASE/v1/claims" \
  -H "Content-Type: application/json" \
  -d '{"claim_code":"CLAIM_CODE"}'
{
  "redemption_code": "GG-NEW-REDEMPTION-CODE",
  "balance": 5000,
  "currency": "EUR",
  "merchant_name": "Preview",
  "product_name": "Preview gift card",
  "expires_at": null,
  "qr_data_url": "data:image/png;base64,..."
}

The first claim replaces the redemption code returned at issue. Show the cardholder this one. Opening the claim again returns the same code. See Claiming replaces the redemption code.

Check the balance

curl -s "$GG_BASE/v1/balance?code=GG-NEW-REDEMPTION-CODE"
{ "balance": 5000, "currency": "EUR" }

Next steps

On this page