Using the API
Authentication
Send your key in one header, manage and cap keys, and let an agent sign in with OAuth.
Every request carries your API key in the x-api-key header, or as Authorization: Bearer <key> if your tool prefers that. The key is the whole credential, with no token exchange and no session. An AI agent that should not hold a key can sign in with OAuth instead.
계정을 확인하는 중입니다.
Send your key
curl "https://www.socialcrawl.dev/v1/tiktok/profile?handle=charlidamelio" \
-H "x-api-key: $SOCIALCRAWL_API_KEY"const res = await fetch(
"https://www.socialcrawl.dev/v1/tiktok/profile?handle=charlidamelio",
{ headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! } },
);import os
import requests
res = requests.get(
"https://www.socialcrawl.dev/v1/tiktok/profile",
params={"handle": "charlidamelio"},
headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
)Can I send it as a Bearer token?
Yes. Most agents, MCP clients and HTTP tools (Postman, n8n, Make, OpenAPI generators) reach for Authorization: Bearer first, and /v1 reads the same key from there. The same format check, credit limit, rate limits and billing apply.
curl "https://www.socialcrawl.dev/v1/tiktok/profile?handle=charlidamelio" \
-H "Authorization: Bearer $SOCIALCRAWL_API_KEY"| You send | What happens |
|---|---|
x-api-key only | The key is read from x-api-key |
Authorization: Bearer <key> only | The key is read from the Bearer token. The word Bearer is not case-sensitive |
| Both | x-api-key wins. A wrong x-api-key is never rescued by the Bearer token |
Authorization with no scheme, or Basic | 401 MISSING_API_KEY, and the message tells you to add the Bearer scheme |
The OpenAPI spec at /v1/openapi.json declares both forms as alternative security schemes (ApiKeyAuth and BearerAuth), so a generated client can use either.
Never put the key in a URL or query string. It ends up in browser history, proxy logs and referrer headers.
Can several agents share one key?
Yes. Have each agent send an x-client-tag header that names it. Then split its spend with GET /v1/credits/usage?group_by=tag. A malformed tag is ignored, not refused, and the response says so in X-Client-Tag-Ignored.
Create and manage keys
What does a key look like?
A key is sc_ followed by 32 random bytes in base64url, so every key is 46 characters long. The dialog that creates a key shows it in full once. After that the dashboard shows only its last 4 characters. You can reveal it again after a fresh sign-in, but support never sees the plaintext, so copy it into a secret manager first.
How do I create one?
- Sign up at socialcrawl.dev. You get 100 welcome credits at once.
- Open Dashboard → API Keys.
- Click Create Key and name it after where it runs (
production,staging,local-dev). - Copy the key from the one-time reveal dialog.
Active keys per account are capped at 5, and every key draws on the same credit balance.
| Rule | Value |
|---|---|
| Storage | SHA-256 hash for auth lookup, AES-256-GCM encrypted for retrieval |
| Revocation | Soft delete. A revoked key returns 401 INVALID_API_KEY on its next request |
| Expiry | None. A key works until you revoke or rotate it |
| Credit limit | Optional cap on what one key may spend. Unset means no cap |
| Rate limits | Applied per key, not per account. See Rate limits |
How do I rotate a key?
Create the new key, deploy it, confirm traffic has moved, then revoke the old one. Revocation takes effect on the next request, so revoking first means downtime. If a key has leaked, revoke it at once and accept the downtime, because anyone holding a live key can spend your credits.
Credit limits per key
Every key on your account draws on the same balance. A test script that loops or a CI job that misfires can therefore spend the credits production depends on. A credit limit caps what one key may ever spend. That key stops at the cap, and every other key keeps working.
Production key no limit <- your real traffic, unaffected
Test key 500 credit limit <- stops at 500, whatever it doesSet it in Dashboard → API Keys. When you create a key, tick Set a credit limit for this key and enter a number. Leave it unticked for no limit, which is the default and what a production key usually wants. You can add, change or remove a limit at any time from the key's ⋯ menu.
Once a capped key reaches its limit, its requests return 402 KEY_BUDGET_EXCEEDED and nothing is deducted. Your account balance is untouched, so the rest of your integration keeps running.
Changes take effect on the key's next request.
Read a key's limit from the API
A capped key's responses carry X-Key-Credits-Remaining, the credits it may still spend after that call. GET /v1/keys/current is free and returns the limit, what the key has used and what it can spend now. Account endpoints shows the call and its response.
OAuth for agents
An API key is the simplest credential. Use OAuth when an AI agent acts for someone and should not hold their key. The person signs in and approves the agent, and the agent gets its own access token. You send that token as Authorization: Bearer <token>.
Each approved agent has its own connection key behind its tokens. Its spend is tracked on its own, you can cap it, and you can disconnect it in Dashboard → Connected apps without touching your own keys.
| The agent | Flow | Start here |
|---|---|---|
| Has no browser, such as a CLI or a background job | Agent registration: it shows you a link and a 6-digit code, and you enter the code after signing in | /auth.md |
| Can open a browser and receive a redirect | Authorization code with PKCE, with resource=https://www.socialcrawl.dev | /.well-known/oauth-authorization-server |
An agent can discover all of this from a 401, whose WWW-Authenticate header links to /.well-known/oauth-protected-resource.
A token carries scopes, and /v1 checks them before anything is billed:
| Scope | Allows |
|---|---|
socialcrawl:read | Free account reads: /v1/credits/balance, /v1/keys/current and GET /v1/notifications |
socialcrawl:spend | Every data call that can bill credits, and marking notifications read |
socialcrawl:manage | With socialcrawl:spend: monitors, cohorts, web jobs, listening, webhooks and schedules |
A token is bound to one service, so a token issued for the hosted MCP server is refused on /v1, and the reverse. Tokens expire, and the agent renews them with its refresh token. An API key is never scope-checked.
When authentication fails
A 401 has two codes, and they need different fixes. Neither is retryable, and neither costs credits.
| Code | Status | What happened | Fix |
|---|---|---|---|
MISSING_API_KEY | 401 | No key reached us in x-api-key or as a Bearer token | Add the header, and check that your proxy passes it on |
INVALID_API_KEY | 401 | The key is malformed, unknown, revoked or expired | Check the key in Dashboard → API Keys |
An API key is never refused with a 403. Only an OAuth access token can get one, as INSUFFICIENT_SCOPE. The two refusals you might expect as a 403 are both 402, because they are about spend, not permission:
| Code | Status | What happened | Fix |
|---|---|---|---|
INSUFFICIENT_CREDITS | 402 | The account balance is lower than the endpoint cost | Top up in Dashboard → Billing |
KEY_BUDGET_EXCEEDED | 402 | This key spent its own credit limit. The account balance is fine | Raise or reset the key's limit |
They need opposite fixes, so branch on error.type, not on the status. Topping up an account that was never short will not unblock a capped key.
Keep keys safe
- Never ship a key in client-side code. Browser and mobile bundles are readable, and every request made with your key is billed to you. Put a server route in front of the API and keep the key on the server.
- Use a separate key per environment. Revoking a staging key should not take down production.
- Cap every key that is not production. A CI or test key with a credit limit cannot drain the balance production runs on.
- Store keys in a secret manager, not in git. Encrypted environment variables, AWS Secrets Manager and 1Password all work.
- Call
https://www.socialcrawl.devexactly, and refuse redirects if you like. No/v1route answers with a 3xx on that host, and a path with a trailing slash or a different case answers 404. Only the bare host redirects:https://socialcrawl.devanswers 301 tohttps://www.socialcrawl.dev, and anyhttp://URL answers 308 tohttps://. A client that never follows redirects therefore never sends its key to another host.
