Globagift Docs
API / Developers

Authentication

Authenticate to the Globagift API with merchant or distributor keys, choose scopes, and sign redemption requests from acceptance points.

The API uses three kinds of credential. Each one is shown in full only once, when it is created. Keep them on your servers and out of browsers, apps and source control.

CredentialLooks likeSent asCreated by
Merchant API keygg_...Authorization: Bearer headerThe merchant, in the portal or with the API
Distributor keyggd_...Authorization: Bearer headerGlobagift, during distributor onboarding
Acceptance-point credentialAn id and a secretFour signed gg- headersThe merchant, with the API

Merchant API keys

A merchant key acts for one brand. Create keys in the merchant portal under Integrations, API access, or with POST /v1/api-keys using a key that has keys:manage.

Keys are either test or live. Test keys work in the sandbox. Live keys become available once the brand is approved for live use.

curl -s "https://engine-sandbox.globagift.io/v1/me" \
  -H "Authorization: Bearer gg_your_test_key"

Scopes

Give each key only the scopes its integration needs, and use a separate key for each integration so you can revoke one without affecting the others.

ScopeAllows
products:readList and read card products
products:writeCreate and update card products
cards:issueIssue cards, and read products and cards while issuing
cards:readList and read cards, and look up a card by redemption code
cards:manageSuspend, release and void cards
redemptions:readList redemptions
reports:readActivity, outstanding balance and ageing reports
webhooks:readList webhook subscriptions and events
webhooks:writeCreate and delete webhook subscriptions
acceptance:manageCreate acceptance points and issue or revoke their credentials
keys:manageCreate, list and revoke API keys

A request with a valid key but without the right scope returns 403 with code insufficient_scope.

Revoke a key with DELETE /v1/api-keys/{id} or in the portal. It stops working straight away.

Distributor keys

A distributor key acts for the distributor, not for any merchant. It carries one of two scopes:

ScopeAllows
distribution:readList granted merchants and their products, look up orders and read statements
distribution:sellEverything in distribution:read, plus reserve, capture and release

Globagift creates distributor keys during onboarding. See Distributor marketplace.

Signed requests from acceptance points

Redemptions do not use an API key. They are signed by an acceptance point: a till, site or app where cards are spent. This keeps redemption authority with the place that takes the card, not with every system that holds a key.

Set one up with a merchant key that has acceptance:manage:

  1. Create the acceptance point with POST /v1/acceptance-points, giving a name and a channel of store, ecommerce or app.
  2. Issue a credential with POST /v1/acceptance-points/{id}/credentials. The response holds the credential id and its secret. The secret is shown once.

Build the signature

Every signed request carries four headers:

HeaderValue
gg-credentialThe credential id
gg-timestampThe current Unix time in seconds
gg-nonceA new random value for every request, such as a UUID
gg-signatureThe signature, in lowercase hex

To build gg-signature:

  1. Take the exact raw request body you will send, and compute its SHA-256 in lowercase hex.
  2. Join these five values with a newline (\n) between each: the upper-case method, the path, the timestamp, the body hash and the nonce.
  3. Compute HMAC-SHA256 of that string, keyed with the credential secret, and encode it in lowercase hex.
sign.mjs
import { createHash, createHmac, randomUUID } from 'node:crypto';

export function signedHeaders({ credentialId, secret, method, path, body }) {
  const timestamp = String(Math.floor(Date.now() / 1000));
  const nonce = randomUUID();
  const bodyHash = createHash('sha256').update(body).digest('hex');
  const canonical = [method.toUpperCase(), path, timestamp, bodyHash, nonce].join('\n');
  const signature = createHmac('sha256', secret).update(canonical).digest('hex');
  return {
    'gg-credential': credentialId,
    'gg-timestamp': timestamp,
    'gg-nonce': nonce,
    'gg-signature': signature,
  };
}

Sign the same string you send. If your HTTP client re-serialises JSON, the body hash will not match.

When a signature is refused

Each of these returns 401 with code invalid_signature:

  • the signature does not match the body, path or secret;
  • the timestamp is more than five minutes from the server's clock;
  • the nonce has already been used with this credential;
  • the credential has been revoked.

The response does not say which, so check the clock on the device and sign each attempt afresh. To retry a redemption, see Retries and idempotency.

Revoke a credential with DELETE /v1/acceptance-points/{id}/credentials/{credential_id} when a device is lost or retired.

On this page