# Quickstart

Source: https://docs.globagift.io/docs/api/quickstart
Description: 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 [#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](https://www.globagift.io/en/contact).

Set two shell variables for the examples:

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

<Steps>
<Step>

### Check your key [#check-your-key]

```bash
curl -s "$GG_BASE/v1/me" -H "Authorization: Bearer $GG_KEY"
```

```json
{ "merchant_id": "3f0c2b1e-8d4a-4c55-9a1e-6b2d7e9f1a20" }
```

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

</Step>
<Step>

### Find a product [#find-a-product]

```bash
curl -s "$GG_BASE/v1/card-products?status=active" -H "Authorization: Bearer $GG_KEY"
```

```json
{
  "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.

</Step>
<Step>

### Issue a card [#issue-a-card]

```bash
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}'
```

```json
{
  "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.

</Step>
<Step>

### Claim the card [#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.

```bash
curl -s -X POST "$GG_BASE/v1/claims" \
  -H "Content-Type: application/json" \
  -d '{"claim_code":"CLAIM_CODE"}'
```

```json
{
  "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](/docs/api/cards#claiming-replaces-the-redemption-code).

</Step>
<Step>

### Check the balance [#check-the-balance]

```bash
curl -s "$GG_BASE/v1/balance?code=GG-NEW-REDEMPTION-CODE"
```

```json
{ "balance": 5000, "currency": "EUR" }
```

</Step>
</Steps>

## Next steps [#next-steps]

- Redeem the card at a till: [Issue and redeem cards](/docs/api/cards#redeem-at-an-acceptance-point).
- Learn the retry and error rules: [Conventions](/docs/api/conventions).
- Selling many merchants' cards? Read [Distributor marketplace](/docs/api/distributor).
