Skip to content

Authentication

Every call to https://api.zemodata.com/v1 carries API credentials. You create them in the portal under API keys. Each key has one authentication mode; your plan decides which modes you may use (a mode your plan doesn’t allow answers auth.mode_not_allowed).

Mode Send Good for
Bearer secret Authorization: Bearer zd_live_sk_… Getting started, server-side code
Signed requests Key ID + an HMAC signature per request Production: the secret never travels
OAuth client credentials A short-lived token from POST /oauth/token Enterprise plans, many services
  • Test keys (zd_test_…) read a made-up test dataset. They never spend credits; spending calls report what a live key would pay in meta.credits_would_charge.
  • Live keys (zd_live_…) read real data and spend credits. You can create them once your email is confirmed and your account approved. Owners and admins need two-step sign-in first.

Secrets are shown once, when the key is created or rotated. If you lose one, rotate the key: the old secret keeps working for the overlap time you choose, so you can switch without downtime.

Credential Format
Bearer or signing secret zd_{env}_sk_ + 40 letters and digits
Key ID (public) zd_{env}_kid_ + 20 letters and digits
OAuth client ID / secret zd_{env}_cid_ + 20 / zd_{env}_cs_ + 40

{env} is test or live. The prefixes are registered with GitHub secret scanning: a secret pushed to a public repository is revoked automatically and the organization’s owners get an email.

A key can only call endpoints its scopes allow. A missing scope answers 403 auth.scope_missing. Scopes can’t be added to an existing key.

Scope Allows
search Fields, taxonomy and geo lookups (and search and count, when they are live)
enrich POST /v1/person/enrich, POST /v1/company/enrich
unlock POST /v1/unlock, POST /v1/estimate
search, unlock or enrich Records by ID (GET /v1/person/{id}, GET /v1/company/{id}): any one of them
usage_read GET /v1/usage
ledger_read GET /v1/credits, GET /v1/ledger
bulk Bulk jobs (/v1/bulk/jobs*)
webhooks Reserved for managing webhooks with a key (coming soon; manage webhooks in the portal today)

Keys can also be narrowed to some data products, an IP allowlist (others get auth.ip_not_allowed), an expiry date, a rate limit and a daily credit cap.

Send the secret in the Authorization header. GET /v1/whoami is free and needs no scope, so it is the easiest way to check a key.

python/whoami.py
"""Check that your API key works: GET /v1/whoami (free, needs no scope)."""
import json
import os
import urllib.request
BASE = os.environ.get("ZEMO_API_BASE", "https://api.zemodata.com")
SECRET = os.environ["ZEMO_API_KEY"] # zd_test_sk_… or zd_live_sk_…
request = urllib.request.Request(
f"{BASE}/v1/whoami",
headers={"Authorization": f"Bearer {SECRET}"},
)
with urllib.request.urlopen(request, timeout=30) as response:
me = json.load(response)
print("organization:", me["org_id"])
print("key:", me["public_id"], f"({me['env']}, {me['auth_mode']})")
print("scopes:", ", ".join(me["scopes"]))
print("products:", ", ".join(me["products"]) or "(all granted products)")

The secret stays on your side. Every request carries four headers:

X-Zemo-Key-Id: zd_live_kid_Q8f3…
X-Zemo-Timestamp: 1795439785
X-Zemo-Nonce: 6f1c2e9a8b7d4c3e2f1a0b9c8d7e6f5a
X-Zemo-Signature: v1=<hex HMAC-SHA256(secret, canonical string)>

The canonical string is six lines joined with \n (UTF-8, no newline at the end):

METHOD upper case: GET, POST
/v1/path the path, without the query
sorted_query key=value pairs, RFC 3986 encoded, sorted by key then value, joined with &
(an empty line when there is no query)
TIMESTAMP Unix time in seconds
NONCE 16 to 64 characters, new for every request
hex(SHA-256(body)) of the exact bytes you send (SHA-256 of the empty string when there is none)

Rules that trip people up:

  • The timestamp must be within 300 seconds of our clock, in seconds, not milliseconds (auth.timestamp_skew).
  • A nonce can be used once in 10 minutes, retries included (auth.replayed).
  • In the query, a + means a space. Decode every name and value, then encode it again with RFC 3986 rules (%20 for a space; letters, digits and -._~ stay as they are) before sorting.
  • Hash the body bytes you actually send, not a re-serialised copy of your JSON.
