Skip to content

Authentication

All API endpoints require an API key. There is no anonymous tier — even the free plan requires a signed-up account and a generated key.

Create a key at portal.thesma.dev/dashboardAPI keysCreate key. The plaintext key is shown once at creation; the server stores only a SHA-256 hash.

The API accepts two header formats for the same key. Both are equivalent — the same middleware validates either.

The format shown in all marketing copy, blog posts, and recipes. Prefer this.

Terminal window
curl -H "X-API-Key: gd_live_a1b2c3d4..." \
"https://api.thesma.dev/v1/us/sec/companies/AAPL"

The conventional REST form. Accepted by the same middleware; same key.

Terminal window
curl -H "Authorization: Bearer gd_live_a1b2c3d4..." \
"https://api.thesma.dev/v1/us/sec/companies/AAPL"

Pick one per codebase and be consistent. Mixing them in the same application works but has no benefit.

The Python SDK, CLI, and most integration examples read the key from the THESMA_API_KEY environment variable if it is set. Exporting the key in your shell is the least-friction option:

Terminal window
export THESMA_API_KEY="gd_live_a1b2c3d4..."
from thesma import ThesmaClient
client = ThesmaClient() # reads THESMA_API_KEY from the environment
PartValue
Prefixgd_live_
Suffix128-bit random hex (32 characters)
Total length40 characters
StoragePlaintext shown once at creation; server stores SHA-256 hash only

The gd_live_ prefix identifies Thesma production keys. Don’t paste keys starting with any other prefix (e.g., th_live_ from older SDK versions) — those will fail authentication against the current API.

401 Unauthorized — missing or invalid key

Section titled “401 Unauthorized — missing or invalid key”
{
"error": "unauthorized",
"error_code": "missing_api_key",
"message": "API key is missing. Pass it via the X-API-Key or Authorization: Bearer header."
}
{
"error": "unauthorized",
"error_code": "invalid_api_key",
"message": "The provided API key is not valid or has been revoked."
}

403 Forbidden — key is disabled or the account is suspended

Section titled “403 Forbidden — key is disabled or the account is suspended”
{
"error": "forbidden",
"error_code": "account_suspended",
"message": "This account is suspended. Contact support@thesma.dev."
}

For the full error catalogue (status codes, error_code values, common causes), see Errors.