Authorization header:
- A login token, from logging in with your email and password. It works on every endpoint.
- An API key, created in the app. It works only on the endpoints its scope allows, and is the one to use for scripts that only read data and for the API reference playground.
Which method works where
Log in
Send your email and password toPOST /v1/login/:
400.
Login is rate limited. Log in once and reuse the token until it expires,
instead of logging in before every request.
Send the token
Add the header to every request. The wordToken and the space after it are
required:
Token lifetime
A request with a missing, expired or revoked token returns
401. Log in again
to get a new token.
Two-factor authentication
If your account has two-factor authentication,POST /v1/login/ returns 202
with a challenge instead of a token:
challenge_id with the code from your authenticator app to
POST /v1/totp/login/:
"method": "email", GlassMarkets sends a six-digit
code to your account email. Submit that code and the same challenge_id to
POST /v1/email-2fa/login/ instead. Email verification is available to accounts
created through an organization invitation. If you choose an authenticator app,
password sign-in uses that app.
Both endpoints return the same response as a normal login.
Log out
POST /v1/logout/ revokes the token that made the request. Other tokens of
the same account stay valid.
API keys
An API key acts as your account, with your account’s current data access, but only on the endpoints its scope allows. A key does not expire with your login session, so use one for scripts instead of a login token.Create a key
- In the GlassMarkets app, open the account menu and choose Settings.
- Next to API keys, choose Manage API keys.
- Enter a Key name, tick the Permissions the key needs, and enter your current password. If your account has two-factor authentication, also enter an authentication or recovery code.
- Choose Create key and copy the key. It starts with
gm_live_and is shown only once.
A key expires one year after it is created. An account can have up to 20
active keys. Changing or resetting your password revokes all of them.
Send the key
Add the header to every request. The wordApiKey and the space after it are
required:
Try requests in the API reference
The pages in the API reference tab that accept API keys have a playground for sending a request from the page. Use a key with onlymetrics:read there,
created just for the playground, and revoke it when you are done. The
playground sends the key to the API through the docs site’s proxy.
Listing your organizations with GET /v1/organizations/ needs a key with
reported_metrics:write or mm_metrics:read. A metrics:read key gets 403
on that page.
Revoke a key
In Settings → Manage API keys, choose Revoke next to the key. The key stops working immediately.Errors
A wrong, expired or revoked key returns401:
403:
POST /v1/logout/ accepts only login tokens and returns 401 for an API key.
