A firm client gives your own system access to one company profile in Sureshake, called a firm in these pages. It has a client ID and a secret, which you exchange for a token that lasts one hour. To get your first token, follow Get started.
POST /v2/oauth/token, metrics and information requests aren’t in the generated API reference yet, so these guides are their reference.
Create a client
Owners and admins of the firm can create clients. Open the firm’s /entities/<id>/control/entity?tab=settings page, or select Control, Entity Info, the Company record tab, then Workspace settings. Under API clients, enter a Client name, tick the Scopes it needs, and select Create client. Copy the Client ID and Secret, because the secret is shown once.
A firm token or a read or write API key can’t create or revoke a client, so a credential your script holds can’t make another. Those routes accept a signed-in session, which is what the product uses, or a Sureshake-issued admin key acting as its owner:
| Route | What it does | Success |
|---|---|---|
GET /v2/entities/{id}/api-clients |
Lists the firm’s clients | 200 with data, a list of clients without their secrets |
POST /v2/entities/{id}/api-clients |
Creates a client | 201 with data.client and data.clientSecret |
DELETE /v2/entities/{id}/api-clients/{clientId} |
Revokes a client | 200 with data.success |
Scopes
A client holds the scopes you tick when you create it, and you can’t change them afterwards. To change them, create a new client.
| Scope | Allows |
|---|---|
metrics:read |
GET /v2/metrics |
metrics:write |
POST /v2/metrics, for its own firm |
reports:read |
GET /v2/reports |
portfolio:read |
GET /v2/entities and GET /v2/entities/{id}/holdings |
requests:read |
GET /v2/information-requests and GET /v2/information-requests/{id} |
requests:write |
POST /v2/information-requests, and /fulfil, /decline and /cancel on a request |
companies:lookup |
POST /v2/companies/lookup, billed against the firm’s membership tier |
webhooks:manage |
Webhook endpoints for its own firm. Creating one returns 503 where webhooks are not configured |
Get a token
POST /v2/oauth/token takes no other credential. Send the client ID and secret in the body, form-encoded or as JSON, or as HTTP Basic authentication.
curl -sS https://api.sureshake.com/v2/oauth/token \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=metrics:read reports:read"scope is optional and space-separated. It narrows this token to some of the client’s scopes. Without it, the token gets all of them.
{
"access_token": "api_at_jliJibDOyRwcwJlrfnLwamU99su_UtIzN53kz-1S9b0",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "metrics:read reports:read"
}There is no refresh token. When a token expires, request a new one. This route allows about 30 requests per minute per IP address on each API server, so you can occasionally get more before a 429. So keep using a token until it expires rather than requesting one per call.
Errors from this route have their own shape:
| Status | error |
Meaning |
|---|---|---|
| 400 | invalid_request |
A required field is missing or malformed |
| 400 | invalid_scope |
You asked for a scope the client doesn’t hold |
| 401 | invalid_client |
The client ID or secret is wrong, the client was revoked, or the firm has no owner or a suspended one |
| 429 | temporarily_unavailable |
Over the rate limit. Wait retry-after seconds |
| 500 | server_error |
An unexpected failure. Retry with backoff |
{
"error": "invalid_scope",
"error_description": "Client is not permitted the requested scope"
}Use the token
Send it as a bearer token:
curl -sS https://api.sureshake.com/v2/entities \
-H "Authorization: Bearer $SURESHAKE_TOKEN"Where a firm token works
A route accepts a firm token only if it opted in, and each one names the scope it needs.
| Route | Scope |
|---|---|
GET /v2/entities |
portfolio:read |
GET /v2/entities/{id}/holdings |
portfolio:read |
GET /v2/metrics |
metrics:read |
POST /v2/metrics |
metrics:write |
GET /v2/reports |
reports:read |
GET /v2/information-requests, GET /v2/information-requests/{id} |
requests:read |
POST /v2/information-requests, and its /fulfil, /decline, /cancel |
requests:write |
POST /v2/companies/lookup |
companies:lookup |
/v2/entities/{id}/webhooks and the routes under it |
webhooks:manage |
Every other route that needs a credential answers a firm token with 401. That includes GET /v2/reports/{id} and GET /v2/reports/shared-with-me. A route that works without a credential gives a firm token no extra access.
What a firm token can read
A firm token acts for the firm, not for a person. It is limited to:
- The firm’s own data: its entity, its reports and its holdings.
- Reports another company has fulfilled to the firm, through
GET /v2/reports. - Metrics: public
sec-edgarrows for any company, and private rows for the firm itself or for a company that has given the firm All reports follow access. - With
companies:lookup, verified company records, billing contacts and public contacts throughPOST /v2/companies/lookup.
Nothing else its owner can read comes with it. Reports shared with the owner personally, and the owner’s other companies, are out of reach. A share is addressed to a person, so to read those, use an API key with GET /v2/reports/shared-with-me.
Errors when using a token
| Status | error.code |
error.message |
Meaning |
|---|---|---|---|
| 401 | UNAUTHORIZED |
Invalid or expired API token |
The token is wrong, expired or revoked, or the firm has no owner |
| 401 | UNAUTHORIZED |
This route does not accept API tokens |
The route isn’t open to firm tokens |
| 403 | FORBIDDEN |
API token is missing the 'metrics:read' scope |
The token doesn’t hold the scope this route needs |
| 403 | FORBIDDEN |
Varies | The token can’t act on that resource, such as another firm’s |
| 403 | ACCOUNT_SUSPENDED |
This firm's owner account is suspended. |
The firm’s owner is suspended |
| 503 | ACCESS_STATE_UNAVAILABLE |
Authentication is temporarily unavailable. |
Retry with backoff |
Revoke or replace a client
Select Revoke next to the client under API clients. The client and every token it holds stop working at once.
A secret can’t be rotated or shown again. To replace one, create a new client, switch your system to it, then revoke the old one.
When the firm changes hands
A token acts as whoever owns the firm at the moment of each request, so a change of owner applies immediately and you don’t need a new client. A firm with no owner can’t get or use a token.