HyperTrackDocs

Authenticate with scoped API keys

Create a scoped API key on the Setup page, send it as a Bearer token, revoke it, and move off the account secret key.

Introduction

A scoped API key authenticates your server to the HyperTrack REST APIs. It replaces Basic authentication with your account ID and secret key.

A scoped key has these properties:

  • Least privilege. A key is read only (api:read) or read and write (api:write).
  • One key per system. Each key has its own label. Give each service, environment or vendor its own key.
  • Revoke one key. When you revoke a key, only that key stops working. Your other keys and your secret key keep working.
  • Not stored in readable form. HyperTrack stores only a hash of the key. The dashboard shows the full key once, when you create it.

A key starts with sk_ht_, followed by 40 letters and digits:

sk_ht_<40 letters and digits>

Create a key

  1. Open the Setup page in the dashboard.
  2. Create a scoped API key.
  3. Enter a label that names the system that will use the key, for example payroll-sync-production.
  4. Select the access:
    • Read only (api:read): the key can make GET requests and POST /orders/export.
    • Read and write (api:write): the key can make all requests that Basic authentication with the secret key can make.
  5. Copy the key and store it in your secret manager.

An account can have up to 20 active scoped keys.

⚠️ The key is shown once

HyperTrack cannot show the key again. If you lose it, create a new key and revoke the old one.

Use the key

Send the key in the Authorization header with the Bearer scheme:

Authorization: Bearer sk_ht_<your key>

The key works on the HyperTrack REST APIs at https://v3.api.hypertrack.com, the same endpoints that accept Basic authentication with your secret key. This example lists your orders:

curl https://v3.api.hypertrack.com/orders \
  -H "Authorization: Bearer $HYPERTRACK_API_KEY"

Keep the key on your server. Do not put it in a mobile app, in browser code, or in version control.

Get an access token with a scoped key

Create access token (POST /oauth/token) also accepts a scoped key in the Authorization header. You do not send client_id or client_secret:

curl -X POST https://v3.api.hypertrack.com/oauth/token \
  -H "Authorization: Bearer $HYPERTRACK_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"grant_type": "client_credentials"}'

The token cannot have more access than the key:

  • A read and write key gets the same tokens as Basic authentication.
  • A read only key gets the scope read.api.* when the request has no scope. A request for the scope *, or for any scope that is not a read scope, fails with 401.

A token stays valid until it expires (expires_in in the response), also when you revoke the key that created it.

Revoke a key

Revoke a key on the Setup page. Requests with the key fail with 401 within about 60 seconds, because the API caches the result of each key check for up to 60 seconds. Your other keys keep working.

Revoke a key at once when it leaves your control: for example, when it is in a log, in a repository, or with a vendor you no longer use.

What a 401 means

The API returns 401 Unauthorized when:

  • The Authorization header is missing, or its format is not Bearer sk_ht_<key>.
  • The key is not known, is revoked, or has expired.
  • A read only key is used for a request that writes data.

If a call that worked before fails with 401, check on the Setup page that the key is still active.

Move from the secret key

If your integration uses Basic authentication with your account ID and secret key, move it to scoped keys:

  1. On the Setup page, create one scoped key for each system that calls HyperTrack. Give each key the least access that the system needs.

  2. In each system, replace the Basic authentication header with the new key:

    Before: Authorization: Basic <base64 of AccountId:SecretKey>
    After:  Authorization: Bearer sk_ht_<your key>

    If the system gets tokens from POST /oauth/token with client_id and client_secret, send the scoped key in the Authorization header instead, as shown in Get an access token with a scoped key.

  3. Deploy, and make sure that the calls succeed.

  4. Write to help@hypertrack.com when nothing uses the secret key any more. We switch off the old secret key for you after you confirm.

Until you ask us to switch it off, your secret key keeps working.

Webhook signing secret

The webhook signing secret is separate from your API keys. It does not change when you create or revoke a scoped key, or when you move from the secret key. To check the signature of a webhook, see Validate webhook notifications.

On this page