socialcrawl-mcp 2.2.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +49 -21
  2. package/dist/app.d.ts +3 -3
  3. package/dist/app.js +75 -12
  4. package/dist/chatgpt-text.d.ts +23 -0
  5. package/dist/chatgpt-text.js +310 -0
  6. package/dist/client-tag.d.ts +13 -0
  7. package/dist/client-tag.js +17 -0
  8. package/dist/client.d.ts +5 -0
  9. package/dist/client.js +14 -4
  10. package/dist/constants.d.ts +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/context.d.ts +13 -0
  13. package/dist/context.js +1 -0
  14. package/dist/cost-guard.d.ts +15 -3
  15. package/dist/cost-guard.js +39 -3
  16. package/dist/data/docs-async.d.ts +2 -2
  17. package/dist/data/docs-async.js +24 -3
  18. package/dist/data/docs-handwritten.js +968 -906
  19. package/dist/data/docs.js +7 -1
  20. package/dist/data/endpoints.js +11153 -7559
  21. package/dist/data/examples.js +2 -2
  22. package/dist/data/guide.d.ts +2 -2
  23. package/dist/data/guide.js +2 -2
  24. package/dist/data/outputs.js +425 -290
  25. package/dist/data/platforms.js +214 -55
  26. package/dist/data/recipes.js +1 -1
  27. package/dist/data/registry-meta.d.ts +10 -10
  28. package/dist/data/registry-meta.js +10 -10
  29. package/dist/endpoint-resolve.d.ts +1 -0
  30. package/dist/endpoint-resolve.js +10 -1
  31. package/dist/endpoint-surface.d.ts +64 -0
  32. package/dist/endpoint-surface.js +472 -0
  33. package/dist/hydration.js +28 -3
  34. package/dist/instructions.md +18 -18
  35. package/dist/listings.d.ts +24 -0
  36. package/dist/listings.js +55 -0
  37. package/dist/oauth/config.d.ts +39 -4
  38. package/dist/oauth/config.js +50 -6
  39. package/dist/oauth/resource-server.d.ts +12 -2
  40. package/dist/oauth/resource-server.js +5 -20
  41. package/dist/oauth/scopes.d.ts +2 -2
  42. package/dist/oauth/scopes.js +4 -4
  43. package/dist/param-aliases.d.ts +7 -0
  44. package/dist/param-aliases.js +15 -0
  45. package/dist/pricing.js +5 -1
  46. package/dist/resources/sample-gate.js +34 -1
  47. package/dist/resources/supplier-tokens.d.ts +1 -1
  48. package/dist/resources/supplier-tokens.js +2 -0
  49. package/dist/result.js +8 -0
  50. package/dist/schemas/async.d.ts +41 -31
  51. package/dist/schemas/async.js +28 -9
  52. package/dist/schemas/outputs.d.ts +4 -4
  53. package/dist/schemas/tools.d.ts +18 -6
  54. package/dist/schemas/tools.js +24 -4
  55. package/dist/server.js +6 -5
  56. package/dist/timeouts.d.ts +24 -1
  57. package/dist/timeouts.js +32 -0
  58. package/dist/tools/account.d.ts +4 -1
  59. package/dist/tools/account.js +1 -1
  60. package/dist/tools/async-common.js +3 -1
  61. package/dist/tools/check-balance.d.ts +4 -2
  62. package/dist/tools/check-balance.js +9 -0
  63. package/dist/tools/discover-runs.js +117 -11
  64. package/dist/tools/discover.js +3 -0
  65. package/dist/tools/estimate.js +10 -1
  66. package/dist/tools/list-endpoints.js +5 -3
  67. package/dist/tools/manage.js +2 -0
  68. package/dist/tools/monitors.d.ts +7 -1
  69. package/dist/tools/monitors.js +26 -2
  70. package/dist/tools/pricing.js +11 -1
  71. package/dist/tools/request.js +10 -2
  72. package/dist/types.d.ts +9 -1
  73. package/dist/value-prices.d.ts +18 -0
  74. package/dist/value-prices.js +79 -0
  75. package/package.json +75 -75
@@ -22,924 +22,986 @@ const newsBand = (() => {
22
22
  : "a metered band";
23
23
  })();
