Authentication
How to authenticate with the Serpex API using Bearer API keys.
All Serpex API requests are authenticated with a Bearer API key sent in the Authorization header.
Get your API key
- Sign in at app.serpex.dev.
- Navigate to API Keys in the left sidebar.
- Click Create API Key, give it a name, and copy the key.
API keys start with sk_ and are shown once — copy it immediately and store it somewhere safe.
Sending the header
Include the key on every request:
Authorization: Bearer sk_your_api_keycURL example:
curl -X POST https://api.serpex.dev/api/search \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"q": "openai gpt-4"}'SDK — key is set once on the client:
import { SerpexClient } from "serpex";
// Pass the key at construction time — all subsequent calls use it.
const client = new SerpexClient(process.env.SERPEX_API_KEY!);import os
from serpex import SerpexClient
client = SerpexClient(os.environ["SERPEX_API_KEY"])Error responses
| Status | Meaning |
|---|---|
401 Unauthorized | Key missing, malformed, or revoked. |
402 Payment Required | Key is valid but the organization has zero credits. |
Keep your key secret
Your API key grants full access to your organization's credits. Never expose it in client-side JavaScript, public repositories, or build logs.
Best practices:
- Store the key in an environment variable (
SERPEX_API_KEY). - Call the API from a backend service, not directly from a browser.
- Rotate the key immediately in the dashboard if you suspect it was leaked — old keys are invalidated the moment you delete them.
Multiple keys
You can create multiple API keys per organization — useful for separating environments (development, staging, production) or per-service access without sharing a single credential.