python/signed_request.py
"""Call the API in signed mode: key ID + secret, an HMAC-SHA256 signature per request."""
import hashlib
import hmac
import json
import os
import secrets
import time
import urllib.parse
import urllib.request
def _encode(value: str) -> str:
return urllib.parse.quote(value, safe="-._~") # RFC 3986: a space is %20
def canonical_string(method: str, path: str, query: str, timestamp: str, nonce: str, body: bytes) -> str:
"""Six lines: method, path, sorted query, timestamp, nonce, SHA-256 of the body."""
pairs = sorted(
(_encode(key), _encode(value)) for key, value in urllib.parse.parse_qsl(query, keep_blank_values=True)
)
return "\n".join(
[
method.upper(),
path,
"&".join(f"{key}={value}" for key, value in pairs),
timestamp,
nonce,
hashlib.sha256(body).hexdigest(),
]
)
def signature(secret: str, canonical: str) -> str:
return "v1=" + hmac.new(secret.encode(), canonical.encode(), hashlib.sha256).hexdigest()
def signed_request(method: str, url: str, body: bytes = b"") -> urllib.request.Request:
parts = urllib.parse.urlsplit(url)
timestamp = str(int(time.time())) # seconds, not milliseconds
nonce = secrets.token_hex(16) # new for every request, retries included
canonical = canonical_string(method, parts.path, parts.query, timestamp, nonce, body)
headers = {
"X-Zemo-Key-Id": os.environ["ZEMO_KEY_ID"], # zd_test_kid_…
"X-Zemo-Timestamp": timestamp,
"X-Zemo-Nonce": nonce,
"X-Zemo-Signature": signature(os.environ["ZEMO_API_SECRET"], canonical),
}
if body:
headers["Content-Type"] = "application/json"
return urllib.request.Request(url, data=body or None, headers=headers, method=method)
if __name__ == "__main__":
base = os.environ.get("ZEMO_API_BASE", "https://api.zemodata.com")
with urllib.request.urlopen(signed_request("GET", f"{base}/v1/whoami"), timeout=30) as response:
me = json.load(response)
print("signed in as", me["public_id"], "with", me["auth_mode"], "requests")

Check your own implementation against these. The secret is a made-up test value; all three samples above reproduce every vector (they are tested against them).

secret: zd_test_sk_0123456789abcdefghijABCDEFGHIJ0123456789
GET /v1/whoami, no query, no body, timestamp 1795439785, nonce 6f1c2e9a8b7d4c3e2f1a0b9c8d7e6f5a
canonical: GET\n/v1/whoami\n\n1795439785\n6f1c2e9a8b7d4c3e2f1a0b9c8d7e6f5a\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
signature: v1=e182740a3557ca128a9450b165ee0d9e0beb1d924215bd3ef6b7c12dba46f8ad
GET /v1/person/search?q=caf%C3%A9+bar&path=a%2Fb&keep=~._-&space=x%20y
timestamp 1795439787, nonce 0123456789abcdef
canonical: GET\n/v1/person/search\nkeep=~._-&path=a%2Fb&q=caf%C3%A9%20bar&space=x%20y\n1795439787\n0123456789abcdef\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
signature: v1=c1b480fbf97a444053cd470563ecea9a0539f13ad9c497ff0ef363f9a6fe4e2b
POST /v1/person/enrich, body {"email": "ada@example.com", "min_likelihood": 6}
timestamp 1795439788, nonce a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
canonical: POST\n/v1/person/enrich\n\n1795439788\na1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6\n6a2a1499942f647f2aa3f083928f132f0e29991ce4d11325f114011d825151e5
signature: v1=e54b04debabce4e8a92fc030cf7e61bc4ed86e4f90b4462d112e344c85355cde

Signed-mode errors: auth.signature_invalid, auth.timestamp_skew, auth.replayed, auth.mode_not_allowed.

An OAuth app is a key with the oauth mode. Its client ID is zd_{env}_cid_… and its secret zd_{env}_cs_…. Exchange them for an access token, then send the token as a bearer:

Terminal window
curl -s -u "$ZEMO_CLIENT_ID:$ZEMO_CLIENT_SECRET" \
-d "grant_type=client_credentials&scope=enrich unlock" \
https://api.zemodata.com/oauth/token
# {"access_token": "eyJ…", "token_type": "Bearer", "expires_in": 900, "scope": "enrich unlock"}
curl -s -H "Authorization: Bearer eyJ…" https://api.zemodata.com/v1/whoami
  • Tokens last 900 seconds. Ask for a new one when it expires (there is no refresh token).
  • The scopes you ask for must be within the app’s scopes.
  • Tokens are JWTs signed with RS256; the public keys are at /.well-known/jwks.json. Revoking the app stops tokens already issued.
  • Errors carry the OAuth error field as well as the problem code: a wrong client ID or secret is 401 with error: invalid_client; a bad grant type or scope is 400 with error: unsupported_grant_type or invalid_scope.