24
24
  export const HANDWRITTEN = {
25
- overview: `# SocialCrawl API
26
-
27
- Unified social, commerce, and research data API. One API key, one response envelope, ${PLATFORMS.length} platforms, ${ENDPOINTS.length} endpoints — social media, commerce, marketplaces & product reviews, retail (Amazon, Walmart, Target, Home Depot, eBay, Klarna, AliExpress, Etsy, Sephora, H&M, Kohl's, Wayfair, Gumtree, Google Shopping), app stores, places, travel & local (Tripadvisor, Yelp, Google Business), business & software reputation (Trustpilot, G2), jobs & salaries, markets & finance, US congressional trading disclosures, news, web research plus full web scraping & browser automation, on-page SEO audits, prediction markets, search trends, Korean search (Naver), content/sentiment analysis, and cross-platform Prism composites.
28
-
29
- The web-scraping/crawling/browser-automation surface (the \`web\` platform) is driven by \`socialcrawl_manage\` with \`area: "web"\`; the stateful monitors wrapper by \`area: "monitors"\`; the audience-filtered mention search (\`/v1/cohorts/*\`) by \`area: "cohorts"\`. Everything else goes through \`socialcrawl_request\`.
30
-
31
- ## Base URL
32
-
33
- https://www.socialcrawl.dev/v1
34
-
35
- ## Authentication
36
-
37
- Pass your API key in the \`x-api-key\` header with every request. See the \`authentication\` topic.
38
-
39
- ## Platforms
40
-
41
- ${PLATFORMS.map((p) => `- ${p.slug} (${p.endpointCount} endpoint${p.endpointCount === 1 ? "" : "s"})`).join("\n")}
42
-
43
- ## Credits
44
-
45
- Three billing models:
46
-
47
- - **Ladder** — the tier rate per request: standard ${CREDIT_LADDER.standard}, advanced ${CREDIT_LADDER.advanced}, premium ${CREDIT_LADDER.premium} credits.
48
- - **Flat** — a per-endpoint override (e.g. \`GET /v1/search/everywhere\` at 20cr; the ${free.length} free endpoints at 0cr).
49
- - **Metered** (${metered.length} endpoints) — the charge depends on the request. An upfront ceiling is deducted and automatically refunded down to the work actually done.
50
-
51
- Cache hits, idempotent replays, empty results, and upstream failures all cost 0 credits. Use the \`socialcrawl_estimate\` tool (or \`socialcrawl_endpoint\` with id \`pricing\`) for the exact cost of every endpoint.
52
-
53
- ## Judgments — free by default
54
-
55
- Judged lists (comments, posts, reviews, and the main searches) label every row for free under \`computed.labels\`, and searches score each row's relevance to your query under \`computed.relevance\`. Metered presets (e.g. \`label=mention\`), \`label=intent\` with \`offer=\`, and a topic of your own in \`relevant_to=\` add 1 credit per started 25 rows judged fresh. \`judgments=off\` turns them off; \`dry_run=1\` previews the cost for free. See the \`judgments\` topic.
56
-
57
- ## Walks, polling and dedupe
58
-
59
- Where an endpoint declares them: \`max_pages\` walks several pages in one call (each billed as a page), \`since\` / \`stop_at_id\` stop a walk at rows you already hold, \`seen=<id>\` drops rows you already received and discounts the page, and \`min_views\` / \`max_age_days\` / \`sort_rows\` filter and order rows server-side. See the \`pagination\` topic.
60
-
61
- ## Batches and background jobs
62
-
63
- \`POST /v1/prism/profiles\` (50 handles), \`POST /v1/prism/post-stats\` (100 URLs) and \`POST /v1/prism/comment-lookup\` (25 comments) answer a batch in one call; \`POST /v1/prism/jobs\` runs up to 5,000 items in the background at the same per-row prices. See the \`batch-jobs\` topic.
64
-
65
- ## Free API discovery
66
-
67
- \`utility/endpoints\`, \`utility/endpoint\`, \`utility/capabilities\`, \`utility/plan\`, \`utility/quickstart\`, and \`utility/llms\` describe the API from inside the API at 0 credits — see the \`discovery\` topic.
68
-
69
- ## Meta Endpoints
70
-
71
- API-key-authed endpoints that return account metadata at 0 credit cost:
72
-
73
- - \`GET /v1/credits/balance\` — current credit balance and recent deduction summary.
74
- - \`GET /v1/credits/transactions\` — the itemised credit ledger (deductions and refunds, keyed by \`request_id\`).
75
-
76
- Both are served by the \`socialcrawl_account\` tool.
77
-
78
- ## Full Reference
79
-
80
- For complete endpoint documentation with parameters, examples, and response schemas:
81
- https://www.socialcrawl.dev/llms-full.txt
82
-
83
- ## OpenAPI Spec
84
-
25
+ overview: `# SocialCrawl API
26
+
27
+ Unified social, commerce, and research data API. One API key, one response envelope, ${PLATFORMS.length} platforms, ${ENDPOINTS.length} endpoints — social media, commerce, marketplaces & product reviews, retail (Amazon, Walmart, Target, Home Depot, eBay, Klarna, AliExpress, Etsy, Sephora, H&M, Kohl's, Wayfair, Gumtree, Google Shopping), app stores, places, travel & local (Tripadvisor, Yelp, Google Business), business & software reputation (Trustpilot, G2), jobs & salaries, markets & finance, US congressional trading disclosures, news, web research plus full web scraping & browser automation, on-page SEO audits, prediction markets, search trends, Korean search (Naver), content/sentiment analysis, and cross-platform Prism composites.
28
+
29
+ The web-scraping/crawling/browser-automation surface (the \`web\` platform) is driven by \`socialcrawl_manage\` with \`area: "web"\`; the stateful monitors wrapper by \`area: "monitors"\`; the audience-filtered mention search (\`/v1/cohorts/*\`) by \`area: "cohorts"\`. Everything else goes through \`socialcrawl_request\`.
30
+
31
+ ## Base URL
32
+
33
+ https://www.socialcrawl.dev/v1
34
+
35
+ ## Authentication
36
+
37
+ Pass your API key in the \`x-api-key\` header with every request. See the \`authentication\` topic.
38
+
39
+ ## Platforms
40
+
41
+ ${PLATFORMS.map((p) => `- ${p.slug} (${p.endpointCount} endpoint${p.endpointCount === 1 ? "" : "s"})`).join("\n")}
42
+
43
+ ## Credits
44
+
45
+ Three billing models:
46
+
47
+ - **Ladder** — the tier rate per request: standard ${CREDIT_LADDER.standard}, advanced ${CREDIT_LADDER.advanced}, premium ${CREDIT_LADDER.premium} credits.
48
+ - **Flat** — a per-endpoint override (e.g. \`GET /v1/search/everywhere\` at 20cr; the ${free.length} free endpoints at 0cr).
49
+ - **Metered** (${metered.length} endpoints) — the charge depends on the request. An upfront ceiling is deducted and automatically refunded down to the work actually done.
50
+
51
+ Cache hits, idempotent replays, empty results, and upstream failures all cost 0 credits. Use the \`socialcrawl_estimate\` tool (or \`socialcrawl_endpoint\` with id \`pricing\`) for the exact cost of every endpoint.
52
+
53
+ ## Judgments — free by default
54
+
55
+ Judged lists (comments, posts, reviews, and the main searches) label every row for free under \`computed.labels\`, and searches score each row's relevance to your query under \`computed.relevance\`. Metered presets (e.g. \`label=mention\`), \`label=intent\` with \`offer=\`, and a topic of your own in \`relevant_to=\` add 1 credit per started 25 rows judged fresh. \`judgments=off\` turns them off; \`dry_run=1\` previews the cost for free. See the \`judgments\` topic.
56
+
57
+ ## Walks, polling and dedupe
58
+
59
+ Where an endpoint declares them: \`max_pages\` walks several pages in one call (each billed as a page), \`since\` / \`stop_at_id\` stop a walk at rows you already hold, \`seen=<id>\` drops rows you already received and discounts the page, and \`min_views\` / \`max_age_days\` / \`sort_rows\` filter and order rows server-side. See the \`pagination\` topic.
60
+
61
+ ## Batches and background jobs
62
+
63
+ \`POST /v1/prism/profiles\` (50 handles), \`POST /v1/prism/post-stats\` (100 URLs) and \`POST /v1/prism/comment-lookup\` (25 comments) answer a batch in one call; \`POST /v1/prism/jobs\` runs up to 5,000 items in the background at the same per-row prices. See the \`batch-jobs\` topic.
64
+
65
+ ## Free API discovery
66
+
67
+ \`utility/endpoints\`, \`utility/endpoint\`, \`utility/capabilities\`, \`utility/plan\`, \`utility/quickstart\`, and \`utility/llms\` describe the API from inside the API at 0 credits — see the \`discovery\` topic.
68
+
69
+ ## Meta Endpoints
70
+
71
+ API-key-authed endpoints that return account metadata at 0 credit cost:
72
+
73
+ - \`GET /v1/credits/balance\` — current credit balance and recent deduction summary.
74
+ - \`GET /v1/credits/transactions\` — the itemised credit ledger (deductions and refunds, keyed by \`request_id\`).
75
+
76
+ Both are served by the \`socialcrawl_account\` tool.
77
+
78
+ ## Full Reference
79
+
80
+ For complete endpoint documentation with parameters, examples, and response schemas:
81
+ https://www.socialcrawl.dev/llms-full.txt
82
+
83
+ ## OpenAPI Spec
84
+
85
85
  https://www.socialcrawl.dev/v1/openapi.json`,
86
- authentication: `# SocialCrawl API — Authentication
87
-
88
- Every request requires an \`x-api-key\` header with your API key. Keys start with \`sc_\`.
89
-
90
- \`\`\`
91
- curl https://www.socialcrawl.dev/v1/tiktok/profile?handle=charlidamelio \\
92
- -H "x-api-key: sc_your_api_key_here"
93
- \`\`\`
94
-
95
- ## Where to get a key
96
-
97
- Sign up at https://www.socialcrawl.dev — every account starts with 100 free credits, no credit card required.
98
-
99
- ## Key management
100
-
101
- - Keys can be rotated from the dashboard at any time.
102
- - Maximum 5 active keys per account.
103
- - Revoked keys stop working immediately.
104
- - A key can carry its own \`credit_limit\`. When that per-key cap is spent while the account still has credits, requests fail with \`KEY_BUDGET_EXCEEDED\` (402) — raise the key's cap rather than topping up the balance.
105
-
106
- ## Configuring the key in the MCP server
107
-
108
- **Local (stdio, \`npx socialcrawl-mcp\`):** the server reads \`SOCIALCRAWL_API_KEY\` from the environment of the MCP process. Set it in the MCP client config (Claude Desktop, Cursor, VS Code, etc.) or as a system environment variable.
109
-
110
- **Remote (Streamable HTTP, https://mcp.socialcrawl.dev/mcp):** send the key on every request as an \`Authorization: Bearer <key>\` or \`x-api-key: <key>\` header — in Claude Code: \`claude mcp add --transport http socialcrawl https://mcp.socialcrawl.dev/mcp --header "Authorization: Bearer sc_your_key"\`. Keys are never accepted in the URL or query string.
111
-
86
+ authentication: `# SocialCrawl API — Authentication
87
+
88
+ Every request requires an \`x-api-key\` header with your API key. Keys start with \`sc_\`.
89
+
90
+ \`\`\`
91
+ curl https://www.socialcrawl.dev/v1/tiktok/profile?handle=charlidamelio \\
92
+ -H "x-api-key: sc_your_api_key_here"
93
+ \`\`\`
94
+
95
+ ## Where to get a key
96
+
97
+ Sign up at https://www.socialcrawl.dev — every account starts with 100 free credits, no credit card required.
98
+
99
+ ## Key management
100
+
101
+ - Keys can be rotated from the dashboard at any time.
102
+ - Maximum 5 active keys per account.
103
+ - Revoked keys stop working immediately.
104
+ - A key can carry its own \`credit_limit\`. When that per-key cap is spent while the account still has credits, requests fail with \`KEY_BUDGET_EXCEEDED\` (402) — raise the key's cap rather than topping up the balance.
105
+
106
+ ## Configuring the key in the MCP server
107
+
108
+ **Local (stdio, \`npx socialcrawl-mcp\`):** the server reads \`SOCIALCRAWL_API_KEY\` from the environment of the MCP process. Set it in the MCP client config (Claude Desktop, Cursor, VS Code, etc.) or as a system environment variable.
109
+
110
+ **Remote (Streamable HTTP, https://mcp.socialcrawl.dev/mcp):** send the key on every request as an \`Authorization: Bearer <key>\` or \`x-api-key: <key>\` header — in Claude Code: \`claude mcp add --transport http socialcrawl https://mcp.socialcrawl.dev/mcp --header "Authorization: Bearer sc_your_key"\`. Keys are never accepted in the URL or query string.
111
+
112
112
  The discovery tools (\`socialcrawl_find\`, \`socialcrawl_endpoint\`, \`socialcrawl_estimate\`) work without a key — only calls that hit the API need one.`,
113
- credits: `# SocialCrawl API — Credits
114
-
115
- Every request costs credits. The MCP server validates and prices a call locally before making it, and the response envelope reports both \`credits_used\` and \`credits_remaining\`.
116
-
117
- ## The three billing models
118
-
119
- | Model | Endpoints | How it charges |
120
- |-------|-----------|----------------|
121
- | ladder | ${ENDPOINTS.filter((e) => e.pricing.model === "ladder").length} | The tier rate, charged per request. |
122
- | flat | ${ENDPOINTS.filter((e) => e.pricing.model === "flat").length} | A per-endpoint override off the ladder (includes the ${free.length} free endpoints). |
123
- | metered | ${metered.length} | Query-dependent: an upfront ceiling is deducted, then refunded down to the work actually done. |
124
-
125
- ### Tiers
126
-
127
- | Tier | Cost per request | Typical use |
128
- |------|------------------|-------------|
129
- | standard | ${CREDIT_LADDER.standard} credit | Profile, post, comment, and search endpoints; static reference data (app-store and Target categories, locations, languages) |
130
- | advanced | ${CREDIT_LADDER.advanced} credits | Trending feeds, audience analytics, ad transparency, GitHub composites, Polymarket research, retail product/review data (Amazon, Walmart, Target, Home Depot, eBay, Google Shopping), Trustpilot and Google Business reviews, hotel details, app-store search/info/reviews/charts |
131
- | premium | ${CREDIT_LADDER.premium} credits | AI-powered utilities (transcript generation), LinkedIn people/job search, GitHub profile-velocity, and the app-store listings-search databases |
132
-
133
- Counting every endpoint under its declared tier: standard ${REGISTRY_STATS.standardEndpoints}, advanced ${REGISTRY_STATS.advancedEndpoints}, premium ${REGISTRY_STATS.premiumEndpoints}.
134
-
135
- ### Metered endpoints
136
-
137
- A metered endpoint's real charge is decided by your query — quoting its base cost under-reports what you will pay. The router deducts a worst-case ceiling up front and refunds the difference when the work settles, so \`credits_used\` in the response envelope (and the \`X-Credits-Used\` header) is always the truth. Examples: \`prism/comments\` bills 1 credit per comment page scanned; \`search/news\` bills 2 credits plus 1 per country leg that returned articles; \`web/crawl\` holds \`limit\` credits and refunds every page it did not crawl.
138
-
139
- Use the \`socialcrawl_estimate\` tool with an \`id\` for any endpoint's exact band, rule, and price-driving parameters — and pass \`params\` (the exact query you will send) plus \`calls\` for an itemised hold and a whole-job budget.
140
-
141
- ### Judgments
142
-
143
- Judged lists carry free default labels (posts: sponsored, intent, niche · comments: sentiment, question, purchase_intent, complaint · reviews: sentiment, issue) and free relevance against your query. A metered preset, \`label=intent\` with \`offer=\`, or \`relevance=score|filter\` with \`relevant_to=\` holds 1 credit per started 25 rows of the page's judged-row cap (4 on a 100-row page; 5 on \`tiktok/search\`, 8 on \`linkedin/search/posts\` and \`search/multi\`) and settles to 1 credit per started 25 rows judged fresh. Rows judged before, cached pages and pages where nothing could be judged are free. \`dry_run=1\` returns \`data.estimate\` for 0 credits. See the \`judgments\` topic.
144
-
145
- ### Levers that change the bill
146
-
147
- - **\`max_pages\`** — walks up to N pages in one call; each page walked is billed as one call (a cached page is free), so the worst case is N × the page's hold.
148
- - **\`seen=<id>\`** — rows this account already received under the id are dropped and the page price falls with the share of repeats (page credits × new rows / rows, rounded up); a page of repeats is free. Join credits are never discounted.
149
- - **\`since\` / \`stop_at_id\`** — end a walk at rows you already hold; fewer pages billed.
150
- - **\`scan_pages\`** (comment lanes) — each page that added comments is billed; a page of only repeats is free.
151
- - **\`include=\`** — row joins hold per row and keep only rows filled fresh (see \`hydration\`).
152
-
153
- ## What is never charged
154
-
155
- - **Cache hits** (BIL-03) — the envelope includes \`"cached": true\` and no credits are deducted. TTLs run from 2 minutes (search) to 30 days (transcripts); see the \`caching\` topic.
156
- - **Idempotent replays** (BIL-02) — a repeat with the same \`Idempotency-Key\` returns the stored response, deducts 0, and sets \`X-Idempotent-Replay: true\`. 24h TTL.
157
- - **Empty results** (BIL-01) — an empty single-object lookup returns 404 \`RESOURCE_NOT_FOUND\` and an empty list returns 200 \`{items: []}\`; both auto-refund. You are never billed for a resource that does not exist or a search that matched nothing.
158
- - **Upstream and internal failures** — 502 \`UPSTREAM_ERROR\`, 503 \`SERVICE_UNAVAILABLE\`, 500 \`INTERNAL_ERROR\`, and request-deadline 504s all reverse the charge.
159
- - **Rejected requests** — 400/401/402/405/409/413/422/429 never deduct: validation runs before billing.
160
- - **The meta and discovery endpoints** — \`/v1/credits/balance\`, \`/v1/credits/transactions\`, the six \`utility/*\` discovery endpoints, reading background jobs (\`GET /v1/prism/jobs\`), and all monitor and web job/monitor/session management.
161
- - **A \`dry_run=1\` judgment preview.**
162
-
163
- ## Partial-coverage refund on universal search
164
-
165
- \`GET /v1/search/everywhere\` (flat 20cr) fans out across many sources. If no usable items come back at all you are fully refunded; if coverage falls below 50% of the sources actually called, half the fee is refunded (10cr charged). The response's \`coverage\`, \`sources_called\`, \`sources_failed\`, \`sources_pruned\`, and \`partial_failure\` fields show exactly what happened.
166
-
167
- ## Verifying a charge
168
-
169
- \`socialcrawl_account\` with \`view: "transactions"\` returns the credit ledger: every deduction and refund with \`amount\`, \`balance_after\`, \`endpoint\`, and \`request_id\`. Deductions are negative and refunds positive, so a page of amounts sums to the balance delta. Look up a specific call with \`requestId\` to see exactly what a metered endpoint settled at.
170
-
171
- ## Advisory warnings (ENV-03)
172
-
173
- Successful responses may include an optional \`data._warnings\` string array — non-fatal notices from the transform pipeline (e.g. an engagement-rate clamp, or \`walk_deadline_reached\` on a server-side page walk). Treat as observability hints, not as failures.
174
-
175
- **Dropped params are named.** A param the endpoint does not declare is dropped — never forwarded, never billed — and gets one \`data._warnings\` line: the closest declared name, the \`label=\` / \`relevance=\` form you probably meant, or "no such parameter". A rejected value's 400 carries \`details.allowed_values\`, \`details.example\` and, for a one-edit typo, \`details.did_you_mean\`.
176
-
177
- **\`meta.hint\`.** When a run of calls matches a cheaper pattern (the same handle on three platforms' profile lanes → \`prism/creator-card\`; 50 handles on one lane → \`POST /v1/prism/profiles\`; page 1 of the same list again → \`stop_at_id\`; comments on 5+ posts without \`label=\`), one response carries \`meta.hint\` with the suggestion and its price. Send the header \`X-SocialCrawl-Hints: off\` to suppress hints.
178
-
179
- ## Insufficient credits
180
-
113
+ credits: `# SocialCrawl API — Credits
114
+
115
+ Every request costs credits. The MCP server validates and prices a call locally before making it, and the response envelope reports both \`credits_used\` and \`credits_remaining\`.
116
+
117
+ ## The three billing models
118
+
119
+ | Model | Endpoints | How it charges |
120
+ |-------|-----------|----------------|
121
+ | ladder | ${ENDPOINTS.filter((e) => e.pricing.model === "ladder").length} | The tier rate, charged per request. |
122
+ | flat | ${ENDPOINTS.filter((e) => e.pricing.model === "flat").length} | A per-endpoint override off the ladder (includes the ${free.length} free endpoints). |
123
+ | metered | ${metered.length} | Query-dependent: an upfront ceiling is deducted, then refunded down to the work actually done. |
124
+
125
+ ### Tiers
126
+
127
+ | Tier | Cost per request | Typical use |
128
+ |------|------------------|-------------|
129
+ | standard | ${CREDIT_LADDER.standard} credit | Profile, post, comment, and search endpoints; static reference data (app-store and Target categories, locations, languages) |
130
+ | advanced | ${CREDIT_LADDER.advanced} credits | Trending feeds, audience analytics, ad transparency, GitHub composites, Polymarket research, retail product/review data (Amazon, Walmart, Target, Home Depot, eBay, Google Shopping), Trustpilot and Google Business reviews, hotel details, app-store search/info/reviews/charts |
131
+ | premium | ${CREDIT_LADDER.premium} credits | AI-powered utilities (transcript generation), LinkedIn people/job search, GitHub profile-velocity, and the app-store listings-search databases |
132
+
133
+ Counting every endpoint under its declared tier: standard ${REGISTRY_STATS.standardEndpoints}, advanced ${REGISTRY_STATS.advancedEndpoints}, premium ${REGISTRY_STATS.premiumEndpoints}.
134
+
135
+ ### Metered endpoints
136
+
137
+ A metered endpoint's real charge is decided by your query — quoting its base cost under-reports what you will pay. The router deducts a worst-case ceiling up front and refunds the difference when the work settles, so \`credits_used\` in the response envelope (and the \`X-Credits-Used\` header) is always the truth. Examples: \`prism/comments\` bills 1 credit per comment page scanned; \`search/news\` bills 2 credits plus 1 per country leg that returned articles; \`web/crawl\` holds \`limit\` credits and refunds every page it did not crawl.
138
+
139
+ Use the \`socialcrawl_estimate\` tool with an \`id\` for any endpoint's exact band, rule, and price-driving parameters — and pass \`params\` (the exact query you will send) plus \`calls\` for an itemised hold and a whole-job budget.
140
+
141
+ ### Judgments
142
+
143
+ Judged lists carry free default labels (posts: sponsored, intent, niche · comments: sentiment, question, purchase_intent, complaint · reviews: sentiment, issue) and free relevance against your query. A metered preset, \`label=intent\` with \`offer=\`, or \`relevance=score|filter\` with \`relevant_to=\` holds 1 credit per started 25 rows of the page's judged-row cap (4 on a 100-row page; 5 on \`tiktok/search\`, 8 on \`linkedin/search/posts\` and \`search/multi\`) and settles to 1 credit per started 25 rows judged fresh. Rows judged before, cached pages and pages where nothing could be judged are free. \`dry_run=1\` returns \`data.estimate\` for 0 credits. See the \`judgments\` topic.
144
+
145
+ ### Levers that change the bill
146
+
147
+ - **\`max_pages\`** — walks up to N pages in one call; each page walked is billed as one call (a cached page is free), so the worst case is N × the page's hold.
148
+ - **\`seen=<id>\`** — rows this account already received under the id are dropped and the page price falls with the share of repeats (page credits × new rows / rows, rounded up); a page of repeats is free. Join credits are never discounted.
149
+ - **\`since\` / \`stop_at_id\`** — end a walk at rows you already hold; fewer pages billed.
150
+ - **\`scan_pages\`** (comment lanes) — each page that added comments is billed; a page of only repeats is free.
151
+ - **\`include=\`** — row joins hold per row and keep only rows filled fresh (see \`hydration\`).
152
+ - **\`pages\`** (\`{platform}/profile/full\`, \`prism/format-lift\`) — reads up to 5 pages of posts in one call: the first at the flat price, each further page at the posts endpoint's own page price (1 credit, 5 on LinkedIn), with pages not read refunded.
153
+
154
+ ## Composites and partial answers
155
+
156
+ Composites (\`prism/*\`) charge in full when half their legs or more return data. They refund half when fewer do, and all when none do, naming each leg that failed (not a 404) in \`data._warnings\`. \`prism/answers\` reports \`data.premium_credits\`, the part of its flat price above its legs, so the legs plus \`premium_credits\` equal the charge.
157
+
158
+ ## What is never charged
159
+
160
+ - **Cache hits** (BIL-03) — the envelope includes \`"cached": true\` and no credits are deducted. TTLs run from 2 minutes (search) to 30 days (transcripts); see the \`caching\` topic.
161
+ - **Idempotent replays** (BIL-02) — a repeat with the same \`Idempotency-Key\` returns the stored response, deducts 0, and sets \`X-Idempotent-Replay: true\`. 24h TTL.
162
+ - **Empty results** (BIL-01) — an empty single-object lookup returns 404 \`RESOURCE_NOT_FOUND\` and an empty list returns 200 \`{items: []}\`; both auto-refund. You are never billed for a resource that does not exist or a search that matched nothing.
163
+ - **Upstream and internal failures** — 502 \`UPSTREAM_ERROR\`, 503 \`SERVICE_UNAVAILABLE\`, 500 \`INTERNAL_ERROR\`, and request-deadline 504s all reverse the charge.
164
+ - **Rejected requests** — 400/401/402/405/409/413/422/429 never deduct: validation runs before billing.
165
+ - **The meta and discovery endpoints** — \`/v1/credits/balance\`, \`/v1/credits/transactions\`, the six \`utility/*\` discovery endpoints, reading background jobs (\`GET /v1/prism/jobs\`), and all monitor and web job/monitor/session management.
166
+ - **A \`dry_run=1\` judgment preview.**
167
+
168
+ ## Partial-coverage refund on universal search
169
+
170
+ \`GET /v1/search/everywhere\` (flat 20cr) fans out across many sources. If no usable items come back at all you are fully refunded; if coverage falls below 50% of the sources actually called, half the fee is refunded (10cr charged). The response's \`coverage\`, \`sources_called\`, \`sources_failed\`, \`sources_pruned\`, and \`partial_failure\` fields show exactly what happened.
171
+
172
+ ## Verifying a charge
173
+
174
+ \`socialcrawl_account\` with \`view: "transactions"\` returns the credit ledger: every deduction and refund with \`amount\`, \`balance_after\`, \`endpoint\`, and \`request_id\`. Deductions are negative and refunds positive, so a page of amounts sums to the balance delta. Look up a specific call with \`requestId\` to see exactly what a metered endpoint settled at.
175
+
176
+ A walk (\`max_pages\`, \`max_items\`, \`max_credits\`) bills each page as its own ledger row, and every one of them, refunds included, carries the walk's own request id as \`metadata.walk_request_id\`. \`request_id\` set to the walk's id returns the whole walk's charges and refunds in one read, and each receipt names its \`walk_request_id\`.
177
+
178
+ ## Tagging charges by client: \`x-client-tag\`
179
+
180
+ Send an optional \`x-client-tag\` header on any request (one of your own customers, a project, a job name) and it is stored on that request's charge and echoed back. Read spend per tag with \`GET /v1/credits/usage?group_by=tag\` (\`socialcrawl_account\` \`view: "usage"\`, \`group_by: "tag"\`) and one tag's receipts with \`GET /v1/credits/transactions?tag=<tag>\` (\`view: "transactions"\`, \`tag\`); each receipt carries its \`tag\`. A malformed tag is ignored, never refused, and the response says so with \`X-Client-Tag-Ignored\`. This MCP server sends the tag set in \`SOCIALCRAWL_CLIENT_TAG\` on every call, if you set one.
181
+
182
+ A usage read that would take longer than 20 s answers a free 503 that says to try a shorter range, one key (\`api_key_id\`) or fewer groups.
183
+
184
+ ## Advisory warnings (ENV-03)
185
+
186
+ Successful responses may include an optional \`data._warnings\` string array — non-fatal notices from the transform pipeline (e.g. an engagement-rate clamp, or \`walk_deadline_reached\` on a server-side page walk). Treat as observability hints, not as failures.
187
+
188
+ **Dropped params are named.** A param the endpoint does not declare is dropped — never forwarded, never billed — and gets one \`data._warnings\` line: the closest declared name, the \`label=\` / \`relevance=\` form you probably meant, or "no such parameter". A rejected value's 400 carries \`details.allowed_values\`, \`details.example\` and, for a one-edit typo, \`details.did_you_mean\`.
189
+
190
+ **\`meta.hint\`.** When a run of calls matches a cheaper pattern (the same handle on three platforms' profile lanes → \`prism/creator-card\`; 50 handles on one lane → \`POST /v1/prism/profiles\`; page 1 of the same list again → \`stop_at_id\`; comments on 5+ posts without \`label=\`), one response carries \`meta.hint\` with the suggestion and its price. Send the header \`X-SocialCrawl-Hints: off\` to suppress hints.
191
+
192
+ ## Insufficient credits
193
+
181
194
  Out of credits returns \`INSUFFICIENT_CREDITS\` (402) with \`credits_remaining: 0\`. A per-key spending cap returns \`KEY_BUDGET_EXCEEDED\` (402) instead — a different fix (raise the key's cap, don't top up). Neither is retryable; waiting does not clear them.`,
182
- errors: `# SocialCrawl API — Errors
183
-
184
- All errors follow the same envelope — every \`/v1\` exit is JSON, never a bare gateway page:
185
-
186
- \`\`\`json
187
- {
188
- "success": false,
189
- "error": {
190
- "type": "INVALID_REQUEST",
191
- "message": "Missing required parameter: handle",
192
- "status": 400,
193
- "doc_url": "https://www.socialcrawl.dev/docs/errors/invalid-request"
194
- },
195
- "credits_used": 0,
196
- "credits_remaining": 99,
197
- "request_id": "req-XXXXX"
198
- }
199
- \`\`\`
200
-
201
- ## Error types
202
-
203
- | Type | Status | Retryable | Meaning |
204
- |------|--------|-----------|---------|
205
- | \`MISSING_API_KEY\` | 401 | no | No \`x-api-key\` header supplied |
206
- | \`INVALID_API_KEY\` | 401 | no | Key does not exist or has been revoked |
207
- | \`INSUFFICIENT_CREDITS\` | 402 | no | Account balance too low for this endpoint |
208
- | \`KEY_BUDGET_EXCEEDED\` | 402 | no | This key's own \`credit_limit\` is spent while the account still has credits — raise the key's cap, don't top up |
209
- | \`INVALID_REQUEST\` | 400 | no | Missing/invalid parameter, bad enum value, broken param coupling, over-long CSV, bad handle/URL format, or a mangled text encoding (ERR-01) |
210
- | \`METHOD_NOT_ALLOWED\` | 405 | no | Wrong HTTP method for this route (ERR-02). Response includes \`Allow\` |
211
- | \`ENDPOINT_NOT_FOUND\` | 404 | no | Unknown platform+resource combination |
212
- | \`RESOURCE_NOT_FOUND\` | 404 | no | Upstream resource does not exist or returned an empty body (BIL-01) — credits auto-refunded |
213
- | \`IDEMPOTENCY_KEY_CONFLICT\` | 409 | no | \`Idempotency-Key\` already used by another account (BIL-02) |
214
- | \`IDEMPOTENCY_KEY_PAYLOAD_MISMATCH\` | 422 | no | Same \`Idempotency-Key\` reused with different parameters (BIL-02) |
215
- | \`PAYLOAD_TOO_LARGE\` | 413 | no | Request body over the JSON size cap (rejected before parse) |
216
- | \`RATE_LIMITED\` | 429 | **yes** | Over the 600 requests/minute per-key window (AIP-09). Unbilled |
217
- | \`CONCURRENCY_LIMIT\` | 429 | **yes** | More than 50 simultaneous requests on the same key |
218
- | \`UPSTREAM_ERROR\` | 502 | **yes** | Upstream source failed — credits refunded automatically |
219
- | \`SERVICE_UNAVAILABLE\` | 503 | **yes** | Circuit breaker open — credits refunded, response includes \`Retry-After: 30\` |
220
- | \`INTERNAL_ERROR\` | 500 | **yes** | Bug on our side — credits refunded; the request ID is the fastest way to report it |
221
-
222
- A request that hits the request-scoped deadline returns a JSON 504 with the credit refunded before the serverless kill.
223
-
224
- **Bad input on a single-source lane is a free 400.** On lanes served by one source (\`weibo/profile\`, \`goodreads/quotes\`, \`airbnb/search\`, \`airbnb/listing/availability\` and the like), input the source cannot use is \`INVALID_REQUEST\` naming the param, at 0 credits — no longer a refunded, retryable 502. Fix the param; do not retry.
225
-
226
- ## Names the API accepts for you
227
-
228
- - **Common param names are renamed, not dropped.** \`sort\` (or \`sort_by\`, \`order_by\`, …), \`country\` (\`region\`, \`country_code\`, \`gl\`, \`geo\`, \`market\`, …), \`limit\` (\`page_size\`, \`per_page\`, \`count\`, \`num\`, …), and a dated \`since\` / \`until\` (or \`start_date\`, \`from\`, \`date_from\`, …) move onto the endpoint's own name for the same thing; a sort word lands on its synonym (\`newest\` → \`latest\`), and an over-large limit is clamped. Each rename is a line in \`data._warnings\`. A name with no counterpart on the endpoint is still dropped (and named in \`_warnings\` with the closest declared name).
229
- - **Feed paths.** \`{platform}/profile/posts\` is that platform's posts feed on Bluesky, Gab, Kwai, Rumble, Threads, TikTok, Truth Social, Twitch and X (plus \`tiktok/user/posts\`, \`instagram/user/posts\`, \`facebook/page/posts\`, \`facebook/user/posts\`, \`twitter/users/tweets\`), and \`x/…\` is \`twitter/…\` — one call, one cache slot. \`socialcrawl_request\` calls the real path and tells you which.
230
-
231
- ## Auto-refund matrix
232
-
233
- Credits are refunded automatically on: 404 \`RESOURCE_NOT_FOUND\` (empty upstream — BIL-01), an empty list result (200 \`{items: []}\`), 502, 503, 500, and 504. Cache hits, 400, 401, 402, 405, 409, 413, 422, and 429 never deduct credits in the first place.
234
-
235
- ## Retry guidance
236
-
237
- Retry only the four transient classes (429/500/502/503). Honour \`Retry-After\` when present, then back off with jitter. Every other code is a client-side fix — retrying it loops forever. To make a retry billing-safe, pass an \`Idempotency-Key\` (see the \`idempotency\` topic).
238
-
239
- ## Client-side validation
240
-
195
+ errors: `# SocialCrawl API — Errors
196
+
197
+ All errors follow the same envelope — every \`/v1\` exit is JSON, never a bare gateway page:
198
+
199
+ \`\`\`json
200
+ {
201
+ "success": false,
202
+ "error": {
203
+ "type": "INVALID_REQUEST",
204
+ "message": "Missing required parameter: handle",
205
+ "status": 400,
206
+ "doc_url": "https://www.socialcrawl.dev/docs/errors/invalid-request"
207
+ },
208
+ "credits_used": 0,
209
+ "credits_remaining": 99,
210
+ "request_id": "req-XXXXX"
211
+ }
212
+ \`\`\`
213
+
214
+ ## Error types
215
+
216
+ | Type | Status | Retryable | Meaning |
217
+ |------|--------|-----------|---------|
218
+ | \`MISSING_API_KEY\` | 401 | no | No \`x-api-key\` header supplied |
219
+ | \`INVALID_API_KEY\` | 401 | no | Key does not exist or has been revoked |
220
+ | \`INSUFFICIENT_CREDITS\` | 402 | no | Account balance too low for this endpoint |
221
+ | \`KEY_BUDGET_EXCEEDED\` | 402 | no | This key's own \`credit_limit\` is spent while the account still has credits — raise the key's cap, don't top up |
222
+ | \`INVALID_REQUEST\` | 400 | no | Missing/invalid parameter, bad enum value, broken param coupling, over-long CSV, bad handle/URL format, or a mangled text encoding (ERR-01) |
223
+ | \`METHOD_NOT_ALLOWED\` | 405 | no | Wrong HTTP method for this route (ERR-02). Response includes \`Allow\` |
224
+ | \`ENDPOINT_NOT_FOUND\` | 404 | no | Unknown platform+resource combination |
225
+ | \`RESOURCE_NOT_FOUND\` | 404 | no | Upstream resource does not exist or returned an empty body (BIL-01) — credits auto-refunded |
226
+ | \`IDEMPOTENCY_KEY_CONFLICT\` | 409 | no | \`Idempotency-Key\` already used by another account (BIL-02) |
227
+ | \`IDEMPOTENCY_KEY_PAYLOAD_MISMATCH\` | 422 | no | Same \`Idempotency-Key\` reused with different parameters (BIL-02) |
228
+ | \`PAYLOAD_TOO_LARGE\` | 413 | no | Request body over the JSON size cap (rejected before parse) |
229
+ | \`RATE_LIMITED\` | 429 | **yes** | Over the 600 requests/minute per-key window (AIP-09). Unbilled |
230
+ | \`CONCURRENCY_LIMIT\` | 429 | **yes** | More than 50 simultaneous requests on the same key |
231
+ | \`UPSTREAM_ERROR\` | 502 | **yes** | Upstream source failed — credits refunded automatically |
232
+ | \`SERVICE_UNAVAILABLE\` | 503 | **yes** | Circuit breaker open (\`Retry-After: 30\`), or the service is briefly saturated (\`Retry-After: 5\`) — credits refunded |
233
+ | \`INTERNAL_ERROR\` | 500 | **yes** | Bug on our side — credits refunded; the request ID is the fastest way to report it |
234
+
235
+ A request that hits the request-scoped deadline returns a JSON 504 with the credit refunded before the serverless kill. A \`GET\` has 48 s for its upstream work (transcripts, Discover and a few other long routes have their own, longer limits); a call still running at 54 s gets the error envelope with a request id and \`Retry-After\`, its credits refunded and the work left to finish, so a retry after the wait can come from the cache at no charge.
236
+
237
+ **Brief saturation is a fast, free 503.** When the database is queued up or the account's balance row is locked by another call, the request answers 503 \`SERVICE_UNAVAILABLE\` with \`Retry-After: 5\` within about 3 to 11 s, instead of hanging to 60 s. A request with under half a second of its time left answers the same refunded 503 with \`Retry-After: 5\` rather than starting a source call it cannot finish. Wait 5 s and retry with the same \`Idempotency-Key\`.
238
+
239
+ **Nothing matching is not an error.** A search or list that ran and found nothing answers 200 with an empty list, \`data.empty_reason\` (for example \`no_matches\`, \`row_filtered\`, \`already_seen\`) and 0 credits, where several lanes used to answer a 404: the tag and mention searches with \`since\` or \`query\`, \`google/business/reviews\` with \`since\` or \`query\`, app-store reviews of a real app with none, \`twitter/tweet/retweeters\` of a post nobody retweeted, \`prism/launch-echo\` with no echo (\`computed.echo: "none"\`) and a GitHub repository with no open issues on \`github/repo/top-issues\`. A wrong id (an app, place or repository that does not exist) is still a refunded 404.
240
+
241
+ **Transcripts: \`no_captions\` vs \`video_gone\`.** A 404 \`no_captions\` means the video exists but has no caption track and no speech was heard (free). \`video_gone\` means a source stated the video is deleted or private (refunded after one attempt, not three). \`video_too_long\` is a free 400 for a spoken-language transcription past 600 s or 20 MB. A transcript too short for its video gets a second listen before it is billed, and comes back free with \`transcript_unconfirmed\` in \`_warnings\` when the check disagrees or cannot run.
242
+
243
+ **Bad input on a single-source lane is a free 400.** On lanes served by one source (\`weibo/profile\`, \`goodreads/quotes\`, \`airbnb/search\`, \`airbnb/listing/availability\` and the like), input the source cannot use is \`INVALID_REQUEST\` naming the param, at 0 credits — no longer a refunded, retryable 502. Fix the param; do not retry.
244
+
245
+ **Answers about the request are not outages.** Since mid-November 2026 these come back after one attempt as a free, non-retryable answer, where each was a refunded 502 after four: an age-restricted Facebook group or Threads profile (404 \`RESOURCE_NOT_FOUND\` that says so); \`sort=popular\` on a YouTube channel whose popular order cannot be read (400 naming \`sort=latest\`); a TikTok account that does not exist on \`profile/videos\`, \`user/followers\` or \`user/following\` (404); a YouTube channel, \`/c/\`, \`/user/\` or \`/post/\` link sent to a video lane (400 naming the right endpoint), and a video id that is not 11 characters (400); \`twitter/ai-search\` with both \`from_handles\` and \`exclude_handles\` (400) or \`from_date\` after \`to_date\` (422). Change the request; do not retry it.
246
+
247
+ **Expired cursors.** A cursor the source can no longer continue answers 400 \`INVALID_REQUEST\` saying the cursor expired — free on \`facebook/adlibrary/company/ads\`, refunded on \`twitter/tweet/replies\` (expired or foreign reply cursor). Start again from the first page.
248
+
249
+ **A paused source is not a timeout.** A 503 \`SERVICE_UNAVAILABLE\` with \`details.reason: "breaker_open"\` means one source is paused (spent quota or repeated failures): the call was refused without being sent and not billed. The message states until when; the same request without the named option (for example without \`sort=most_viewed\`) usually works now. With no time stated, wait for \`Retry-After\`. \`utility/explain-error\` explains a pasted one this way.
250
+
251
+ **Web pages that cannot be read.** \`web/scrape\` and \`web/extract\` answer a free 404 \`RESOURCE_NOT_FOUND\` with \`details.reason: "site_not_supported"\` for a site the scraper refuses by policy (a platform page also gets \`details.suggestion\`, the SocialCrawl endpoint to use instead), and \`details.reason: "url_unreachable"\` in about 1 s for a dead or unresolvable address. A Google redirect link (\`google.<tld>/url?q=…\`) is read as its target. \`page_state\` on \`web/scrape\` reports bot checks and blank pages, with a \`_warnings\` line.
252
+
253
+ **Retry-After.** A refunded 504 carries \`Retry-After: 30\`. A Reddit lane whose source stays rate-limited after its own retries answers a refunded 503 saying Reddit is momentarily rate-limited upstream, with Retry-After: 30. A 429 body carries \`error.details\` (the limit, the window and when it resets). A 504 whose every search timed out (\`*/search/mentions\`, \`*/search/hashtag\`) is the refunded 504 timeout, not a 502.
254
+
255
+ **Errors from monitors and background jobs** use the same envelope as every other route: \`success\`, \`status\`, \`doc_url\`, \`retryable\`, \`credits_used\` and \`request_id\` beside \`error.type\` and \`error.message\`. \`MONITOR_LIMIT_REACHED\` is a catalogued type.
256
+
257
+ ## Names the API accepts for you
258
+
259
+ - **Common param names are renamed, not dropped.** \`sort\` (or \`sort_by\`, \`order_by\`, …), \`country\` (\`region\`, \`country_code\`, \`gl\`, \`geo\`, \`market\`, …), \`limit\` (\`page_size\`, \`per_page\`, \`count\`, \`num\`, …), and a dated \`since\` / \`until\` (or \`start_date\`, \`from\`, \`date_from\`, …) move onto the endpoint's own name for the same thing; a sort word lands on its synonym (\`newest\` → \`latest\`), and an over-large limit is clamped. Each rename is a line in \`data._warnings\`. A name with no counterpart on the endpoint is still dropped (and named in \`_warnings\` with the closest declared name).
260
+ - **Feed paths.** \`{platform}/profile/posts\` is that platform's posts feed on Bluesky, Gab, Kwai, Rumble, Threads, TikTok, Truth Social, Twitch and X (plus \`tiktok/user/posts\`, \`instagram/user/posts\`, \`facebook/page/posts\`, \`facebook/user/posts\`, \`twitter/users/tweets\`), and \`x/…\` is \`twitter/…\` — one call, one cache slot. \`socialcrawl_request\` calls the real path and tells you which.
261
+
262
+ ## Auto-refund matrix
263
+
264
+ Credits are refunded automatically on: 404 \`RESOURCE_NOT_FOUND\` (empty upstream — BIL-01), an empty list result (200 \`{items: []}\`), 502, 503, 500, and 504. Cache hits, 400, 401, 402, 405, 409, 413, 422, and 429 never deduct credits in the first place.
265
+
266
+ ## Retry guidance
267
+
268
+ Retry only the four transient classes (429/500/502/503). Honour \`Retry-After\` when present, then back off with jitter. Every other code is a client-side fix — retrying it loops forever. To make a retry billing-safe, pass an \`Idempotency-Key\` (see the \`idempotency\` topic).
269
+
270
+ ## Client-side validation
271
+
241
272
  Before making any request, this MCP server validates locally that the platform exists, the resource exists, all required parameters and \`oneOf\` groups are satisfied, enum values are legal, integers are in range, parameter couplings hold, and CSV lists are within their limits. That turns a round-trip 400 into an instant free error.`,
242
- idempotency: `# SocialCrawl API — Idempotent Requests (BIL-02)
243
-
244
- Any \`/v1/*\` request can be made retry-safe by supplying an \`Idempotency-Key\` header. Network blips, agent retries, and redelivery from a queue stop being a billing risk.
245
-
246
- ## How to use it
247
-
248
- The \`socialcrawl_request\` tool (and \`socialcrawl_manage\` for the async job submitters) accepts an optional \`idempotencyKey\` parameter:
249
-
250
- - Use a UUIDv4 (or any opaque 16+ character string) the agent can regenerate on retry.
251
- - Reuse the same key across retries of the same logical operation.
252
- - Generate a fresh key for each new logical operation.
253
-
254
- ## What the server does
255
-
256
- \`lookupIdempotency(userId, key, requestHash)\` returns one of four verdicts:
257
-
258
- | Outcome | HTTP | Body | Credits |
259
- |---------|------|------|---------|
260
- | \`proceed\` | (continues normal flow) | — | normal cost |
261
- | \`replay\` | 200 (original status) | stored response verbatim, with \`X-Idempotent-Replay: true\` header | 0 deducted |
262
- | \`conflict\` | 409 | \`IDEMPOTENCY_KEY_CONFLICT\` | 0 |
263
- | \`payload_mismatch\` | 422 | \`IDEMPOTENCY_KEY_PAYLOAD_MISMATCH\` | 0 |
264
-
265
- The \`requestHash\` is a stable hash of \`(method, path, sorted query params)\`.
266
-
267
- ## TTL
268
-
269
- Idempotency rows live for **24h**. After that the key is reusable.
270
-
271
- ## Credits and cache
272
-
273
- Replays cost **0 credits** — same as cache hits. Idempotency lookup runs *before* the cache check, so a replay wins over a \`Cache-Control: no-cache\` force-refresh: exactly-once semantics beat freshness.
274
-
275
- ## Streaming caveat
276
-
277
- A streamed (SSE) response is not stored for replay — idempotency applies to the JSON envelope path.`,
278
- pagination: `# SocialCrawl API — Pagination
279
-
280
- Every list endpoint speaks one client contract, whatever its upstream calls its cursor.
281
-
282
- ## The universal \`cursor\` param
283
-
284
- The registry declares 11 different native cursor names (\`max_cursor\`, \`next_max_id\`, \`continuationToken\`, \`after\`, \`next_page_id\`, …) plus \`page\` and \`offset\` styles. **Every paginatable endpoint also accepts \`cursor\`**, rewritten to that endpoint's native param before validation, caching, and dispatch. The native names still work; \`cursor\` is the one you should write.
285
-
286
- \`socialcrawl_endpoint\` prints each endpoint's paging style and native param.
287
-
288
- ## The \`pagination\` envelope block
289
-
290
- Every list response carries a top-level:
291
-
292
- \`\`\`json
293
- "pagination": { "next_cursor": "sc.…", "has_more": true, "page_size": 20 }
294
- \`\`\`
295
-
296
- A list answer also carries **\`next_page_credits\`** — the next page priced by the same pricer that charges (your negotiated rate included; \`null\` with no cursor) — and **\`typical_page_size\`**, the verified page size (\`null\` when unverified). Budget a walk from these rather than the band's ceiling; \`socialcrawl_collect\` stops before a page whose \`next_page_credits\` would overrun \`max_credits\`.
297
-
298
- **Stop on \`has_more === false\`**, not on cursor absence. A zero-item page never advances (\`next_cursor\` is dropped), so an empty page is an honest end rather than an infinite loop. The legacy \`data.next_cursor\` is retained for one deprecation cycle.
299
-
300
- ## The \`sc.\` token
301
-
302
- \`next_cursor\` is an opaque \`sc.<base64url>\` token that packs the native param, the inner cursor, and any source pin. Treat it as opaque: pass it back verbatim. Page/offset styles encode the next number inside the token and advance server-side, so you never compute an offset yourself.
303
-
304
- ## Anti-burn 400 (free)
305
-
306
- Sending a *known* cursor name that is not this endpoint's native param (or \`cursor\`) is rejected with \`INVALID_REQUEST\` + \`error.details.did_you_mean: "cursor"\` at **0 credits**. This exists because the old failure mode was silent: the wrong name was ignored, page 1 came back again, \`next_cursor\` looked null, and you paid for it.
307
-
308
- ## \`limit\`: page size vs collect-until-N
309
-
310
- For most endpoints \`limit\` is a **page size** mapped to the upstream's native limit param (with an endpoint-specific max).
311
-
312
- For a handful it is **collect-until-N**: the endpoint walks upstream pages itself until it has N unique items, de-duplicating server-side, and bills per page actually consumed with the unused budget refunded. \`socialcrawl_endpoint\` flags these explicitly — the name of the native param cannot tell you which is which.
313
-
314
- ## Composites that walk for you
315
-
316
- Server-side composites marked *paginatable* (e.g. \`prism/comments\`) walk every page in one call and fold the results together. One call, one metered charge covering the whole walk — do not page these yourself.
317
-
318
- ## Walk several pages in one call: \`max_pages\`
319
-
320
- Where an endpoint declares \`max_pages\` (1-5), one call walks up to that many pages and returns the rows from all of them, after any row filter. Each page walked is billed exactly as one call (a cached page is free). \`data.walk.stopped\` says why the walk ended (\`end\`, \`max_pages\`, \`time_budget\`, \`page_error\`) and \`data.next_cursor\` continues from there. The row filters \`min_views\`, \`max_age_days\` and \`sort_rows=views\` run on our side across every page walked; \`data.walk.discarded\` counts what they removed.
321
-
322
- ## Incremental polling: \`since\` and \`stop_at_id\`
323
-
324
- On the profile feeds that declare them (Instagram posts/reels, TikTok videos, YouTube videos/shorts, Facebook posts, X tweets, Threads posts), \`since=<ISO date>\` drops rows older than the date and ends the walk at the first older dated row; \`stop_at_id=<post.id or post.url>\` drops that post and everything after it. Pinned rows never count as the boundary. When either is sent, \`pagination.stopped_at\` reports \`since\`, \`known_id\`, \`end\` or null. Billing is unchanged — the page you fetched costs a page — but you stop walking sooner.
325
-
326
- ## Dedupe across calls: \`seen\`
327
-
328
- \`seen=<your id>\` (1-64 letters, digits, \`.\`, \`_\`, \`-\`) drops rows this account already received under the same id in the last 24 hours, and the page price falls with the share of repeats — a page of nothing but repeats is free. Use one id across a set of related searches; \`data.walk.repeats\` counts what was removed.
329
-
330
- ## Billing while paging
331
-
273
+ idempotency: `# SocialCrawl API — Idempotent Requests (BIL-02)
274
+
275
+ Any \`/v1/*\` request can be made retry-safe by supplying an \`Idempotency-Key\` header. Network blips, agent retries, and redelivery from a queue stop being a billing risk.
276
+
277
+ ## How to use it
278
+
279
+ The \`socialcrawl_request\` tool (and \`socialcrawl_manage\` for the async job submitters) accepts an optional \`idempotencyKey\` parameter:
280
+
281
+ - Use a UUIDv4 (or any opaque 16+ character string) the agent can regenerate on retry.
282
+ - Reuse the same key across retries of the same logical operation.
283
+ - Generate a fresh key for each new logical operation.
284
+
285
+ ## What the server does
286
+
287
+ \`lookupIdempotency(userId, key, requestHash)\` returns one of four verdicts:
288
+
289
+ | Outcome | HTTP | Body | Credits |
290
+ |---------|------|------|---------|
291
+ | \`proceed\` | (continues normal flow) | — | normal cost |
292
+ | \`replay\` | 200 (original status) | stored response verbatim, with \`X-Idempotent-Replay: true\` header | 0 deducted |
293
+ | \`conflict\` | 409 | \`IDEMPOTENCY_KEY_CONFLICT\` | 0 |
294
+ | \`payload_mismatch\` | 422 | \`IDEMPOTENCY_KEY_PAYLOAD_MISMATCH\` | 0 |
295
+
296
+ The \`requestHash\` is a stable hash of \`(method, path, sorted query params)\`.
297
+
298
+ ## TTL
299
+
300
+ Idempotency rows live for **24h**. After that the key is reusable.
301
+
302
+ ## Credits and cache
303
+
304
+ Replays cost **0 credits** — same as cache hits. Idempotency lookup runs *before* the cache check, so a replay wins over a \`Cache-Control: no-cache\` force-refresh: exactly-once semantics beat freshness.
305
+
306
+ ## Streaming caveat
307
+
308
+ A streamed (SSE) response is not stored for replay — idempotency applies to the JSON envelope path. This server calls the streaming endpoints for their JSON envelope (\`search/everywhere\` and the other \`accept-header\` routes, and \`prism/answers\`, which streams by default unless asked for JSON), so a key replays there too. Send \`stream=true\` on \`prism/answers\` only if you want the stream and accept that it cannot be replayed.`,
309
+ pagination: `# SocialCrawl API — Pagination
310
+
311
+ Every list endpoint speaks one client contract, whatever its upstream calls its cursor.
312
+
313
+ ## The universal \`cursor\` param
314
+
315
+ The registry declares 11 different native cursor names (\`max_cursor\`, \`next_max_id\`, \`continuationToken\`, \`after\`, \`next_page_id\`, …) plus \`page\` and \`offset\` styles. **Every paginatable endpoint also accepts \`cursor\`**, rewritten to that endpoint's native param before validation, caching, and dispatch. The native names still work; \`cursor\` is the one you should write.
316
+
317
+ \`socialcrawl_endpoint\` prints each endpoint's paging style and native param.
318
+
319
+ ## The \`pagination\` envelope block
320
+
321
+ Every list response carries a top-level:
322
+
323
+ \`\`\`json
324
+ "pagination": { "next_cursor": "sc.…", "has_more": true, "page_size": 20 }
325
+ \`\`\`
326
+
327
+ A list answer also carries **\`next_page_credits\`** — the next page priced by the same pricer that charges (your negotiated rate included; \`null\` with no cursor) — and **\`typical_page_size\`**, the verified page size (\`null\` when unverified). Budget a walk from these rather than the band's ceiling; \`socialcrawl_collect\` stops before a page whose \`next_page_credits\` would overrun \`max_credits\`.
328
+
329
+ **Stop on \`has_more === false\`**, not on cursor absence. A zero-item page never advances (\`next_cursor\` is dropped), so an empty page is an honest end rather than an infinite loop. The legacy \`data.next_cursor\` is retained for one deprecation cycle.
330
+
331
+ ## The \`sc.\` token
332
+
333
+ \`next_cursor\` is an opaque \`sc.<base64url>\` token that packs the native param, the inner cursor, and any source pin. Treat it as opaque: pass it back verbatim. Page/offset styles encode the next number inside the token and advance server-side, so you never compute an offset yourself.
334
+
335
+ ## Anti-burn 400 (free)
336
+
337
+ Sending a *known* cursor name that is not this endpoint's native param (or \`cursor\`) is rejected with \`INVALID_REQUEST\` + \`error.details.did_you_mean: "cursor"\` at **0 credits**. This exists because the old failure mode was silent: the wrong name was ignored, page 1 came back again, \`next_cursor\` looked null, and you paid for it.
338
+
339
+ ## \`limit\`: page size vs collect-until-N
340
+
341
+ For most endpoints \`limit\` is a **page size** mapped to the upstream's native limit param (with an endpoint-specific max).
342
+
343
+ For a handful it is **collect-until-N**: the endpoint walks upstream pages itself until it has N unique items, de-duplicating server-side, and bills per page actually consumed with the unused budget refunded. \`socialcrawl_endpoint\` flags these explicitly — the name of the native param cannot tell you which is which.
344
+
345
+ ## Composites that walk for you
346
+
347
+ Server-side composites marked *paginatable* (e.g. \`prism/comments\`) walk every page in one call and fold the results together. One call, one metered charge covering the whole walk — do not page these yourself.
348
+
349
+ ## Walk several pages in one call: \`max_pages\`, \`max_items\`, \`max_credits\`
350
+
351
+ Where an endpoint declares them (about 200 lists do), one call walks pages and returns the rows from all of them, after any row filter: \`max_pages\` (1-50) walks up to that many pages, \`max_items\` (1-5000) walks until the response holds at least that many rows, and \`max_credits\` (1-100000) caps what the call may spend across every page (sent alone it walks as far as the budget goes, up to 50 pages). Each page walked is billed exactly as one call (a cached page is free). \`data.walk.stopped\` says why the walk ended (\`end\`, \`max_pages\`, \`max_items\`, \`max_credits\`, \`time_budget\`, \`page_error\`) and \`pagination.next_cursor\` continues from there — send it with the same params to resume a walk that stopped on \`time_budget\`. The row filters \`min_views\`, \`max_age_days\` and \`sort_rows=views\` run on our side across every page walked; \`data.walk.discarded\` counts what they removed.
352
+
353
+ **What the walk report tells you.** \`data.walk.oldest_published_at\` and \`newest_published_at\` say which dates the rows read span, so a \`time_budget\` stop tells you how far back it got (its \`_warnings\` line names the date reached). \`data.walk.end_reason: "source_depth"\` marks an \`end\` that came before your \`since\`: the source served nothing older, and a line names the oldest date served. \`data.walk.gaps\` lists any jump of more than 7 days between consecutive pages of a newest-first list. \`data.walk.rows_dropped_by_relevance\` counts rows a \`relevance=filter\` removed (the default relevance score never drops a row).
354
+
355
+ **\`page_error\` is not the end.** A later page that comes back empty with no proof the list is over stops the walk with \`stopped: "page_error"\` and the cursor to resume, never \`end\`; an empty page right after one that said there was more is read once more, uncached, before the walk gives up. \`total\` is \`null\`, not 0, when the source does not say.
356
+
357
+ **\`max_credits\` or \`max_items\` without \`max_pages\`** walks up to the default of 50 pages, and a walk that read more than 2 pages that way says so in \`data._warnings\`. Send \`max_pages\` to bound it.
358
+
359
+ **On a lane that does not walk** (for example \`twitter/search/mentions\` or \`reddit/profile/comments\`), \`max_pages\`, \`max_items\` and \`max_credits\` are ignored, and the \`_warnings\` line says the lane does not walk pages in one call and names \`cursor\` with \`pagination.next_cursor\` (or the lane's own \`limit\` and \`before\`). \`socialcrawl_collect\` walks those lanes page by page for you.
360
+
361
+ ## Incremental polling: \`since\` and \`stop_at_id\`
362
+
363
+ On the profile feeds that declare them (Instagram posts/reels, TikTok videos, YouTube videos/shorts, Facebook posts, X tweets, Threads posts), \`since=<ISO date>\` drops rows older than the date and ends the walk at the first older dated row; \`stop_at_id=<post.id or post.url>\` drops that post and everything after it. Pinned rows never count as the boundary. When either is sent, \`pagination.stopped_at\` reports \`since\`, \`known_id\`, \`end\` or null. Billing is unchanged — the page you fetched costs a page — but you stop walking sooner.
364
+
365
+ ## Dedupe across calls: \`seen\`
366
+
367
+ \`seen=<your id>\` (1-64 letters, digits, \`.\`, \`_\`, \`-\`) drops rows this account already received under the same id in the last 24 hours, and the page price falls with the share of repeats — a page of nothing but repeats is free. Use one id across a set of related searches; \`data.walk.repeats\` counts what was removed.
368
+
369
+ ## When a search runs out
370
+
371
+ A narrow or date-bounded search can reach a later page the source answers empty. The first time, that page is a refunded, retryable 503 — "retry the same cursor". Retry the same cursor later: on \`tiktok/search\` the same cursor answering empty again ends the walk; on \`facebook/search/posts\` it ends only when the cursor answers empty again at least 10 minutes after its first empty answer (a stalled page often recovers within a minute). The end is served as 200, \`items: []\`, \`has_more: false\`, 0 credits. Do not loop on the same cursor more often than that.
372
+
373
+ ## Cursors that expire or belong to one sort
374
+
375
+ An expired or foreign cursor is a 400 \`INVALID_REQUEST\` that says to start again from the first page (\`twitter/tweet/replies\`: refunded; \`facebook/adlibrary/company/ads\`: free). A cursor minted under one sort keeps that sort: \`yelp/business/reviews\` carries its \`sort\` inside \`next_cursor\`, and \`instagram/profile/reels\` with \`sort=most_viewed\` continues only on the source that minted it — any other combination is a free 400. Cursors on \`g2/reviews\` and \`twitter/tweet/replies\` are portable across sources.
376
+
377
+ ## Billing while paging
378
+
332
379
  Each page of an ordinary list endpoint is a separate billed request. A repeat of the same page inside the cache TTL is free. An empty page is refunded.`,
333
- caching: `# SocialCrawl API — Caching
334
-
335
- **A cache hit costs 0 credits.** We already paid the upstream for the call that produced the cached body; billing you a second time for the same bytes would be double-charging. The envelope reports \`"cached": true\` and the response carries \`X-Cache: HIT\`.
336
-
337
- ## TTL by category
338
-
339
- | Category | TTL | Typical endpoints |
340
- |----------|-----|-------------------|
341
- | profile | ${CACHE_TTLS.profile}s (15 min) | Profile / author lookups |
342
- | post | ${CACHE_TTLS.post}s (10 min) | Post and video detail |
343
- | comments | ${CACHE_TTLS.comments}s (5 min) | Comment and reply lists |
344
- | search | ${CACHE_TTLS.search}s (2 min) | Search and feed endpoints |
345
- | analytics | ${CACHE_TTLS.analytics}s (30 min) | Analytics, aggregates, reference data |
346
- | immutable | ${CACHE_TTLS.immutable}s (30 days) | Single-video transcripts — a published transcript never changes |
347
-
348
- Each endpoint's exact category and TTL is shown by \`socialcrawl_endpoint\` and \`socialcrawl_estimate\`. An endpoint may declare its own TTL override; \`0\` means it is never cached and every call is live and billed.
349
-
350
- ## The cache key
351
-
352
- Deterministic from \`platform + resource + sorted query params\`, plus a version segment. Two consequences worth knowing:
353
-
354
- - **Adding junk query params does NOT bypass the cache** — unknown params are stripped from the key (BIL-06). They also never reach upstream.
355
- - Parameter order does not matter.
356
-
357
- ## Forcing a fresh fetch
358
-
359
- Send \`Cache-Control: no-cache\`. The lookup is skipped (guaranteed-live fetch, billed at the normal rate) but the fresh result is still written back, so the next plain caller gets a free hit. \`X-Cache\` reports \`MISS\`.
360
-
361
- An \`Idempotency-Key\` replay runs *before* the cache check, so a replay beats a force-refresh.
362
-
363
- ## Streaming
364
-
380
+ caching: `# SocialCrawl API — Caching
381
+
382
+ **A cache hit costs 0 credits.** We already paid the upstream for the call that produced the cached body; billing you a second time for the same bytes would be double-charging. The envelope reports \`"cached": true\` and the response carries \`X-Cache: HIT\`.
383
+
384
+ ## TTL by category
385
+
386
+ | Category | TTL | Typical endpoints |
387
+ |----------|-----|-------------------|
388
+ | profile | ${CACHE_TTLS.profile}s (15 min) | Profile / author lookups |
389
+ | post | ${CACHE_TTLS.post}s (10 min) | Post and video detail |
390
+ | comments | ${CACHE_TTLS.comments}s (5 min) | Comment and reply lists |
391
+ | search | ${CACHE_TTLS.search}s (2 min) | Search and feed endpoints |
392
+ | analytics | ${CACHE_TTLS.analytics}s (30 min) | Analytics, aggregates, reference data |
393
+ | immutable | ${CACHE_TTLS.immutable}s (30 days) | Single-video transcripts — a published transcript never changes |
394
+
395
+ Each endpoint's exact category and TTL is shown by \`socialcrawl_endpoint\` and \`socialcrawl_estimate\`. An endpoint may declare its own TTL override; \`0\` means it is never cached and every call is live and billed.
396
+
397
+ ## The cache key
398
+
399
+ Deterministic from \`platform + resource + sorted query params\`, plus a version segment. Two consequences worth knowing:
400
+
401
+ - **Adding junk query params does NOT bypass the cache** — unknown params are stripped from the key (BIL-06). They also never reach upstream.
402
+ - Parameter order does not matter.
403
+
404
+ ## Forcing a fresh fetch
405
+
406
+ Send \`Cache-Control: no-cache\`. The lookup is skipped (guaranteed-live fetch, billed at the normal rate) but the fresh result is still written back, so the next plain caller gets a free hit. \`X-Cache\` reports \`MISS\`.
407
+
408
+ An \`Idempotency-Key\` replay runs *before* the cache check, so a replay beats a force-refresh.
409
+
410
+ ## Streaming
411
+
365
412
  A streamed (SSE) response never shares a cache slot with the sync JSON variant: both the lookup and the write are skipped for a streaming request. A prior sync result can never be replayed as a stream, and a stream never seeds a sync envelope.`,
366
- "response-schema": `# SocialCrawl API — Response Schema
367
-
368
- ## The envelope
369
-
370
- Every successful \`/v1\` response:
371
-
372
- \`\`\`json
373
- {
374
- "success": true,
375
- "platform": "tiktok",
376
- "endpoint": "/v1/tiktok/profile",
377
- "data": { "...": "..." },
378
- "credits_used": 1,
379
- "credits_remaining": 4999,
380
- "request_id": "req-XXXXX",
381
- "cached": false
382
- }
383
- \`\`\`
384
-
385
- \`credits_used\` is the **settled** charge — for a metered endpoint that is the post-refund number, not the upfront hold. Errors use the same envelope with \`success: false\` and an \`error\` object (see the \`errors\` topic).
386
-
387
- ## List responses
388
-
389
- A list archetype's \`data\` is normalised to \`{ items, total?, next_cursor?, dropped }\` plus the top-level \`pagination\` block. An empty list is \`200 { items: [], total: 0 }\` with the credit refunded — a valid "zero matches", not an error. A single-object lookup that finds nothing is a refunded \`404 RESOURCE_NOT_FOUND\` instead.
390
-
391
- ## \`data.dropped\` — the integrity counter
392
-
393
- Every list response carries \`data.dropped\`: the count of upstream items discarded because they could not be repaired to the endpoint schema. \`0\` is a positive assertion that the page is complete, not a default — check it on every page of a drain, because \`items.length\` cannot distinguish a lossy page from a genuinely small one.
394
-
395
- \`\`\`json
396
- "data": { "items": ["..."], "total": 42, "dropped": 0 }
397
- \`\`\`
398
-
399
- **It lives inside \`data\`, not at the envelope root** — unlike \`pagination\`, which is a root sibling of \`data\`. Reading \`response.dropped\` yields \`undefined\`, which a lenient client misreads as zero and a strict one misreads as an outage. Read \`response.data.dropped\`. Singular (non-list) responses omit it entirely; there is no list to lose rows from.
400
-
401
- The published OpenAPI declared this field at the envelope root between 2026-07-09 and 2026-08-10. That was a spec error, not a wire change: no response has ever carried a root-level \`dropped\`. See GitHub socialcrawl/mcp#2.
402
-
403
- ## \`data._warnings\` — non-fatal notices
404
-
405
- An optional \`string[]\` appended to \`data\` when the transform pipeline reports drift (unresolved field-map paths, clamped computed values). Advisory only: never flip success, gate a retry, or treat it as an error on its presence. Omitted entirely when empty, so absent means "no warnings".
406
-
407
- ## The canonical schema
408
-
409
- Every endpoint declaring an archetype is validated against one canonical Zod schema at the wire, so the same field means the same thing on every platform. Archetype families:
410
-
411
- - **Social** — \`Author\`/\`AuthorList\`, \`Post\`/\`PostList\`, \`Comment\`/\`CommentList\`, \`Audience\`, \`Transcript\`, \`SearchResult\`, \`Analytics\`, \`MediaList\`.
412
- - **Commerce** — \`Product\`/\`ProductList\`, \`Review\`/\`ReviewList\`, \`Seller\`/\`SellerList\`.
413
- - **Places, apps, news, finance, jobs** — \`Place\`/\`PlaceList\`, \`App\`/\`AppList\`, \`NewsArticleList\`, \`QuoteList\`, \`JobList\`.
414
- - **Web** — \`WebPage\`/\`WebPageList\`.
415
-
416
- \`socialcrawl_endpoint\` shows each endpoint's archetype, where its rows are and its response fields in its Response column.
417
-
418
- ## Platform-specific fields: \`ext\`
419
-
420
- Data that does not fit a canonical field lives in a typed, optional \`ext\` sub-object on the post/comment/author/product/review/app objects. Keys are declared per platform — anything undeclared is stripped by the schema gate, so \`ext\` is a contract, not a free-form bag.
421
-
422
- One join key worth memorising: the stable cross-endpoint YouTube creator key is \`post.ext.channel_id\` (the bare \`UC…\` id), never \`post.author.username\`, which is the \`@handle\` or \`null\`.
423
-
424
- ## \`format=raw\`
425
-
426
- \`format=raw\` returns the source's own body instead of the canonical schema. The source's billing fields (\`credits_remaining\`, \`credits_charged\`, \`credits_used\`, and a supplier \`cost\`) are removed from it, on a live call and a cache hit alike — read your charge from the envelope's \`credits_used\`, never from inside \`data\`.
427
-
428
- ## Computed fields
429
-
430
- Where the inputs are present, responses add a \`computed\` block: \`engagement_rate\`, \`language\`, \`content_category\`, \`estimated_reach\`. Unknown values are \`null\`, never zero.
431
-
432
- ## Response headers
433
-
434
- | Header | Value |
435
- |--------|-------|
436
- | \`X-Request-Id\` | Unique request identifier (\`req-XXXXX\`) — quote it in any support report |
437
- | \`X-Credits-Used\` | Settled credits for this request (0 on a cache hit, refund, or replay) |
438
- | \`X-Credits-Remaining\` | Balance after deduction |
439
- | \`X-Cache\` | \`HIT\` or \`MISS\` |
440
- | \`X-RateLimit-Limit\` / \`-Remaining\` / \`-Reset\` | Per-key request-rate window |
441
- | \`X-Concurrency-Limit\` / \`-Remaining\` | Per-key concurrency headroom |
442
- | \`X-Idempotent-Replay\` | \`true\` when the body was replayed from an idempotency record |
443
-
444
- ## Advisory warnings
445
-
413
+ "response-schema": `# SocialCrawl API — Response Schema
414
+
415
+ ## The envelope
416
+
417
+ Every successful \`/v1\` response:
418
+
419
+ \`\`\`json
420
+ {
421
+ "success": true,
422
+ "platform": "tiktok",
423
+ "endpoint": "/v1/tiktok/profile",
424
+ "data": { "...": "..." },
425
+ "credits_used": 1,
426
+ "credits_remaining": 4999,
427
+ "request_id": "req-XXXXX",
428
+ "cached": false
429
+ }
430
+ \`\`\`
431
+
432
+ \`credits_used\` is the **settled** charge — for a metered endpoint that is the post-refund number, not the upfront hold. Errors use the same envelope with \`success: false\` and an \`error\` object (see the \`errors\` topic).
433
+
434
+ ## List responses
435
+
436
+ A list archetype's \`data\` is normalised to \`{ items, total?, next_cursor?, dropped }\` plus the top-level \`pagination\` block. An empty list is \`200 { items: [], total: 0 }\` with the credit refunded — a valid "zero matches", not an error. A single-object lookup that finds nothing is a refunded \`404 RESOURCE_NOT_FOUND\` instead.
437
+
438
+ ## \`data.dropped\` — the integrity counter
439
+
440
+ Every list response carries \`data.dropped\`: the count of upstream items discarded because they could not be repaired to the endpoint schema. \`0\` is a positive assertion that the page is complete, not a default — check it on every page of a drain, because \`items.length\` cannot distinguish a lossy page from a genuinely small one.
441
+
442
+ \`\`\`json
443
+ "data": { "items": ["..."], "total": 42, "dropped": 0 }
444
+ \`\`\`
445
+
446
+ **It lives inside \`data\`, not at the envelope root** — unlike \`pagination\`, which is a root sibling of \`data\`. Reading \`response.dropped\` yields \`undefined\`, which a lenient client misreads as zero and a strict one misreads as an outage. Read \`response.data.dropped\`. Singular (non-list) responses omit it entirely; there is no list to lose rows from.
447
+
448
+ The published OpenAPI declared this field at the envelope root between 2026-07-09 and 2026-08-10. That was a spec error, not a wire change: no response has ever carried a root-level \`dropped\`. See GitHub socialcrawl/mcp#2.
449
+
450
+ ## \`data._warnings\` — non-fatal notices
451
+
452
+ An optional \`string[]\` appended to \`data\` when the transform pipeline reports drift (unresolved field-map paths, clamped computed values). Advisory only: never flip success, gate a retry, or treat it as an error on its presence. Omitted entirely when empty, so absent means "no warnings".
453
+
454
+ ## The canonical schema
455
+
456
+ Every endpoint declaring an archetype is validated against one canonical Zod schema at the wire, so the same field means the same thing on every platform. Archetype families:
457
+
458
+ - **Social** — \`Author\`/\`AuthorList\`, \`Post\`/\`PostList\`, \`Comment\`/\`CommentList\`, \`Audience\`, \`Transcript\`, \`SearchResult\`, \`Analytics\`, \`MediaList\`.
459
+ - **Commerce** — \`Product\`/\`ProductList\`, \`Review\`/\`ReviewList\`, \`Seller\`/\`SellerList\`.
460
+ - **Places, apps, news, finance, jobs** — \`Place\`/\`PlaceList\`, \`App\`/\`AppList\`, \`NewsArticleList\`, \`QuoteList\`, \`JobList\`.
461
+ - **Web** — \`WebPage\`/\`WebPageList\`.
462
+
463
+ \`socialcrawl_endpoint\` shows each endpoint's archetype, where its rows are and its response fields in its Response column.
464
+
465
+ ## Platform-specific fields: \`ext\`
466
+
467
+ Data that does not fit a canonical field lives in a typed, optional \`ext\` sub-object on the post/comment/author/product/review/app objects. Keys are declared per platform — anything undeclared is stripped by the schema gate, so \`ext\` is a contract, not a free-form bag.
468
+
469
+ One join key worth memorising: the stable cross-endpoint YouTube creator key is \`post.ext.channel_id\` (the bare \`UC…\` id), never \`post.author.username\`, which is the \`@handle\` or \`null\`.
470
+
471
+ ## \`format=raw\`
472
+
473
+ \`format=raw\` returns the source's own body instead of the canonical schema. The source's billing fields (\`credits_remaining\`, \`credits_charged\`, \`credits_used\`, and a supplier \`cost\`) are removed from it, on a live call and a cache hit alike — read your charge from the envelope's \`credits_used\`, never from inside \`data\`.
474
+
475
+ ## Computed fields
476
+
477
+ Where the inputs are present, responses add a \`computed\` block: \`engagement_rate\`, \`language\`, \`content_category\`, \`estimated_reach\`. Unknown values are \`null\`, never zero.
478
+
479
+ Every comment item (on \`reddit/post/comments\`, \`youtube/video/comments\`, \`facebook/post/comments\` and every other comment lane) also carries \`computed.country\` — \`{ value, source, confidence }\` or null — beside \`computed.language\`. \`computed.engagement_rate\` is null on a repost row (\`twitter/user/tweets\`, with one \`_warnings\` line) and on GitHub accounts and repositories.
480
+
481
+ ## Empty and closed lists
482
+
483
+ An empty list says why: \`empty_reason\` (for example \`no_matches\`) and \`empty_reason_note\`. On a search the note suggests changing the query or the filters; on a list read by link, handle or id it does not. A post whose comment section is closed answers a free 200 with no rows and \`comments_disabled: true\` (\`youtube/video/comments\`, \`telegram/post/comments\`; \`youtube/video\` carries \`post.ext.comments_disabled\`). An empty Google search and a text filter that matches nothing are a free 200 \`no_matches\`, not a 404.
484
+
485
+ ## Response headers
486
+
487
+ | Header | Value |
488
+ |--------|-------|
489
+ | \`X-Request-Id\` | Unique request identifier (\`req-XXXXX\`) — quote it in any support report |
490
+ | \`X-Credits-Used\` | Settled credits for this request (0 on a cache hit, refund, or replay) |
491
+ | \`X-Credits-Remaining\` | Balance after deduction |
492
+ | \`X-Cache\` | \`HIT\` or \`MISS\` |
493
+ | \`X-RateLimit-Limit\` / \`-Remaining\` / \`-Reset\` | Per-key request-rate window |
494
+ | \`X-Concurrency-Limit\` / \`-Remaining\` | Per-key concurrency headroom |
495
+ | \`X-Idempotent-Replay\` | \`true\` when the body was replayed from an idempotency record |
496
+
497
+ ## Advisory warnings
498
+
446
499
  \`data._warnings\` is an optional string array of non-fatal notices from the transform pipeline. Treat as observability hints, not failures.`,
447
- limits: `# SocialCrawl API — Rate Limits, Concurrency & Timeouts
448
-
449
- | Limit | Value | On breach |
450
- |-------|-------|-----------|
451
- | Request rate | 600 requests / minute / key (sliding window) | \`RATE_LIMITED\` 429, **unbilled**. Fail-open: a degraded limiter lets traffic through rather than blocking it |
452
- | Concurrency | 50 simultaneous requests / key | \`CONCURRENCY_LIMIT\` 429, unbilled |
453
- | Active API keys | 5 per account | Key creation refused |
454
- | Request body | JSON size cap | \`PAYLOAD_TOO_LARGE\` 413, rejected before parse |
455
- | Idempotency records | 24h TTL | Key becomes reusable |
456
-
457
- ## Headers to steer by
458
-
459
- Every \`/v1/*\` response carries \`X-RateLimit-Limit\`, \`X-RateLimit-Remaining\`, and \`X-RateLimit-Reset\` (unix epoch seconds; omitted when the limiter is degraded), plus \`X-Concurrency-Limit\` and \`X-Concurrency-Remaining\` — including on a 429. Read \`X-RateLimit-Remaining\` and pace yourself instead of discovering the wall.
460
-
461
- The two are deliberately separate and never aliased: 600/min is a *rate*, 50-at-once is a *depth*. A batch job can breach the second without approaching the first.
462
-
463
- ## Timeouts and deadlines
464
-
465
- - Each request runs under a **request-scoped deadline**. If it is about to expire, the API returns a JSON 504 with the credit refunded rather than being killed mid-flight by the platform.
466
- - Upstream calls have a per-attempt timeout with retries on transient 5xx and network failures, bounded by a per-endpoint total budget. Slow upstreams (retail providers in particular) carry tighter budgets so a hung call still leaves room to refund.
467
- - The API's own clocks are a 48s deadline, a 54s fallback that answers 504 (refunded) and a 60s hard kill; it recommends a 60s client timeout.
468
- - This MCP client waits for each endpoint's recommended timeout plus 5s of headroom, never less than 60s and never more than 120s. A client-side abort does not stop the server call: it can still complete and bill, so the timeout message says where to check what was charged before retrying.
469
-
470
- ## Circuit breaker
471
-
472
- A distributed breaker keyed by platform + upstream opens after repeated failures. While open, single-source endpoints return \`SERVICE_UNAVAILABLE\` (503) with \`Retry-After: 30\` and a full refund; multi-source endpoints route around the open source instead. One degraded platform never takes down its neighbours.
473
-
474
- ## Retrying well
475
-
500
+ limits: `# SocialCrawl API — Rate Limits, Concurrency & Timeouts
501
+
502
+ | Limit | Value | On breach |
503
+ |-------|-------|-----------|
504
+ | Request rate | 600 requests / minute / key (sliding window) | \`RATE_LIMITED\` 429, **unbilled**. Fail-open: a degraded limiter lets traffic through rather than blocking it |
505
+ | Concurrency | 50 simultaneous requests / key | \`CONCURRENCY_LIMIT\` 429, unbilled |
506
+ | Active API keys | 5 per account | Key creation refused |
507
+ | Request body | JSON size cap | \`PAYLOAD_TOO_LARGE\` 413, rejected before parse |
508
+ | Idempotency records | 24h TTL | Key becomes reusable |
509
+
510
+ ## Headers to steer by
511
+
512
+ Every \`/v1/*\` response carries \`X-RateLimit-Limit\`, \`X-RateLimit-Remaining\`, and \`X-RateLimit-Reset\` (unix epoch seconds; omitted when the limiter is degraded), plus \`X-Concurrency-Limit\` and \`X-Concurrency-Remaining\` — including on a 429. Read \`X-RateLimit-Remaining\` and pace yourself instead of discovering the wall.
513
+
514
+ The two are deliberately separate and never aliased: 600/min is a *rate*, 50-at-once is a *depth*. A batch job can breach the second without approaching the first.
515
+
516
+ ## Timeouts and deadlines
517
+
518
+ - Each request runs under a **request-scoped deadline**. If it is about to expire, the API returns a JSON 504 with the credit refunded rather than being killed mid-flight by the platform.
519
+ - Upstream calls have a per-attempt timeout with retries on transient 5xx and network failures, bounded by a per-endpoint total budget. Slow upstreams (retail providers in particular) carry tighter budgets so a hung call still leaves room to refund.
520
+ - The API's own clocks are a 48s deadline, a 54s fallback that answers 504 (refunded) and a 60s hard kill; it recommends a 60s client timeout.
521
+ - This MCP client waits for each endpoint's recommended timeout plus 5s of headroom, never less than 60s and never more than 120s. A client-side abort does not stop the server call: it can still complete and bill, so the timeout message says where to check what was charged before retrying.
522
+
523
+ ## Circuit breaker
524
+
525
+ A distributed breaker keyed by platform + upstream opens after repeated failures. While open, single-source endpoints return \`SERVICE_UNAVAILABLE\` (503) with \`Retry-After: 30\` and a full refund; multi-source endpoints route around the open source instead. One degraded platform never takes down its neighbours.
526
+
527
+ ## Retrying well
528
+
476
529
  Retry only 429/500/502/503 (and 504). Honour \`Retry-After\`, back off with jitter, and attach an \`Idempotency-Key\` so a retry can never double-charge.`,
477
- setup: `# SocialCrawl — Setup & Correct Use
478
-
479
- How to configure SocialCrawl, and how to drive it well once it is configured. Everything on this page is free to verify: \`socialcrawl_endpoint\` and \`socialcrawl_account\` call the API's own free routes at 0 credits.
480
-
481
- ## 1. Get a key
482
-
483
- Sign up at https://www.socialcrawl.dev — 100 free credits, no credit card. Keys start with \`sc_\`. Up to 5 active keys per account, rotatable from the dashboard at any time.
484
-
485
- A key can carry its own \`credit_limit\`. That cap is separate from the account balance: when it is spent you get \`KEY_BUDGET_EXCEEDED\` (402) while the account still has credits. Give each integration its own capped key and a runaway agent can only spend its own budget.
486
-
487
- ## 2. Configure the key
488
-
489
- **Local (stdio) — \`npx socialcrawl-mcp\`.** The server reads \`SOCIALCRAWL_API_KEY\` from its own process environment, which your MCP client supplies:
490
-
491
- \`\`\`json
492
- {
493
- "mcpServers": {
494
- "socialcrawl": {
495
- "command": "npx",
496
- "args": ["-y", "socialcrawl-mcp"],
497
- "env": { "SOCIALCRAWL_API_KEY": "sc_your_key_here" }
498
- }
499
- }
500
- }
501
- \`\`\`
502
-
503
- - **Claude Code:** \`claude mcp add socialcrawl -e SOCIALCRAWL_API_KEY=sc_… -- npx -y socialcrawl-mcp\`
504
- - **Claude Desktop:** \`claude_desktop_config.json\` (macOS \`~/Library/Application Support/Claude/\`, Windows \`%APPDATA%\\Claude\\\`)
505
- - **Cursor / VS Code / Windsurf:** the same \`mcpServers\` block in that client's MCP config file.
506
-
507
- **Remote (Streamable HTTP) — no install.** Send the key as a header on every request; it is never accepted in a URL or query string:
508
-
509
- \`\`\`
510
- claude mcp add --transport http socialcrawl https://mcp.socialcrawl.dev/mcp \\
511
- --header "Authorization: Bearer sc_your_key_here"
512
- \`\`\`
513
-
514
- \`x-api-key: sc_…\` works too. The remote transport is stateless and builds its context per request — it never falls back to a server-side environment key, so an anonymous caller cannot inherit the operator's credits.
515
-
516
- **Direct HTTP, no MCP.** \`x-api-key: sc_…\` on every \`/v1/*\` request against \`https://www.socialcrawl.dev\`.
517
-
518
- ## 3. Verify the setup
519
-
520
- \`\`\`
521
- socialcrawl_account
522
- \`\`\`
523
-
524
- 0 credits, and it proves auth end to end. If it fails, the message names the cause: \`MISSING_API_KEY\` means the env var never reached the process; \`INVALID_API_KEY\` means it is malformed, revoked, or from another environment.
525
-
526
- Then confirm this server's catalogue is current:
527
-
528
- \`\`\`
529
- socialcrawl_account view: "freshness"
530
- \`\`\`
531
-
532
- This is the one check people skip. The MCP ships a catalogue generated when it was built; the API keeps moving. \`freshness\` compares the two and tells you whether to upgrade (\`npx -y socialcrawl-mcp@latest\`). Calls always hit the live API and keep working — but discovery, pricing, and local validation answer from the snapshot, so a newer endpoint looks unknown until you upgrade.
533
-
534
- ## 4. Pick the right tool
535
-
536
- | You want to… | Tool |
537
- |--------------|------|
538
- | See what platforms exist | \`socialcrawl_find\` with no task |
539
- | Find an endpoint for a task | \`socialcrawl_find\` with the task in plain words |
540
- | Know what a call costs | \`socialcrawl_estimate\` with the exact params |
541
- | Learn one endpoint completely | \`socialcrawl_endpoint\` with its id |
542
- | Fetch data | \`socialcrawl_request\` (one page) or \`socialcrawl_collect\` (N rows) |
543
- | Scrape / crawl / browse the open web | \`socialcrawl_manage\` \`area: "web"\` |
544
- | Schedule a recipe on a cadence | \`socialcrawl_manage\` \`area: "monitors"\` |
545
- | Check balance or explain a charge | \`socialcrawl_account\` |
546
- | Read a contract (paging, caching, errors…) | \`socialcrawl_endpoint\` with a topic id |
547
- | Get the live, authoritative answer | \`socialcrawl_endpoint\` with a key set |
548
-
549
- Two surfaces do **not** go through \`socialcrawl_request\`: the \`web\` platform (action-based, mixes GET/POST/PATCH/DELETE and async jobs) and monitors (\`/v1/monitors/*\`, not registry endpoints); both are \`socialcrawl_manage\` areas.
550
-
551
- ## 5. Bundled vs live — which to trust
552
-
553
- This server answers most questions from a catalogue generated from the backend registry at build time. That is fast, works without a key, and is right almost always.
554
-
555
- The \`/v1/utility/*\` endpoints answer from the live registry at request time. They are the authority when the two disagree.
556
-
557
- Prefer bundled (the default) for browsing and planning. Reach for the live answer (\`socialcrawl_endpoint\` with a key) when:
558
-
559
- - an endpoint you expect is missing, or a parameter is rejected that the docs say exists;
560
- - you need the exact live price of a metered endpoint;
561
- - you are generating code or docs that must match production today;
562
- - you are not using MCP at all — \`/v1/utility/*\` is the same information over plain HTTP.
563
-
564
- ## 6. Use it well
565
-
566
- **Discover before you spend.** \`list_endpoints\` and \`pricing\` cost nothing. A call that fails validation costs nothing either — this server checks required params, \`oneOf\` groups, enum values, integer ranges, parameter couplings, and CSV limits locally first.
567
-
568
- **Read \`credits_used\`, not the sticker price.** ${metered.length} endpoints are metered: an upfront ceiling is deducted and refunded down to the work actually done. \`/v1/search/news\` advertises a 1-credit base and really charges ${newsBand}. The envelope's \`credits_used\` is the settled number.
569
-
570
- **Let the cache work.** Identical calls inside the TTL are free (2 minutes for search, up to 30 days for transcripts). Do not add junk query params to force freshness — unknown params are stripped from the cache key and never reach upstream. Send \`Cache-Control: no-cache\` if you genuinely need a live fetch.
571
-
572
- **Page correctly.** Pass \`cursor\` back verbatim and stop on \`pagination.has_more === false\`. Never build or decode a cursor. Sending a *different* endpoint's native cursor name is a free 400 with a \`did_you_mean\` hint rather than a silently re-billed page 1.
573
-
574
- **Make retries safe.** Pass an \`idempotencyKey\` (UUIDv4) on anything you might resend. Replays within 24h return the original response for 0 credits. Retry only 429/500/502/503; everything else is a client-side fix that will fail again.
575
-
576
- **Prefer one call to many.** \`search/everywhere\` fans out across 14 sources for a flat 20 credits. A Prism composite fans out across several detail endpoints and folds the legs into one report. Both beat orchestrating the fan-out yourself, in latency and usually in credits.
577
-
578
- **Respect the limits.** 600 requests/minute and 50 concurrent per key, both unbilled when exceeded. Every response carries \`X-RateLimit-Remaining\` and \`X-Concurrency-Remaining\` — pace off those rather than discovering the wall.
579
-
580
- **Keep the request id.** Every response has \`request_id\`. It is the key into the credit ledger (\`socialcrawl_account\` with \`view: "transactions"\`) and the fastest way to get a charge or a bug looked at.
581
-
582
- ## 7. Staying up to date
583
-
584
- - \`socialcrawl_account\` \`view: "freshness"\` — is this server's catalogue current?
585
- - \`npx -y socialcrawl-mcp@latest\` — upgrade the local server.
586
- - \`GET /v1/utility/llms\` (or, with \`SOCIALCRAWL_LEGACY_TOOLS=1\`, \`socialcrawl_discover\` \`action: "llms"\`) — refresh an agent's context corpus in one call instead of scraping docs pages.
587
- - https://www.socialcrawl.dev/llms.txt · \`llms-full.txt\` · \`llms-{platform}.txt\` — the same corpus as static files.
588
- - https://www.socialcrawl.dev/v1/openapi.json — the OpenAPI spec.
530
+ setup: `# SocialCrawl — Setup & Correct Use
531
+
532
+ How to configure SocialCrawl, and how to drive it well once it is configured. Everything on this page is free to verify: \`socialcrawl_endpoint\` and \`socialcrawl_account\` call the API's own free routes at 0 credits.
533
+
534
+ ## 1. Get a key
535
+
536
+ Sign up at https://www.socialcrawl.dev — 100 free credits, no credit card. Keys start with \`sc_\`. Up to 5 active keys per account, rotatable from the dashboard at any time.
537
+
538
+ A key can carry its own \`credit_limit\`. That cap is separate from the account balance: when it is spent you get \`KEY_BUDGET_EXCEEDED\` (402) while the account still has credits. Give each integration its own capped key and a runaway agent can only spend its own budget.
539
+
540
+ ## 2. Configure the key
541
+
542
+ **Local (stdio) — \`npx socialcrawl-mcp\`.** The server reads \`SOCIALCRAWL_API_KEY\` from its own process environment, which your MCP client supplies:
543
+
544
+ \`\`\`json
545
+ {
546
+ "mcpServers": {
547
+ "socialcrawl": {
548
+ "command": "npx",
549
+ "args": ["-y", "socialcrawl-mcp"],
550
+ "env": { "SOCIALCRAWL_API_KEY": "sc_your_key_here" }
551
+ }
552
+ }
553
+ }
554
+ \`\`\`
555
+
556
+ - **Claude Code:** \`claude mcp add socialcrawl -e SOCIALCRAWL_API_KEY=sc_… -- npx -y socialcrawl-mcp\`
557
+ - **Claude Desktop:** \`claude_desktop_config.json\` (macOS \`~/Library/Application Support/Claude/\`, Windows \`%APPDATA%\\Claude\\\`)
558
+ - **Cursor / VS Code / Windsurf:** the same \`mcpServers\` block in that client's MCP config file.
559
+
560
+ **Remote (Streamable HTTP) — no install.** Send the key as a header on every request; it is never accepted in a URL or query string:
561
+
562
+ \`\`\`
563
+ claude mcp add --transport http socialcrawl https://mcp.socialcrawl.dev/mcp \\
564
+ --header "Authorization: Bearer sc_your_key_here"
565
+ \`\`\`
566
+
567
+ \`x-api-key: sc_…\` works too. The remote transport is stateless and builds its context per request — it never falls back to a server-side environment key, so an anonymous caller cannot inherit the operator's credits.
568
+
569
+ **Direct HTTP, no MCP.** \`x-api-key: sc_…\` on every \`/v1/*\` request against \`https://www.socialcrawl.dev\`.
570
+
571
+ ## 3. Verify the setup
572
+
573
+ \`\`\`
574
+ socialcrawl_account
575
+ \`\`\`
576
+
577
+ 0 credits, and it proves auth end to end. If it fails, the message names the cause: \`MISSING_API_KEY\` means the env var never reached the process; \`INVALID_API_KEY\` means it is malformed, revoked, or from another environment.
578
+
579
+ Then confirm this server's catalogue is current:
580
+
581
+ \`\`\`
582
+ socialcrawl_account view: "freshness"
583
+ \`\`\`
584
+
585
+ This is the one check people skip. The MCP ships a catalogue generated when it was built; the API keeps moving. \`freshness\` compares the two and tells you whether to upgrade (\`npx -y socialcrawl-mcp@latest\`). Calls always hit the live API and keep working — but discovery, pricing, and local validation answer from the snapshot, so a newer endpoint looks unknown until you upgrade.
586
+
587
+ ## 4. Pick the right tool
588
+
589
+ | You want to… | Tool |
590
+ |--------------|------|
591
+ | See what platforms exist | \`socialcrawl_find\` with no task |
592
+ | Find an endpoint for a task | \`socialcrawl_find\` with the task in plain words |
593
+ | Know what a call costs | \`socialcrawl_estimate\` with the exact params |
594
+ | Learn one endpoint completely | \`socialcrawl_endpoint\` with its id |
595
+ | Fetch data | \`socialcrawl_request\` (one page) or \`socialcrawl_collect\` (N rows) |
596
+ | Scrape / crawl / browse the open web | \`socialcrawl_manage\` \`area: "web"\` |
597
+ | Schedule a recipe on a cadence | \`socialcrawl_manage\` \`area: "monitors"\` |
598
+ | Check balance or explain a charge | \`socialcrawl_account\` |
599
+ | Read a contract (paging, caching, errors…) | \`socialcrawl_endpoint\` with a topic id |
600
+ | Get the live, authoritative answer | \`socialcrawl_endpoint\` with a key set |
601
+
602
+ Two surfaces do **not** go through \`socialcrawl_request\`: the \`web\` platform (action-based, mixes GET/POST/PATCH/DELETE and async jobs) and monitors (\`/v1/monitors/*\`, not registry endpoints); both are \`socialcrawl_manage\` areas.
603
+
604
+ ## 5. Bundled vs live — which to trust
605
+
606
+ This server answers most questions from a catalogue generated from the backend registry at build time. That is fast, works without a key, and is right almost always.
607
+
608
+ The \`/v1/utility/*\` endpoints answer from the live registry at request time. They are the authority when the two disagree.
609
+
610
+ Prefer bundled (the default) for browsing and planning. Reach for the live answer (\`socialcrawl_endpoint\` with a key) when:
611
+
612
+ - an endpoint you expect is missing, or a parameter is rejected that the docs say exists;
613
+ - you need the exact live price of a metered endpoint;
614
+ - you are generating code or docs that must match production today;
615
+ - you are not using MCP at all — \`/v1/utility/*\` is the same information over plain HTTP.
616
+
617
+ ## 6. Use it well
618
+
619
+ **Discover before you spend.** \`list_endpoints\` and \`pricing\` cost nothing. A call that fails validation costs nothing either — this server checks required params, \`oneOf\` groups, enum values, integer ranges, parameter couplings, and CSV limits locally first.
620
+
621
+ **Read \`credits_used\`, not the sticker price.** ${metered.length} endpoints are metered: an upfront ceiling is deducted and refunded down to the work actually done. \`/v1/search/news\` advertises a 1-credit base and really charges ${newsBand}. The envelope's \`credits_used\` is the settled number.
622
+
623
+ **Let the cache work.** Identical calls inside the TTL are free (2 minutes for search, up to 30 days for transcripts). Do not add junk query params to force freshness — unknown params are stripped from the cache key and never reach upstream. Send \`Cache-Control: no-cache\` if you genuinely need a live fetch.
624
+
625
+ **Page correctly.** Pass \`cursor\` back verbatim and stop on \`pagination.has_more === false\`. Never build or decode a cursor. Sending a *different* endpoint's native cursor name is a free 400 with a \`did_you_mean\` hint rather than a silently re-billed page 1.
626
+
627
+ **Make retries safe.** Pass an \`idempotencyKey\` (UUIDv4) on anything you might resend. Replays within 24h return the original response for 0 credits. Retry only 429/500/502/503; everything else is a client-side fix that will fail again.
628
+
629
+ **Prefer one call to many.** \`search/everywhere\` fans out across 14 sources for a flat 20 credits. A Prism composite fans out across several detail endpoints and folds the legs into one report. Both beat orchestrating the fan-out yourself, in latency and usually in credits.
630
+
631
+ **Respect the limits.** 600 requests/minute and 50 concurrent per key, both unbilled when exceeded. Every response carries \`X-RateLimit-Remaining\` and \`X-Concurrency-Remaining\` — pace off those rather than discovering the wall.
632
+
633
+ **Keep the request id.** Every response has \`request_id\`. It is the key into the credit ledger (\`socialcrawl_account\` with \`view: "transactions"\`) and the fastest way to get a charge or a bug looked at.
634
+
635
+ ## 7. Staying up to date
636
+
637
+ - \`socialcrawl_account\` \`view: "freshness"\` — is this server's catalogue current?
638
+ - \`npx -y socialcrawl-mcp@latest\` — upgrade the local server.
639
+ - \`GET /v1/utility/llms\` (or, with \`SOCIALCRAWL_LEGACY_TOOLS=1\`, \`socialcrawl_discover\` \`action: "llms"\`) — refresh an agent's context corpus in one call instead of scraping docs pages.
640
+ - https://www.socialcrawl.dev/llms.txt · \`llms-full.txt\` · \`llms-{platform}.txt\` — the same corpus as static files.
641
+ - https://www.socialcrawl.dev/v1/openapi.json — the OpenAPI spec.
589
642
  `,
590
- discovery: `# SocialCrawl API — Self-Describing Discovery (\`/v1/utility/*\`)
591
-
592
- Six endpoints let any client — an AI agent, a script, a third-party integration — learn the entire API from inside the API. All six are **free (0 credits)**, api-key-authed, and served **in-process from the endpoint registry**: no upstream call, no network hop, no retries, and therefore no drift. Whatever they say is exactly what is callable right now.
593
-
594
- Because \`cost: 0\` takes a read-only billing path, they succeed even at a zero balance and write no ledger rows. They are safe to call in a loop, on startup, or before every request.
595
-
596
- In this MCP server \`socialcrawl_endpoint\` reads \`utility/endpoint\` live, \`socialcrawl_find\` asks \`utility/find\` and \`utility/resolve\`, \`socialcrawl_estimate\` asks \`utility/estimate\`, and \`socialcrawl_account\` checks freshness. The 1.x \`socialcrawl_discover\` tool (with \`SOCIALCRAWL_LEGACY_TOOLS=1\`) renders every payload below as readable markdown.
597
-
598
- ---
599
-
600
- ## \`GET /v1/utility/quickstart\` — get started in one call
601
-
602
- Everything needed for a first successful request, in one response: authentication (header name and where to get a key), the base URL, a ready-to-run first call with curl, the success and error envelope shapes, the credit model with tier rates and billing rules, the **full error taxonomy** (every code with its HTTP status and what it means), the pagination contract, rate limits, live platform/endpoint counts, and a \`next_steps\` block linking onward.
603
-
604
- | Param | Type | Notes |
605
- |-------|------|-------|
606
- | \`platform\` | string | Optional. Tailors the first-call example and links to one platform slug. |
607
-
608
- MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "quickstart"\`.
609
-
610
- Reach for it when bootstrapping a new integration, or when an agent needs the error taxonomy in one payload rather than a docs crawl.
611
-
612
- ---
613
-
614
- ## \`GET /v1/utility/endpoints\` — the endpoint catalogue
615
-
616
- A machine-readable row for every active endpoint: \`id\` (\`platform/resource\`), \`path\`, \`method\`, \`platform\`, \`summary\`, \`credits\` **and \`credits_label\`**, \`archetype\`, \`required_params\`, \`one_of\` groups, \`optional_params\`, a \`paginated\` flag, a \`how_to_use\` link to its guide, and a \`docs_url\`.
617
-
618
- Read **\`credits_label\`**, not \`credits\`. \`credits\` is the static base; the label carries the real shape — \`"1 (standard)"\`, \`"20 (override; tier standard)"\`, \`"2-120 (metered)"\`. For a metered endpoint the base number understates every call.
619
-
620
- The response also carries a \`stats\` block with the **live** registry totals. Those totals are whole-API regardless of any filter, which makes a deliberately non-matching filter the cheapest possible freshness probe.
621
-
622
- | Param | Type | Notes |
623
- |-------|------|-------|
624
- | \`platform\` | string | Exact slug. An unknown slug, or a platform whose endpoints are all withdrawn, returns 404 rather than an empty list that would read as "this platform has nothing". |
625
- | \`search\` | string | Case-insensitive substring over \`platform/resource\` and the summary. |
626
- | \`method\` | enum | \`GET\` or \`POST\`. |
627
-
628
- The array key is \`endpoints\`, deliberately not \`items\`, so the response envelope never stamps a pagination block onto a fixed list.
629
-
630
- MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "catalog"\` (plus \`platform\` / \`search\` / \`method\`).
631
-
632
- ---
633
-
634
- ## \`GET /v1/utility/endpoint\` — how to use one endpoint
635
-
636
- The deepest per-endpoint object the API exposes, and the one to reach for before calling something unfamiliar:
637
-
638
- - **\`credits\`** — cost, label, tier, \`pricing_notes\` (the exact metered rule), and the standing billing rules.
639
- - **\`params\`** — \`required\`, \`one_of\` groups with their rule, and \`optional\`, each with type, description, example, and any \`requires\` coupling.
640
- - **\`pagination\`** — the paging style and the universal param names, or \`null\`.
641
- - **\`cache\`** — TTL in seconds plus the note that identical calls inside it are free.
642
- - **\`response\`** — archetype, schema URL, and a real example response.
643
- - **\`request\`** — a ready-to-run URL and curl.
644
- - **\`links\`** — endpoint docs, platform docs, the platform's \`llms-*.txt\`, and the filtered catalogue.
645
- - **\`related\`** — sibling endpoints with their own guide links, so an agent can walk a platform.
646
-
647
- | Param | Type | Notes |
648
- |-------|------|-------|
649
- | \`id\` | string | \`platform/resource\`, e.g. \`tiktok/profile\`. |
650
- | \`url\` | string | Path form (\`/v1/tiktok/profile\`) or a full URL. |
651
- | \`method\` | enum | Disambiguates a resource registered under more than one method (the stateful \`web\` family). |
652
-
653
- \`id\` or \`url\` is required — one of the two, not both. Omitting both is a 400; an unknown endpoint is a 404 pointing back at the catalogue. Disabled endpoints resolve like unknowns, matching the catalogue.
654
-
655
- MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "endpoint"\` and \`id\`. The tool accepts an id, a path, or a full URL and normalises it for you.
656
-
657
- ---
658
-
659
- ## \`GET /v1/utility/capabilities\` — which endpoints can do X
660
-
661
- Every cross-cutting parameter, once: the \`label\` presets per row family (comments, posts, reviews — which are free by default and which are metered), \`relevance\`, \`judgments\`, \`include\`, \`since\` / \`stop_at_id\`, \`recent_days\`, the row filters, \`seen\`, \`trim\`, \`download_media\`, \`market\` and \`fit\`. Each entry says what the parameter does, what it costs, and lists every endpoint that supports it.
662
-
663
- | Param | Type | Notes |
664
- |-------|------|-------|
665
- | \`param\` | string | Return one capability only (e.g. \`label\`, \`relevance\`, \`seen\`). An unknown one is a 404 naming every capability. |
666
-
667
- MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "capabilities"\` (and \`param\`). Without a key it answers from the bundled registry.
668
-
669
- ---
670
-
671
- ## \`GET /v1/utility/plan\` — turn a job into calls
672
-
673
- A job in plain words ("track mentions of Acme on TikTok and Reddit", "a creator's profile, posts and comments") becomes the exact calls to make, in order: method, path, the params your question filled, the ones still missing (\`ask\`), which step's rows fill a later step (\`binds\`), the credit price of each call, and a curl with every unknown value left as a \`{placeholder}\`. A question outside the planned jobs returns \`uncertain\` with no steps — never a guessed chain.
674
-
675
- | Param | Type | Notes |
676
- |-------|------|-------|
677
- | \`query\` | string | Required. The job in plain words. |
678
-
679
- MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "plan"\` and \`query\` (needs an API key; free).
680
-
681
- ---
682
-
683
- ## \`GET /v1/utility/llms\` — agent context payload
684
-
685
- The SocialCrawl context corpus, served through the API: the same content as \`llms.txt\` for the whole API or one platform. An agent with a key can bootstrap itself in one call instead of scraping documentation pages.
686
-
687
- | Param | Type | Notes |
688
- |-------|------|-------|
689
- | \`platform\` | string | Scope the corpus to one platform slug. |
690
- | \`format\` | enum | \`markdown\` (default) returns the corpus text; \`json\` returns a structured context object. |
691
-
692
- The markdown is produced by the *same* builders that write the static \`llms.txt\` files, never a parallel formatter, so the API-served context and the static files cannot disagree.
693
-
694
- MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "llms"\`.
695
-
696
- ---
697
-
698
- ## When to use these instead of the MCP's own tools
699
-
700
- \`socialcrawl_find\`, \`socialcrawl_endpoint\` and \`socialcrawl_estimate\` answer the same questions **without an API key and without a network round trip**, from a catalogue generated from the same registry. Prefer them for browsing and planning — they are faster and always available.
701
-
702
- Use \`/v1/utility/*\` when you need the **live** answer:
703
-
704
- - An endpoint you expect is missing, or a parameter is rejected that the bundled docs say exists — the bundled catalogue is a build-time snapshot and this server may simply be behind.
705
- - You need the exact live price of a metered endpoint.
706
- - You are generating code, docs, or a client that must match production today.
707
- - You are not going through MCP at all — this is the same information over plain HTTP, for any language or agent framework.
708
-
709
- **Check which situation you are in:** \`socialcrawl_account\` with \`view: "freshness"\` compares the live registry totals against this server's bundled catalogue and tells you whether to upgrade (\`npx -y socialcrawl-mcp@latest\`). Data calls always hit the live API and keep working regardless — it is discovery, pricing, and local validation that age.
710
-
711
- ## Other machine-readable surfaces
712
-
713
- - \`https://www.socialcrawl.dev/v1/openapi.json\` (and \`.yaml\`) — the full OpenAPI spec.
714
- - \`https://www.socialcrawl.dev/llms.txt\`, \`llms-full.txt\`, \`llms-{platform}.txt\` — the same corpus as static files.
715
- - \`GET /v1/credits/balance\` and \`GET /v1/credits/transactions\` — account metadata, also 0 credits.
643
+ discovery: `# SocialCrawl API — Self-Describing Discovery (\`/v1/utility/*\`)
644
+
645
+ Six endpoints let any client — an AI agent, a script, a third-party integration — learn the entire API from inside the API. All six are **free (0 credits)**, api-key-authed, and served **in-process from the endpoint registry**: no upstream call, no network hop, no retries, and therefore no drift. Whatever they say is exactly what is callable right now.
646
+
647
+ Because \`cost: 0\` takes a read-only billing path, they succeed even at a zero balance and write no ledger rows. They are safe to call in a loop, on startup, or before every request.
648
+
649
+ In this MCP server \`socialcrawl_endpoint\` reads \`utility/endpoint\` live, \`socialcrawl_find\` asks \`utility/find\` and \`utility/resolve\`, \`socialcrawl_estimate\` asks \`utility/estimate\`, and \`socialcrawl_account\` checks freshness. The 1.x \`socialcrawl_discover\` tool (with \`SOCIALCRAWL_LEGACY_TOOLS=1\`) renders every payload below as readable markdown.
650
+
651
+ ---
652
+
653
+ ## \`GET /v1/utility/quickstart\` — get started in one call
654
+
655
+ Everything needed for a first successful request, in one response: authentication (header name and where to get a key), the base URL, a ready-to-run first call with curl, the success and error envelope shapes, the credit model with tier rates and billing rules, the **full error taxonomy** (every code with its HTTP status and what it means), the pagination contract, rate limits, live platform/endpoint counts, and a \`next_steps\` block linking onward.
656
+
657
+ | Param | Type | Notes |
658
+ |-------|------|-------|
659
+ | \`platform\` | string | Optional. Tailors the first-call example and links to one platform slug. |
660
+
661
+ MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "quickstart"\`.
662
+
663
+ Reach for it when bootstrapping a new integration, or when an agent needs the error taxonomy in one payload rather than a docs crawl.
664
+
665
+ ---
666
+
667
+ ## \`GET /v1/utility/endpoints\` — the endpoint catalogue
668
+
669
+ A machine-readable row for every active endpoint: \`id\` (\`platform/resource\`), \`path\`, \`method\`, \`platform\`, \`summary\`, \`credits\` **and \`credits_label\`**, \`archetype\`, \`required_params\`, \`one_of\` groups, \`optional_params\`, a \`paginated\` flag, a \`how_to_use\` link to its guide, and a \`docs_url\`.
670
+
671
+ Read **\`credits_label\`**, not \`credits\`. \`credits\` is the static base; the label carries the real shape — \`"1 (standard)"\`, \`"20 (override; tier standard)"\`, \`"2-120 (metered)"\`. For a metered endpoint the base number understates every call.
672
+
673
+ The response also carries a \`stats\` block with the **live** registry totals. Those totals are whole-API regardless of any filter, which makes a deliberately non-matching filter the cheapest possible freshness probe.
674
+
675
+ | Param | Type | Notes |
676
+ |-------|------|-------|
677
+ | \`platform\` | string | Exact slug. An unknown slug, or a platform whose endpoints are all withdrawn, returns 404 rather than an empty list that would read as "this platform has nothing". |
678
+ | \`search\` | string | Case-insensitive substring over \`platform/resource\` and the summary. |
679
+ | \`method\` | enum | \`GET\` or \`POST\`. |
680
+
681
+ The array key is \`endpoints\`, deliberately not \`items\`, so the response envelope never stamps a pagination block onto a fixed list.
682
+
683
+ MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "catalog"\` (plus \`platform\` / \`search\` / \`method\`).
684
+
685
+ ---
686
+
687
+ ## \`GET /v1/utility/endpoint\` — how to use one endpoint
688
+
689
+ The deepest per-endpoint object the API exposes, and the one to reach for before calling something unfamiliar:
690
+
691
+ - **\`credits\`** — cost, label, tier, \`pricing_notes\` (the exact metered rule), and the standing billing rules.
692
+ - **\`params\`** — \`required\`, \`one_of\` groups with their rule, and \`optional\`, each with type, description, example, and any \`requires\` coupling.
693
+ - **\`pagination\`** — the paging style and the universal param names, or \`null\`.
694
+ - **\`cache\`** — TTL in seconds plus the note that identical calls inside it are free.
695
+ - **\`response\`** — archetype, schema URL, and a real example response.
696
+ - **\`request\`** — a ready-to-run URL and curl.
697
+ - **\`links\`** — endpoint docs, platform docs, the platform's \`llms-*.txt\`, and the filtered catalogue.
698
+ - **\`related\`** — sibling endpoints with their own guide links, so an agent can walk a platform.
699
+
700
+ | Param | Type | Notes |
701
+ |-------|------|-------|
702
+ | \`id\` | string | \`platform/resource\`, e.g. \`tiktok/profile\`. |
703
+ | \`url\` | string | Path form (\`/v1/tiktok/profile\`) or a full URL. |
704
+ | \`method\` | enum | Disambiguates a resource registered under more than one method (the stateful \`web\` family). |
705
+
706
+ \`id\` or \`url\` is required — one of the two, not both. Omitting both is a 400; an unknown endpoint is a 404 pointing back at the catalogue. Disabled endpoints resolve like unknowns, matching the catalogue.
707
+
708
+ MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "endpoint"\` and \`id\`. The tool accepts an id, a path, or a full URL and normalises it for you.
709
+
710
+ ---
711
+
712
+ ## \`GET /v1/utility/capabilities\` — which endpoints can do X
713
+
714
+ Every cross-cutting parameter, once: the \`label\` presets per row family (comments, posts, reviews — which are free by default and which are metered), \`relevance\`, \`judgments\`, \`include\`, \`since\` / \`stop_at_id\`, \`recent_days\`, the row filters, \`seen\`, \`trim\`, \`download_media\`, \`market\` and \`fit\`. Each entry says what the parameter does, what it costs, and lists every endpoint that supports it.
715
+
716
+ | Param | Type | Notes |
717
+ |-------|------|-------|
718
+ | \`param\` | string | Return one capability only (e.g. \`label\`, \`relevance\`, \`seen\`). An unknown one is a 404 naming every capability. |
719
+
720
+ MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "capabilities"\` (and \`param\`). Without a key it answers from the bundled registry.
721
+
722
+ ---
723
+
724
+ ## \`GET /v1/utility/plan\` — turn a job into calls
725
+
726
+ A job in plain words ("track mentions of Acme on TikTok and Reddit", "a creator's profile, posts and comments") becomes the exact calls to make, in order: method, path, the params your question filled, the ones still missing (\`ask\`), which step's rows fill a later step (\`binds\`), the credit price of each call, and a curl with every unknown value left as a \`{placeholder}\`. A question outside the planned jobs returns \`uncertain\` with no steps — never a guessed chain.
727
+
728
+ | Param | Type | Notes |
729
+ |-------|------|-------|
730
+ | \`query\` | string | Required. The job in plain words. |
731
+
732
+ MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "plan"\` and \`query\` (needs an API key; free).
733
+
734
+ ---
735
+
736
+ ## \`GET /v1/utility/llms\` — agent context payload
737
+
738
+ The SocialCrawl context corpus, served through the API: the same content as \`llms.txt\` for the whole API or one platform. An agent with a key can bootstrap itself in one call instead of scraping documentation pages.
739
+
740
+ | Param | Type | Notes |
741
+ |-------|------|-------|
742
+ | \`platform\` | string | Scope the corpus to one platform slug. |
743
+ | \`format\` | enum | \`markdown\` (default) returns the corpus text; \`json\` returns a structured context object. |
744
+
745
+ The markdown is produced by the *same* builders that write the static \`llms.txt\` files, never a parallel formatter, so the API-served context and the static files cannot disagree.
746
+
747
+ MCP (1.x tools, \`SOCIALCRAWL_LEGACY_TOOLS=1\`): \`socialcrawl_discover\` with \`action: "llms"\`.
748
+
749
+ ---
750
+
751
+ ## When to use these instead of the MCP's own tools
752
+
753
+ \`socialcrawl_find\`, \`socialcrawl_endpoint\` and \`socialcrawl_estimate\` answer the same questions **without an API key and without a network round trip**, from a catalogue generated from the same registry. Prefer them for browsing and planning — they are faster and always available.
754
+
755
+ Use \`/v1/utility/*\` when you need the **live** answer:
756
+
757
+ - An endpoint you expect is missing, or a parameter is rejected that the bundled docs say exists — the bundled catalogue is a build-time snapshot and this server may simply be behind.
758
+ - You need the exact live price of a metered endpoint.
759
+ - You are generating code, docs, or a client that must match production today.
760
+ - You are not going through MCP at all — this is the same information over plain HTTP, for any language or agent framework.
761
+
762
+ **Check which situation you are in:** \`socialcrawl_account\` with \`view: "freshness"\` compares the live registry totals against this server's bundled catalogue and tells you whether to upgrade (\`npx -y socialcrawl-mcp@latest\`). Data calls always hit the live API and keep working regardless — it is discovery, pricing, and local validation that age.
763
+
764
+ ## Other machine-readable surfaces
765
+
766
+ - \`https://www.socialcrawl.dev/v1/openapi.json\` (and \`.yaml\`) — the full OpenAPI spec.
767
+ - \`https://www.socialcrawl.dev/llms.txt\`, \`llms-full.txt\`, \`llms-{platform}.txt\` — the same corpus as static files.
768
+ - \`GET /v1/credits/balance\` and \`GET /v1/credits/transactions\` — account metadata, also 0 credits.
716
769
  `,
717
- "batch-jobs": `# SocialCrawl API — Batches and Background Jobs
718
-
719
- Some questions are "the same lookup for many things". SocialCrawl answers those in one call up to a batch size, and in a background job beyond it — at the batch endpoint's own per-row price either way.
720
-
721
- ## Synchronous batches (POST, JSON body)
722
-
723
- | Endpoint | Batch | Price |
724
- |----------|-------|-------|
725
- | \`POST /v1/prism/profiles\` | up to 50 \`{ platform, handle }\` pairs (25 with \`include: "posts"\`) | 1 per successful row (5 on LinkedIn); with \`include: "posts"\` plus 1 for a posts page that came back with posts; failed handles refunded |
726
- | \`POST /v1/prism/post-stats\` | up to 100 post URLs, mixed platforms | 1 per successful URL (2 on Instagram, 5 on LinkedIn); dead and failed URLs refunded |
727
- | \`POST /v1/prism/comment-lookup\` | up to 25 known comments | 2 per found TikTok item, 5 per found Instagram item; the rest refunded |
728
- | \`POST /v1/youtube/videos\` / \`channels\` | up to 1,000 ids | 5 credits per 50-id chunk (1,000 ids = 100 credits) |
729
- | \`POST /v1/youtube/transcripts\` | up to 100 ids | 3 per successful transcript; the rest refunded |
730
-
731
- In this server: \`socialcrawl_request\` with the array in \`body\` (e.g. \`body: { items: [{ platform: "tiktok", handle: "scout2015" }] }\`).
732
-
733
- ## Background jobs: \`/v1/prism/jobs\`
734
-
735
- For 51 to 5,000 items:
736
-
737
- 1. **Submit** — \`POST /v1/prism/jobs\` with \`{ "endpoint": "prism/profiles" | "prism/post-stats", "items": [...] }\` (plus \`include: "posts"\` and \`since\` for profiles, and an optional \`webhook: { "url": "https://…" }\`). Every item is validated before anything is held — a bad item is a free 400 naming its index. The whole job's ceiling is held at submit and the 202 reports it as \`credits_used\`, with the \`job_id\` and, if you asked for a webhook, its signing secret (shown once).
738
- 2. **Poll** — \`GET /v1/prism/jobs/{job_id}\` (free): \`status\` (\`queued\`, \`running\`, \`completed\`, \`failed\`), \`chunks_done\` of \`chunk_count\`, credits held and charged, the \`summary\` once complete, and \`results\` — the rows of up to five finished chunks, each exactly as the batch endpoint returns it plus \`index\`. Send \`next_cursor\` back as \`cursor\` for more rows; \`results_complete\` is true once every row has been read.
739
- 3. **List** — \`GET /v1/prism/jobs\` (free) lists this key's jobs, newest first.
740
-
741
- **Billing.** The job runs in chunks of 50 (25 with posts), each exactly as a call to the batch endpoint. When the last chunk settles, the charge is the sum of the rows that succeeded and the rest of the hold is refunded; a job where every row failed is \`failed\` and charged nothing. A 402 at submit creates nothing. The same \`Idempotency-Key\` with the same body replays the job at 0 credits; with a different body it is a 422.
742
-
743
- **Webhook.** One \`batch.completed\` event (never the rows) signed \`x-socialcrawl-signature: t=<unix>,v1=<hmac>\` with the per-job secret, to a public https URL.
744
-
745
- In this server: \`socialcrawl_request\` with platform \`prism\`, resource \`jobs\` and the job in \`body\` to submit; resource \`jobs/{job_id}\` with \`params: { job_id }\` (or resource \`jobs/<id>\`) to poll; resource \`jobs\` with no body to list.
746
-
747
- ## Any GET as a background job
748
-
749
- A GET that can outlast your client's timeout (\`twitter/ai-search\`, a deep walk) runs in the background when you add \`async=true\` (or send \`Prefer: respond-async\`). The answer is a 202 with \`data.job_id\` (\`bj_…\`), a \`Location\` header and \`Retry-After\`; read it free at \`GET /v1/prism/jobs/{job_id}\`, where \`results[0].response\` is exactly what the call returns. Nothing is held at submit: the call is validated now and billed as itself when it runs. \`Idempotency-Key\` returns the same job on a retry. Any other \`async\` value is a free 400. Not offered on async or always-streaming endpoints, or on \`prism/discover\`, which has its own \`async\`.
750
-
770
+ "batch-jobs": `# SocialCrawl API — Batches and Background Jobs
771
+
772
+ Some questions are "the same lookup for many things". SocialCrawl answers those in one call up to a batch size, and in a background job beyond it — at the batch endpoint's own per-row price either way.
773
+
774
+ ## Synchronous batches (POST, JSON body)
775
+
776
+ | Endpoint | Batch | Price |
777
+ |----------|-------|-------|
778
+ | \`POST /v1/prism/profiles\` | up to 50 \`{ platform, handle }\` pairs (25 with \`include: "posts"\`) | 1 per successful row (5 on LinkedIn); with \`include: "posts"\` plus 1 for a posts page that came back with posts; failed handles refunded |
779
+ | \`POST /v1/prism/post-stats\` | up to 100 post URLs, mixed platforms | 1 per successful URL (2 on Instagram, 5 on LinkedIn); dead and failed URLs refunded |
780
+ | \`POST /v1/prism/comment-lookup\` | up to 25 known comments | 2 per found TikTok item, 5 per found Instagram item; the rest refunded |
781
+ | \`POST /v1/youtube/videos\` / \`channels\` | up to 1,000 ids | 5 credits per 50-id chunk (1,000 ids = 100 credits) |
782
+ | \`POST /v1/youtube/transcripts\` | up to 100 ids | 3 per successful transcript; the rest refunded |
783
+
784
+ In this server: \`socialcrawl_request\` with the array in \`body\` (e.g. \`body: { items: [{ platform: "tiktok", handle: "scout2015" }] }\`).
785
+
786
+ ## Background jobs: \`/v1/prism/jobs\`
787
+
788
+ For 51 to 5,000 items:
789
+
790
+ 1. **Submit** — \`POST /v1/prism/jobs\` with \`{ "endpoint": "prism/profiles" | "prism/post-stats", "items": [...] }\` (plus \`include: "posts"\` and \`since\` for profiles, and an optional \`webhook: { "url": "https://…" }\`). Every item is validated before anything is held — a bad item is a free 400 naming its index. The whole job's ceiling is held at submit and the 202 reports it as \`credits_used\`, with the \`job_id\` and, if you asked for a webhook, its signing secret (shown once).
791
+ 2. **Poll** — \`GET /v1/prism/jobs/{job_id}\` (free): \`status\` (\`queued\`, \`running\`, \`completed\`, \`failed\`), \`chunks_done\` of \`chunk_count\`, credits held and charged, the \`summary\` once complete, and \`results\` — the rows of up to five finished chunks, each exactly as the batch endpoint returns it plus \`index\`. Send \`next_cursor\` back as \`cursor\` for more rows; \`results_complete\` is true once every row has been read.
792
+ 3. **List** — \`GET /v1/prism/jobs\` (free) lists this key's jobs, newest first.
793
+
794
+ **Billing.** The job runs in chunks of 50 (25 with posts), each exactly as a call to the batch endpoint. When the last chunk settles, the charge is the sum of the rows that succeeded and the rest of the hold is refunded; a job where every row failed is \`failed\` and charged nothing. A 402 at submit creates nothing. The same \`Idempotency-Key\` with the same body replays the job at 0 credits; with a different body it is a 422.
795
+
796
+ **A GET endpoint as the job.** \`endpoint\` can also be the path of any GET endpoint (for example \`youtube/channel/about\`), with up to 1,000 \`items\`, each an object of that endpoint's query params (\`{ "handle": "@mkbhd" }\`). Each item runs as the direct call would — served, cached and billed per call, three side by side — so the job itself holds nothing; \`credits_max\` is the most the job can settle at, an item that walks counted at its walk ceiling (\`max_pages\` pages at their most, capped by \`max_credits\`). A streaming-only or non-GET endpoint is refused free.
797
+
798
+ **Long walks finish inside a job.** An item that sends \`max_pages\`, \`max_items\` or \`max_credits\` and stops on \`time_budget\` resumes from its own \`pagination.next_cursor\` with what is left of those limits (50 pages when only a target is sent), up to 5 times inside the job's 260 s ceiling, and answers one merged walk: rows once (repeats counted under \`data.walk.duplicates\`), pages, credits and \`request_ids\` summed, the last cursor, and \`data.walk.resumes\` (the extra calls). A failed page is asked again up to twice; a resume that still fails keeps the rows and ends \`page_error\` with \`walk_incomplete\`, and one refused under \`max_credits\` ends \`max_credits\`. Every page is billed as a direct call.
799
+
800
+ **Webhook.** One \`batch.completed\` event (never the rows) signed \`x-socialcrawl-signature: t=<unix>,v1=<hmac>\` with the per-job secret, to a public https URL.
801
+
802
+ In this server: \`socialcrawl_request\` with platform \`prism\`, resource \`jobs\` and the job in \`body\` to submit; resource \`jobs/{job_id}\` with \`params: { job_id }\` (or resource \`jobs/<id>\`) to poll; resource \`jobs\` with no body to list.
803
+
804
+ ## Any GET as a background job
805
+
806
+ A GET that can outlast your client's timeout (\`twitter/ai-search\`, a deep walk) runs in the background when you add \`async=true\` (or send \`Prefer: respond-async\`). The answer is a 202 with \`data.job_id\` (\`bj_…\`), a \`Location\` header and \`Retry-After\`; read it free at \`GET /v1/prism/jobs/{job_id}\`, where \`results[0].response\` is exactly what the call returns. Nothing is held at submit: the call is validated now and billed as itself when it runs. \`Idempotency-Key\` returns the same job on a retry. Any other \`async\` value is a free 400. Not offered on async or always-streaming endpoints, or on \`prism/discover\`, which has its own \`async\`.
807
+
751
808
  In this server: add \`async: "true"\` to \`params\` on \`socialcrawl_request\`; the answer carries the poll call to make.`,
752
- monitors: `# SocialCrawl API — Monitors
753
-
754
- Monitors are the **stateful, scheduled wrapper** around any SocialCrawl recipe. A monitor re-runs a registered endpoint or a Prism composite on a cadence, delivers each result to a signed webhook, evaluates alert rules, and accumulates a per-run time-series you can read back. *"Prism answers once; monitors watch it for you."*
755
-
756
- Monitors are **not** registry endpoints — they live at \`/v1/monitors/*\` and are managed through \`socialcrawl_manage\` with \`area: "monitors"\`, not \`socialcrawl_request\`. Auth is the same \`x-api-key\`.
757
-
758
- (Not to be confused with **web monitors**, \`/v1/web/monitors/*\` — those watch a single URL for content changes and are driven by \`socialcrawl_manage\` \`area: "web"\` with the \`monitor_*\` actions.)
759
-
760
- ## Operations (\`socialcrawl_manage\` \`area: "monitors"\` actions)
761
-
762
- | Action | HTTP | What it does |
763
- |--------|------|--------------|
764
- | \`create\` | \`POST /v1/monitors\` | Create a monitor. Validates the recipe and its params (the same checks \`/v1\` runs, so a value the endpoint would refuse is a free 400), enforces the plan's active-monitor cap, returns the monitor + \`estimated_cost_per_run\`/\`estimated_monthly_cost\`/\`next_run_at\` and (once) the webhook signing secret. |
765
- | \`list\` | \`GET /v1/monitors\` | Owner-scoped, cursor-paginated list. Filter with \`status\` = active \| paused \| all. |
766
- | \`get\` | \`GET /v1/monitors/:id\` | A single monitor (404 if not owned — never leaks existence or the secret). |
767
- | \`runs\` | \`GET /v1/monitors/:id/runs\` | Reverse-chron run history, each with its \`legs[]\` + \`alerts_fired\` + \`skip_reason\`. \`include=result\` adds the stored result (legacy monitors), \`include=numbers\` a track run's numbers and deltas, \`include=result,numbers\` both. |
768
- | \`timeseries\` | \`GET /v1/monitors/:id/timeseries\` | The headline read — each stored run's metrics as a \`{ t, metrics }\` series (reads snapshots, no live API calls). Track monitors add a per-row \`series\`; \`row\` (comma-separated row ids) narrows it. |
769
- | \`export\` | \`GET /v1/monitors/:id/export\` | A monitor's stored numbers as \`format\` = \`csv\` (default) or \`ndjson\`, optional \`from\`/\`to\`. Free; reads at most the newest 1,000 runs in the window. |
770
- | \`pause\` / \`resume\` | \`PATCH /v1/monitors/:id\` | Pause or resume scheduling. A paused monitor is not run, billed, or counted against the cap. |
771
- | \`delete\` | \`DELETE /v1/monitors/:id\` | Unschedule + cascade-delete runs and the webhook. |
772
-
773
- \`dry_run: true\` on \`create\` sends \`?dry_run=1\`: the API runs the real call's checks (including the plan cap) and answers \`{ valid, normalized_body, estimate }\` without writing, scheduling or charging anything. Its \`estimate\` carries \`recipe_cost_per_run\`, \`scheduling_premium\`, \`estimated_cost_per_run\`, \`runs_per_month\`, \`estimated_monthly_cost\` and \`next_run_at\`.
774
-
775
- ## Create parameters
776
-
777
- - \`recipe\` (required) — any registered **GET** endpoint or Prism composite as \`platform/resource\` (e.g. \`prism/brand-mentions\`, \`tiktok/profile/videos\`, or a list composite such as \`prism/profile/comments\`). POST batch endpoints cannot be monitored.
778
- - \`cadence\` (required) — \`hourly\` \| \`daily\` \| \`weekly\`, or a cron expression.
779
- - \`webhook_url\` (required unless \`track\` is set) — HTTPS endpoint that receives each run, signed with \`x-socialcrawl-signature\` (HMAC-SHA256, timestamped).
780
- - \`params\` — parameters passed to the recipe every run. Frozen at create, with relative tokens resolved at each run: \`now-<N>d\` becomes the date N days back (\`YYYY-MM-DD\`), \`now-<N>h\` the ISO timestamp N hours back (e.g. \`since: "now-3h"\` on an hourly \`prism/profile/comments\` monitor).
781
- - \`alert_rules\` — \`[{ metric, op, value, window? }]\`. Ops: \`gt\`, \`lt\`, \`gte\`, \`lte\`, \`abs_change_gt\`, \`pct_change_gt\`, \`pct_change_lt\` (the change ops compare a run to the previous comparable run; \`window\` is \`1d\` \| \`1w\`). To alert on new items, use the \`rows_new\` metric (rows not seen in the previous run; ops \`gt\` / \`gte\`): \`{"metric":"rows_new","op":"gt","value":0}\`. \`rows_new\` requires \`track\` (below): without it the create is refused with "rows_new needs track".
782
- - \`track\` — makes a tracking monitor that keeps numbers per row between runs: \`{ metrics, row_key?, max_rows? }\`. \`metrics\` is 1-20 paths to numbers: \`items[].<numeric path>\` reads one per row of a list recipe (e.g. \`items[].post.engagement.views\`; the part after \`items[].\` is relative to the row), and a plain dot path reads one off the page (e.g. \`author.followers\`). \`row_key\` is the dot path of a stable id inside a row (default: the row's own id, e.g. \`post.id\`; required when the rows have none); \`max_rows\` is 1-200 (default 100). With \`track\`, \`webhook_url\` is optional (a download-only monitor). New-items alert, whole: \`track: { metrics: ["items[].post.engagement.views"] }\`, \`alert_rules: [{"metric":"rows_new","op":"gt","value":0}]\`, \`suppress_webhook_unless_alert: true\`; keep \`track\` and \`alert_rules\` together.
783
- - \`webhook_format\` — \`full\` (default: the run's payload, plus \`numbers\`/\`deltas\` on a track monitor) or \`rows\` (one flat, spreadsheet-ready line per row and metric; needs \`track\`). Needs \`webhook_url\`.
784
- - \`webhook_rows\` — \`all\` (default) or \`new\`: only the rows new since the previous run. Needs \`track\` with an \`items[].\` metric and a \`webhook_url\`; the first run is a \`baseline: true\` run with no rows.
785
- - \`suppress_webhook_unless_alert\` — only deliver the webhook when a rule trips.
786
- - \`name\`, \`output_schema\`, \`webhook_secret\` (8-200 chars) — optional.
787
-
788
- ## Track monitors (numbers only)
789
-
790
- \`\`\`json
791
- { "recipe": "tiktok/profile/videos", "params": { "handle": "khaby.lame" }, "cadence": "daily",
792
- "track": { "metrics": ["items[].post.engagement.views", "items[].post.engagement.likes"] } }
793
- \`\`\`
794
-
795
- - Each path is checked against the recipe's page at create: a typo or a non-numeric field is a free 400 with a "Did you mean" hint. Prism recipes with no fixed response shape are created with a warning to check the first run.
796
- - On a track monitor an alert rule must name one of \`track.metrics\`, or \`rows_new\`.
797
- - Each run stores only those numbers per row plus the change against the previous run, not the page. Read them with \`export\`, \`timeseries\` (\`row\` narrows the per-row series), or \`runs\` with \`include=numbers\`.
798
-
799
- ## Plan caps
800
-
801
- Active monitors per account follow the highest credit pack it has bought: **Free 3, Starter 10, Growth 25, Pro 100, Enterprise 500**. Paused monitors do not count. Creating one past the cap is \`403 MONITOR_LIMIT_REACHED\`; pause or delete one to free a slot.
802
-
803
- ## Billing
804
-
809
+ monitors: `# SocialCrawl API — Monitors
810
+
811
+ Monitors are the **stateful, scheduled wrapper** around any SocialCrawl recipe. A monitor re-runs a registered endpoint or a Prism composite on a cadence, delivers each result to a signed webhook, evaluates alert rules, and accumulates a per-run time-series you can read back. *"Prism answers once; monitors watch it for you."*
812
+
813
+ Monitors are **not** registry endpoints — they live at \`/v1/monitors/*\` and are managed through \`socialcrawl_manage\` with \`area: "monitors"\`, not \`socialcrawl_request\`. Auth is the same \`x-api-key\`.
814
+
815
+ (Not to be confused with **web monitors**, \`/v1/web/monitors/*\` — those watch a single URL for content changes and are driven by \`socialcrawl_manage\` \`area: "web"\` with the \`monitor_*\` actions.)
816
+
817
+ ## Operations (\`socialcrawl_manage\` \`area: "monitors"\` actions)
818
+
819
+ | Action | HTTP | What it does |
820
+ |--------|------|--------------|
821
+ | \`create\` | \`POST /v1/monitors\` | Create a monitor. Validates the recipe and its params (the same checks \`/v1\` runs, so a value the endpoint would refuse is a free 400), enforces the plan's active-monitor cap, returns the monitor + \`estimated_cost_per_run\`/\`estimated_monthly_cost\`/\`next_run_at\` and (once) the webhook signing secret. |
822
+ | \`list\` | \`GET /v1/monitors\` | Owner-scoped, cursor-paginated list. Filter with \`status\` = active \| paused \| all. |
823
+ | \`get\` | \`GET /v1/monitors/:id\` | A single monitor (404 if not owned — never leaks existence or the secret). |
824
+ | \`runs\` | \`GET /v1/monitors/:id/runs\` | Reverse-chron run history, each with its \`legs[]\` + \`alerts_fired\` + \`skip_reason\`. \`include=result\` adds the stored result (legacy monitors), \`include=numbers\` a track run's numbers and deltas, \`include=result,numbers\` both. |
825
+ | \`timeseries\` | \`GET /v1/monitors/:id/timeseries\` | The headline read — each stored run's metrics as a \`{ t, metrics }\` series (reads snapshots, no live API calls). Track monitors add a per-row \`series\`; \`row\` (comma-separated row ids) narrows it. |
826
+ | \`export\` | \`GET /v1/monitors/:id/export\` | A monitor's stored numbers as \`format\` = \`csv\` (default) or \`ndjson\`, optional \`from\`/\`to\`. \`shape\` = \`long\` (default: one line per run, row and metric, \`t,row_id,metric,value,abs_change,pct_change\`) or \`shape=rows\` (one line per run and row with a column per metric, \`run_at_utc\` as \`DD/MM/YYYY HH:mm\`; CSV text cells starting \`=\`, \`+\`, \`-\` or \`@\` get a leading apostrophe). Free; reads at most the newest 1,000 runs in the window. |
827
+ | \`pause\` / \`resume\` | \`PATCH /v1/monitors/:id\` | Pause or resume scheduling. A paused monitor is not run, billed, or counted against the cap. Either can carry \`max_credits_per_month\` and \`email_digest\` in the same PATCH. Resuming a monitor paused by its monthly cap needs no free plan slot. |
828
+ | \`update\` | \`PATCH /v1/monitors/:id\` | Change \`max_credits_per_month\` (\`null\` removes the cap) and/or \`email_digest\` without touching the status. |
829
+ | \`delete\` | \`DELETE /v1/monitors/:id\` | Unschedule + cascade-delete runs and the webhook. |
830
+
831
+ \`dry_run: true\` on \`create\` sends \`?dry_run=1\`: the API runs the real call's checks (including the plan cap) and answers \`{ valid, normalized_body, estimate }\` without writing, scheduling or charging anything. Its \`estimate\` carries \`recipe_cost_per_run\`, \`scheduling_premium\`, \`estimated_cost_per_run\`, \`runs_per_month\` (730 hourly, 30 daily, 4 weekly), \`estimated_monthly_cost\`, \`monthly_cap\` and \`runs_until_cap\` (null without a cap), \`legs_billed_separately\` and \`next_run_at\`. A dry run always answers 200 with the quote; when the real create would be refused at the plan's monitor or list-subject limit it adds \`data.would_be_refused\` (\`type\` MONITOR_LIMIT_REACHED, \`message\`, \`slots\` with \`used\`, \`adding\`, \`limit\`, \`plan\`).
832
+
833
+ **Reading a monitor.** \`list\` and \`get\` carry \`max_credits_per_month\`, \`email_digest\`, \`legs_billed_separately\` and \`paused_because\` — \`monthly_cap\`, \`consecutive_skips\`, \`webhook_failing\`, or null when active or paused by you. The create answer is \`{ monitor, webhook_secret }\` (not the usual envelope); on a recipe whose sources bill themselves its \`warnings\` say those sources are billed on top of the quote. An hourly monitor runs at its own minute of the hour, fixed at create (the quote's \`next_run_at\` shows the top of the hour).
834
+
835
+ ## Create parameters
836
+
837
+ - \`recipe\` (required) — any registered **GET** endpoint or Prism composite as \`platform/resource\` (e.g. \`prism/brand-mentions\`, \`tiktok/profile/videos\`, or a list composite such as \`prism/profile/comments\`). POST batch endpoints cannot be monitored.
838
+ - \`cadence\` (required) — \`hourly\` \| \`daily\` \| \`weekly\`, or a cron expression.
839
+ - \`webhook_url\` (required unless \`track\` is set) — HTTPS endpoint that receives each run, signed with \`x-socialcrawl-signature\` (HMAC-SHA256, timestamped).
840
+ - \`params\` — parameters passed to the recipe every run. Frozen at create, with relative tokens resolved at each run: \`now-<N>d\` becomes the date N days back (\`YYYY-MM-DD\`), \`now-<N>h\` the ISO timestamp N hours back (e.g. \`since: "now-3h"\` on an hourly \`prism/profile/comments\` monitor).
841
+ - \`alert_rules\` — \`[{ metric, op, value, window? }]\`. Ops: \`gt\`, \`lt\`, \`gte\`, \`lte\`, \`abs_change_gt\`, \`pct_change_gt\`, \`pct_change_lt\` (the change ops compare a run to the previous comparable run; \`window\` is \`1d\` \| \`1w\`). To alert on new items, use the \`rows_new\` metric (rows not seen in the previous run; ops \`gt\` / \`gte\`): \`{"metric":"rows_new","op":"gt","value":0}\`. \`rows_new\` requires \`track\` (below): without it the create is refused with "rows_new needs track".
842
+ - \`track\` — makes a tracking monitor that keeps numbers per row between runs: \`{ metrics, row_key?, max_rows? }\`. \`metrics\` is 1-20 paths to numbers: \`items[].<numeric path>\` reads one per row of a list recipe (e.g. \`items[].post.engagement.views\`; the part after \`items[].\` is relative to the row), and a plain dot path reads one off the page (e.g. \`author.followers\`). \`row_key\` is the dot path of a stable id inside a row (default: the row's own id, e.g. \`post.id\`; required when the rows have none); \`max_rows\` is 1-200 (default 100). With \`track\`, \`webhook_url\` is optional (a download-only monitor). New-items alert, whole: \`track: { metrics: ["items[].post.engagement.views"] }\`, \`alert_rules: [{"metric":"rows_new","op":"gt","value":0}]\`, \`suppress_webhook_unless_alert: true\`; keep \`track\` and \`alert_rules\` together.
843
+ - \`webhook_format\` — \`full\` (default: the run's payload, plus \`numbers\`/\`deltas\` on a track monitor) or \`rows\` (one flat, spreadsheet-ready line per row and metric; needs \`track\`). Needs \`webhook_url\`.
844
+ - \`webhook_rows\` — \`all\` (default) or \`new\`: only the rows new since the previous run. Needs \`track\` with an \`items[].\` metric and a \`webhook_url\`; the first run is a \`baseline: true\` run with no rows.
845
+ - \`suppress_webhook_unless_alert\` — only deliver the webhook when a rule trips.
846
+ - \`max_credits_per_month\` — the most the monitor may bill in a calendar month (UTC), whole credits 1 to 10,000,000. The run that would pass it is skipped unbilled and the monitor pauses with \`paused_because: "monthly_cap"\` until the 1st. A free 400 below one run's price (recipe cost + 1) and on recipes whose sources bill themselves (\`search/multi\`, \`tiktokshop/sales\`, the tag searches).
847
+ - \`email_digest\` — \`daily\` or \`off\` (default). With it on the monitor has a second destination, so it keeps running when its webhook stops.
848
+ - \`name\`, \`output_schema\`, \`webhook_secret\` (8-200 chars) — optional.
849
+
850
+ ## Track monitors (numbers only)
851
+
852
+ \`\`\`json
853
+ { "recipe": "tiktok/profile/videos", "params": { "handle": "khaby.lame" }, "cadence": "daily",
854
+ "track": { "metrics": ["items[].post.engagement.views", "items[].post.engagement.likes"] } }
855
+ \`\`\`
856
+
857
+ - Each path is checked against the recipe's page at create: a typo or a non-numeric field is a free 400 with a "Did you mean" hint. Prism recipes with no fixed response shape are created with a warning to check the first run.
858
+ - On a track monitor an alert rule must name one of \`track.metrics\`, or \`rows_new\`.
859
+ - Each run stores only those numbers per row plus the change against the previous run, not the page. Read them with \`export\`, \`timeseries\` (\`row\` narrows the per-row series), or \`runs\` with \`include=numbers\`.
860
+
861
+ ## Plan caps
862
+
863
+ Active monitors per account follow the highest credit pack it has bought: **Free 3, Starter 10, Growth 25, Pro 100, Enterprise 500**. Paused monitors do not count. Creating one past the cap is \`403 MONITOR_LIMIT_REACHED\`; pause or delete one to free a slot.
864
+
865
+ ## Billing
866
+
805
867
  Managing monitors (create/list/get/runs/timeseries/export/pause/delete) costs **0 credits**. Each *scheduled run* bills the underlying recipe's normal cost (priced with the frozen params) **plus a 1-credit scheduling premium** — so a daily \`prism/reputation\` monitor costs 30 + 1 = 31 credits per run. Creating a monitor holds and charges nothing; the first run is at \`next_run_at\`. Runs skipped for insufficient balance are never charged. A run whose recipe fails is fully refunded, and so is a run that records nothing: a track run where none of the tracked metrics has a value, or whose page comes back empty, is marked \`failed\` with a \`skip_reason\`, fires no alert, sends no webhook, and is never the comparison point for the next run. Use \`estimated_cost_per_run\` / \`estimated_monthly_cost\` (returned by \`create\`, or a create \`dry_run\`) to budget, and \`socialcrawl_estimate\` with the recipe's \`id\` to price it first. The webhook auto-pauses after 10 consecutive delivery failures.`,
806
- cohorts: `# SocialCrawl API — Cohorts
807
-
808
- Cohorts answer a **narrower question than open social listening**: not "who is talking about X?" but "**which of _these specific_ public identities is talking about X?**" You supply the panel — a purchaser list, a customer roster, a creator shortlist — and get bounded, deterministic, metered retrieval over exactly those accounts.
809
-
810
- Cohorts are **not** registry endpoints. They live at \`/v1/cohorts/*\` and \`/v1/cohort-queries/*\`, mix POST/PUT/GET/DELETE with an async lifecycle, and are driven by \`socialcrawl_manage\` with \`area: "cohorts"\` rather than \`socialcrawl_request\`. Auth is the same \`x-api-key\`.
811
-
812
- It is **not** audience discovery. It does not find people, infer demographics, or score interests. It takes a list you already have and reports what those public accounts posted.
813
-
814
- ## What SocialCrawl receives
815
-
816
- Two things per member, and nothing else:
817
-
818
- - \`platform\` + \`handle\` — the public identity (the profile URL for LinkedIn).
819
- - \`external_id\` — your own opaque key, echoed back on every match and every coverage row so you can join results to your own records.
820
-
821
- Whatever produced the list (receipts, CRM segments, panel attributes) stays on your side; there is no field for it here. Both the identity and your \`external_id\` are encrypted at rest with a per-account key and never appear in logs, job payloads, traces, or error messages. \`get\` returns counts and metadata — it will not read the identities back to you.
822
-
823
- ## Supported identity platforms
824
-
825
- \`instagram\` · \`tiktok\` · \`youtube\` · \`twitter\` · \`threads\` · \`bluesky\` · \`truth-social\` · \`kwai\` · \`twitch\` · \`linkedin\`
826
-
827
- Anything else is rejected at upload (400 \`COHORT_IDENTITY_PLATFORM_UNSUPPORTED\`), so an unsupported identity can never silently cost you a query that returns nothing. \`socialcrawl_manage\` also checks the list locally before it sends.
828
-
829
- ## The lifecycle
830
-
831
- | Action | HTTP | Cost |
832
- |--------|------|------|
833
- | \`create\` | \`POST /v1/cohorts\` | 0 |
834
- | \`add_members\` | \`PUT /v1/cohorts/:id/members\` (repeat per 1,000) | 0 |
835
- | \`estimate_cost\` | *local calculation, no API call* | 0 |
836
- | \`query\` | \`POST /v1/cohorts/:id/queries\` -> \`202\` | metered |
837
- | \`query_status\` | \`GET /v1/cohort-queries/:id\` | 0 |
838
- | \`query_results\` | \`GET /v1/cohort-queries/:id/results\` | 0 |
839
- | \`query_cancel\` | \`DELETE /v1/cohort-queries/:id\` | 0 |
840
- | \`get\` / \`delete\` | \`GET\`/\`DELETE /v1/cohorts/:id\` | 0 |
841
-
842
- Writes (\`create\`, \`add_members\`, \`query\`) require an \`Idempotency-Key\` UUID. The tool generates one when you omit it and echoes it back in the response header — **reuse that key to retry**, or a repeated call creates a second cohort or reserves a second query. Replaying a key with a *different* body returns 422 \`IDEMPOTENCY_KEY_PAYLOAD_MISMATCH\`.
843
-
844
- **Dry run.** \`dry_run: true\` on \`create\`, \`add_members\` and \`query\` sends \`?dry_run=1\`: the API runs that route's own checks (Idempotency-Key, body schema, the cohort existing) and answers \`{ valid, normalized_params, estimate }\` at 0 credits. Nothing is created, written or reserved, and the Idempotency-Key is not claimed, so the same key can go with the real call. A \`query\` dry run echoes the normalized body and the cohort's \`member_count\`, and caps \`expected_max\` at your \`max_credits\`; the exact ceiling is what \`estimate_cost\` computes.
845
-
846
- ## Limits
847
-
848
- | Limit | Value |
849
- |-------|-------|
850
- | Cohorts per API key | 100 |
851
- | Members per cohort | 10,000 |
852
- | Members per upload call | 1,000 |
853
- | Keywords per query | 20 |
854
- | \`max_pages_per_identity\` | 1-20 |
855
- | \`max_items_per_identity\` | 1-1,000 |
856
- | \`retention_days\` | 7-90 (default 30) |
857
- | \`query_results\` \`limit\` | 1-500 (default 100) |
858
-
859
- Re-sending an \`external_id\` you have already uploaded **updates** its identity rather than adding a row, so a nightly full re-push is safe and does not inflate the count. Two different \`external_id\`s claiming the same normalized identity inside one cohort is 409 \`COHORT_IDENTITY_CONFLICT\` rather than a quiet double count.
860
-
861
- ## Matching is code, not a model
862
-
863
- - **Normalization** — keyword and candidate text are both Unicode NFKC, case-folded, whitespace-collapsed.
864
- - **Whole-word only** — \`acme\` matches "my acme review", never "acmecorp".
865
- - **CJK caveat** — CJK scripts count as letters, so a Korean/Japanese/Chinese keyword embedded inside surrounding CJK text will not match; pass the surrounding form as its own keyword.
866
- - **Echoed normalized** — submit "Acme Pro", a match reports \`"acme pro"\`.
867
- - **Title and description** — on YouTube and Twitch both surfaces are matched, and \`text_excerpt\` carries whichever one hit.
868
-
869
- No stemming, fuzzy matching, semantic expansion, sentiment scoring, or brand-alias inference. Want "Acme" to also catch "AcmeCo"? Pass both. Only content the source attributes to the identity you supplied is eligible — profile lookups resolve the account and its cursor and never become results.
870
-
871
- ## Opt-in topic matching (newly added, subject to availability)
872
-
873
- > **Newly added.** The API contract accepts these fields, but topic matching may not yet be live on every deployment. A keyword-only query (no \`match\`, no \`topics\`) works exactly as described above either way.
874
-
875
- A query may also send \`topics\` — 1-10 objects of \`{ id, description }\` (\`id\` 1-64 of letters, digits, \`_\`, \`-\`, unique; \`description\` one plain sentence of 1-300 characters) — with \`match\`:
876
-
877
- | \`match\` | Which items are checked | Which items are returned |
878
- |---------|-------------------------|--------------------------|
879
- | absent or \`keywords\` | none | keyword hits, exactly as before, with no new field |
880
- | \`topics\` | keyword hits only | keyword hits that are about a topic, plus hits that could not be checked |
881
- | \`both\` | every authored item | every keyword hit, plus items about a topic that never say the keyword |
882
-
883
- \`keywords\` stays required in every mode. \`topics\` without \`match: "topics"\`/\`"both"\` is a 400 (\`COHORT_TOPICS_REQUIRE_MATCH\`), those modes without \`topics\` are a 400 (\`COHORT_MATCH_REQUIRES_TOPICS\`), and a bad or duplicate topic is \`COHORT_TOPIC_INVALID\`; \`socialcrawl_manage\` checks all three locally first.
884
-
885
- Each item of a topic query carries:
886
-
887
- - \`matched_topics\` — \`[{ id, p }]\`, the topics the item is about at \`p >= 0.7\`, strongest first. \`[]\` = checked and about none; \`null\` = could not be checked (the keyword match stands alone).
888
- - \`mention_type\` — \`first_hand_use_or_purchase\`, \`opinion_or_review\`, \`sponsored_or_promotional\`, \`news_or_share\`, \`incidental\`, \`other\`, or \`uncertain\` when no option clearly won; \`null\` when not checked or no topic matched.
889
-
890
- \`matched_keywords\` can be empty only in \`both\` mode, for an item a topic matched and no keyword did. If a topic check fails or times out, that batch falls back to the keyword match exactly, so coverage, \`window_complete\` and credits are the same as the keyword path. Topic matching is **not billed**: the reservation ceiling and settlement are the keyword query's.
891
-
892
- ## Coverage is the important field
893
-
894
- \`query_results\` returns \`items\` **and** \`coverage\`, one coverage record per member whether or not it matched. This is what stops a partial crawl from reading as "nobody talked about you".
895
-
896
- - \`window_complete: true\` — the route reached your \`date_from\` boundary or the end of the feed. What you got is everything in the window.
897
- - \`window_complete: false\` — the page budget ran out, the account was unreachable, or the route errored. There may be posts you did not see.
898
- - \`oldest_seen\` — the oldest post observed for that member, even when nothing matched: how far back the crawl actually got.
899
- - \`status\` — \`not_found\` for a handle that does not resolve, \`failed\` for an exhausted or erroring account. **A query can be \`succeeded\` while individual members report either.**
900
-
901
- Coverage is paginated exactly like \`items\`, so a 10,000-member panel takes at least 20 pages at \`limit=500\` even when nothing matched, and later pages can carry coverage with an empty \`items\` array. Accumulate both streams until \`next_cursor\` is null. Pages are also bounded to a 1 MB body, so a short page is not necessarily the last one.
902
-
903
- On the single-page platforms (LinkedIn, Bluesky, Threads, Twitch) the source serves one fixed page per identity, so raising \`max_pages_per_identity\` cannot deepen the crawl there — \`window_complete: false\` simply means the window is beyond what the source exposes. Twitter/X does page, so its depth follows the budget.
904
-
905
- ## Credits
906
-
907
- Every lifecycle call is **0 credits**. A query reserves its worst-case ceiling at submission:
908
-
909
- \`\`\`text
910
- ceiling = SUM over members and their routes (credits per page x (route has a cursor ? max_pages_per_identity : 1))
911
- \`\`\`
912
-
913
- | Platform | Credits per successful page |
914
- |----------|------------------------------|
915
- | LinkedIn | 5, one fixed page (the page cap is always 1) |
916
- | Instagram, YouTube | 2 per page-round (two cursor-paged routes per member) |
917
- | Bluesky, Threads, Twitch | 1, one fixed page (the page cap is always 1) |
918
- | Twitter/X, TikTok, Kwai, Truth Social | 1 per page, scales with \`max_pages_per_identity\` |
919
-
920
- Run \`socialcrawl_manage\` with \`area: "cohorts", action: "estimate_cost"\` (plus \`members\` or \`platform_counts\` and your \`max_pages_per_identity\`) to compute that number locally, for free, before you commit.
921
-
922
- You are charged **only for pages that actually succeeded**. Failed, timed-out, cancelled, and skipped pages cost nothing, and when the query reaches a terminal state the unspent reservation is refunded exactly once — \`actual_credits + refunded_credits\` always equals \`reserved_credits\`. \`max_credits\` is your own safety limit, never permission to spend beyond the ceiling: if the computed ceiling exceeds it, submission fails with a 400 before any work is created or any credit is held.
923
-
924
- ## Errors
925
-
926
- | Code | Status | Meaning |
927
- |------|--------|---------|
928
- | \`COHORT_LIMIT_EXCEEDED\` | 400 | The account already holds the maximum of 100 cohorts |
929
- | \`COHORT_MEMBER_LIMIT_EXCEEDED\` | 400 | The upload would push the cohort past 10,000 members |
930
- | \`COHORT_IDENTITY_PLATFORM_UNSUPPORTED\` | 400 | That platform is not supported for cohort queries |
931
- | \`COHORT_IDENTITY_CONFLICT\` | 409 | Another \`external_id\` already claims that identity in this cohort |
932
- | \`COHORT_QUERY_NOT_READY\` | 409 | The query has not succeeded — running, cancelled, and expired queries do not serve results |
933
- | \`COHORT_QUERY_NOT_CANCELLABLE\` | 409 | The query is already terminal |
934
- | \`COHORT_RESULT_TOO_LARGE\` | 413 | A single stored result cannot fit under the 1 MB page ceiling |
935
- | \`COHORT_MAX_CREDITS_BELOW_ESTIMATE\` | 400 | \`max_credits\` is below the computed ceiling; raise it to at least \`estimated_credits\` (nothing is held) |
936
- | \`COHORT_TOPICS_REQUIRE_MATCH\` / \`COHORT_MATCH_REQUIRES_TOPICS\` / \`COHORT_TOPIC_INVALID\` | 400 | Topic matching sent without its partner field, or a bad or duplicate topic (reported in \`error.details.issues\`) |
937
- | \`INSUFFICIENT_CREDITS\` | 402 | The reservation ceiling exceeds your available balance |
938
-
939
- A cohort or query that is not yours returns **404, never 403** — a cross-tenant probe is indistinguishable from a resource that does not exist.
940
-
941
- ## Retention and privacy
942
-
868
+ cohorts: `# SocialCrawl API — Cohorts
869
+
870
+ Cohorts answer a **narrower question than open social listening**: not "who is talking about X?" but "**which of _these specific_ public identities is talking about X?**" You supply the panel — a purchaser list, a customer roster, a creator shortlist — and get bounded, deterministic, metered retrieval over exactly those accounts.
871
+
872
+ Cohorts are **not** registry endpoints. They live at \`/v1/cohorts/*\` and \`/v1/cohort-queries/*\`, mix POST/PUT/GET/DELETE with an async lifecycle, and are driven by \`socialcrawl_manage\` with \`area: "cohorts"\` rather than \`socialcrawl_request\`. Auth is the same \`x-api-key\`.
873
+
874
+ It is **not** audience discovery. It does not find people, infer demographics, or score interests. It takes a list you already have and reports what those public accounts posted.
875
+
876
+ ## What SocialCrawl receives
877
+
878
+ Two things per member, and nothing else:
879
+
880
+ - \`platform\` + \`handle\` — the public identity (the profile URL for LinkedIn).
881
+ - \`external_id\` — your own opaque key, echoed back on every match and every coverage row so you can join results to your own records.
882
+
883
+ Whatever produced the list (receipts, CRM segments, panel attributes) stays on your side; there is no field for it here. Both the identity and your \`external_id\` are encrypted at rest with a per-account key and never appear in logs, job payloads, traces, or error messages. \`get\` returns counts and metadata — it will not read the identities back to you.
884
+
885
+ ## Supported identity platforms
886
+
887
+ \`instagram\` · \`tiktok\` · \`youtube\` · \`twitter\` · \`threads\` · \`bluesky\` · \`truth-social\` · \`kwai\` · \`twitch\` · \`linkedin\`
888
+
889
+ Anything else is rejected at upload (400 \`COHORT_IDENTITY_PLATFORM_UNSUPPORTED\`), so an unsupported identity can never silently cost you a query that returns nothing. \`socialcrawl_manage\` also checks the list locally before it sends.
890
+
891
+ ## The lifecycle
892
+
893
+ | Action | HTTP | Cost |
894
+ |--------|------|------|
895
+ | \`create\` | \`POST /v1/cohorts\` | 0 |
896
+ | \`add_members\` | \`PUT /v1/cohorts/:id/members\` (repeat per 1,000) | 0 |
897
+ | \`estimate_cost\` | *local calculation, no API call* | 0 |
898
+ | \`query\` | \`POST /v1/cohorts/:id/queries\` -> \`202\` | metered |
899
+ | \`query_status\` | \`GET /v1/cohort-queries/:id\` | 0 |
900
+ | \`query_results\` | \`GET /v1/cohort-queries/:id/results\` | 0 |
901
+ | \`query_cancel\` | \`DELETE /v1/cohort-queries/:id\` | 0 |
902
+ | \`get\` / \`delete\` | \`GET\`/\`DELETE /v1/cohorts/:id\` | 0 |
903
+
904
+ Writes (\`create\`, \`add_members\`, \`query\`) require an \`Idempotency-Key\` UUID. The tool generates one when you omit it and echoes it back in the response header — **reuse that key to retry**, or a repeated call creates a second cohort or reserves a second query. Replaying a key with a *different* body returns 422 \`IDEMPOTENCY_KEY_PAYLOAD_MISMATCH\`.
905
+
906
+ **Dry run.** \`dry_run: true\` on \`create\`, \`add_members\` and \`query\` sends \`?dry_run=1\`: the API runs that route's own checks (Idempotency-Key, body schema, the cohort existing) and answers \`{ valid, normalized_params, estimate }\` at 0 credits. Nothing is created, written or reserved, and the Idempotency-Key is not claimed, so the same key can go with the real call. A \`query\` dry run echoes the normalized body and the cohort's \`member_count\`, and caps \`expected_max\` at your \`max_credits\`; the exact ceiling is what \`estimate_cost\` computes.
907
+
908
+ ## Limits
909
+
910
+ | Limit | Value |
911
+ |-------|-------|
912
+ | Cohorts per API key | 100 |
913
+ | Members per cohort | 10,000 |
914
+ | Members per upload call | 1,000 |
915
+ | Keywords per query | 20 |
916
+ | \`max_pages_per_identity\` | 1-20 |
917
+ | \`max_items_per_identity\` | 1-1,000 |
918
+ | \`retention_days\` | 7-90 (default 30) |
919
+ | \`query_results\` \`limit\` | 1-500 (default 100) |
920
+
921
+ Re-sending an \`external_id\` you have already uploaded **updates** its identity rather than adding a row, so a nightly full re-push is safe and does not inflate the count. Two different \`external_id\`s claiming the same normalized identity inside one cohort is 409 \`COHORT_IDENTITY_CONFLICT\` rather than a quiet double count.
922
+
923
+ ## Matching is code, not a model
924
+
925
+ - **Normalization** — keyword and candidate text are both Unicode NFKC, case-folded, whitespace-collapsed.
926
+ - **Whole-word only** — \`acme\` matches "my acme review", never "acmecorp".
927
+ - **CJK caveat** — CJK scripts count as letters, so a Korean/Japanese/Chinese keyword embedded inside surrounding CJK text will not match; pass the surrounding form as its own keyword.
928
+ - **Echoed normalized** — submit "Acme Pro", a match reports \`"acme pro"\`.
929
+ - **Title and description** — on YouTube and Twitch both surfaces are matched, and \`text_excerpt\` carries whichever one hit.
930
+
931
+ No stemming, fuzzy matching, semantic expansion, sentiment scoring, or brand-alias inference. Want "Acme" to also catch "AcmeCo"? Pass both. Only content the source attributes to the identity you supplied is eligible — profile lookups resolve the account and its cursor and never become results.
932
+
933
+ ## Opt-in topic matching (newly added, subject to availability)
934
+
935
+ > **Newly added.** The API contract accepts these fields, but topic matching may not yet be live on every deployment. A keyword-only query (no \`match\`, no \`topics\`) works exactly as described above either way.
936
+
937
+ A query may also send \`topics\` — 1-10 objects of \`{ id, description }\` (\`id\` 1-64 of letters, digits, \`_\`, \`-\`, unique; \`description\` one plain sentence of 1-300 characters) — with \`match\`:
938
+
939
+ | \`match\` | Which items are checked | Which items are returned |
940
+ |---------|-------------------------|--------------------------|
941
+ | absent or \`keywords\` | none | keyword hits, exactly as before, with no new field |
942
+ | \`topics\` | keyword hits only | keyword hits that are about a topic, plus hits that could not be checked |
943
+ | \`both\` | every authored item | every keyword hit, plus items about a topic that never say the keyword |
944
+
945
+ \`keywords\` stays required in every mode. \`topics\` without \`match: "topics"\`/\`"both"\` is a 400 (\`COHORT_TOPICS_REQUIRE_MATCH\`), those modes without \`topics\` are a 400 (\`COHORT_MATCH_REQUIRES_TOPICS\`), and a bad or duplicate topic is \`COHORT_TOPIC_INVALID\`; \`socialcrawl_manage\` checks all three locally first.
946
+
947
+ Each item of a topic query carries:
948
+
949
+ - \`matched_topics\` — \`[{ id, p }]\`, the topics the item is about at \`p >= 0.7\`, strongest first. \`[]\` = checked and about none; \`null\` = could not be checked (the keyword match stands alone).
950
+ - \`mention_type\` — \`first_hand_use_or_purchase\`, \`opinion_or_review\`, \`sponsored_or_promotional\`, \`news_or_share\`, \`incidental\`, \`other\`, or \`uncertain\` when no option clearly won; \`null\` when not checked or no topic matched.
951
+
952
+ \`matched_keywords\` can be empty only in \`both\` mode, for an item a topic matched and no keyword did. If a topic check fails or times out, that batch falls back to the keyword match exactly, so coverage, \`window_complete\` and credits are the same as the keyword path. Topic matching is **not billed**: the reservation ceiling and settlement are the keyword query's.
953
+
954
+ ## Coverage is the important field
955
+
956
+ \`query_results\` returns \`items\` **and** \`coverage\`, one coverage record per member whether or not it matched. This is what stops a partial crawl from reading as "nobody talked about you".
957
+
958
+ - \`window_complete: true\` — the route reached your \`date_from\` boundary or the end of the feed. What you got is everything in the window.
959
+ - \`window_complete: false\` — the page budget ran out, the account was unreachable, or the route errored. There may be posts you did not see.
960
+ - \`oldest_seen\` — the oldest post observed for that member, even when nothing matched: how far back the crawl actually got.
961
+ - \`status\` — \`not_found\` for a handle that does not resolve, \`failed\` for an exhausted or erroring account. **A query can be \`succeeded\` while individual members report either.**
962
+
963
+ Coverage is paginated exactly like \`items\`, so a 10,000-member panel takes at least 20 pages at \`limit=500\` even when nothing matched, and later pages can carry coverage with an empty \`items\` array. Accumulate both streams until \`next_cursor\` is null. Pages are also bounded to a 1 MB body, so a short page is not necessarily the last one.
964
+
965
+ On the single-page platforms (LinkedIn, Bluesky, Threads, Twitch) the source serves one fixed page per identity, so raising \`max_pages_per_identity\` cannot deepen the crawl there — \`window_complete: false\` simply means the window is beyond what the source exposes. Twitter/X does page, so its depth follows the budget.
966
+
967
+ ## Credits
968
+
969
+ Every lifecycle call is **0 credits**. A query reserves its worst-case ceiling at submission:
970
+
971
+ \`\`\`text
972
+ ceiling = SUM over members and their routes (credits per page x (route has a cursor ? max_pages_per_identity : 1))
973
+ \`\`\`
974
+
975
+ | Platform | Credits per successful page |
976
+ |----------|------------------------------|
977
+ | LinkedIn | 5, one fixed page (the page cap is always 1) |
978
+ | Instagram, YouTube | 2 per page-round (two cursor-paged routes per member) |
979
+ | Bluesky, Threads, Twitch | 1, one fixed page (the page cap is always 1) |
980
+ | Twitter/X, TikTok, Kwai, Truth Social | 1 per page, scales with \`max_pages_per_identity\` |
981
+
982
+ Run \`socialcrawl_manage\` with \`area: "cohorts", action: "estimate_cost"\` (plus \`members\` or \`platform_counts\` and your \`max_pages_per_identity\`) to compute that number locally, for free, before you commit.
983
+
984
+ You are charged **only for pages that actually succeeded**. Failed, timed-out, cancelled, and skipped pages cost nothing, and when the query reaches a terminal state the unspent reservation is refunded exactly once — \`actual_credits + refunded_credits\` always equals \`reserved_credits\`. \`max_credits\` is your own safety limit, never permission to spend beyond the ceiling: if the computed ceiling exceeds it, submission fails with a 400 before any work is created or any credit is held.
985
+
986
+ ## Errors
987
+
988
+ | Code | Status | Meaning |
989
+ |------|--------|---------|
990
+ | \`COHORT_LIMIT_EXCEEDED\` | 400 | The account already holds the maximum of 100 cohorts |
991
+ | \`COHORT_MEMBER_LIMIT_EXCEEDED\` | 400 | The upload would push the cohort past 10,000 members |
992
+ | \`COHORT_IDENTITY_PLATFORM_UNSUPPORTED\` | 400 | That platform is not supported for cohort queries |
993
+ | \`COHORT_IDENTITY_CONFLICT\` | 409 | Another \`external_id\` already claims that identity in this cohort |
994
+ | \`COHORT_QUERY_NOT_READY\` | 409 | The query has not succeeded — running, cancelled, and expired queries do not serve results |
995
+ | \`COHORT_QUERY_NOT_CANCELLABLE\` | 409 | The query is already terminal |
996
+ | \`COHORT_RESULT_TOO_LARGE\` | 413 | A single stored result cannot fit under the 1 MB page ceiling |
997
+ | \`COHORT_MAX_CREDITS_BELOW_ESTIMATE\` | 400 | \`max_credits\` is below the computed ceiling; raise it to at least \`estimated_credits\` (nothing is held) |
998
+ | \`COHORT_TOPICS_REQUIRE_MATCH\` / \`COHORT_MATCH_REQUIRES_TOPICS\` / \`COHORT_TOPIC_INVALID\` | 400 | Topic matching sent without its partner field, or a bad or duplicate topic (reported in \`error.details.issues\`) |
999
+ | \`INSUFFICIENT_CREDITS\` | 402 | The reservation ceiling exceeds your available balance |
1000
+
1001
+ A cohort or query that is not yours returns **404, never 403** — a cross-tenant probe is indistinguishable from a resource that does not exist.
1002
+
1003
+ ## Retention and privacy
1004
+
943
1005
  Membership is purged after \`retention_days\` (7-90, default 30), and results are purged with their parent cohort. Only matched content and coverage are stored — never the unmatched feeds the workers paged through. \`DELETE\` on a cohort cascades its members, queries, and results and cancels anything still in flight; your credit-ledger receipts survive, because billing history outlives the data.`,
944
1006
  };
945
1007
  //# sourceMappingURL=docs-handwritten.js.map