socialcrawl-mcp 2.7.0 → 2.7.1

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.
package/dist/client.js CHANGED
@@ -237,6 +237,11 @@ export function formatHttpError(status, body, options, headerRequestId, retryAft
237
237
  const suggestion = nonEmptyString(parsed?.error?.details?.did_you_mean);
238
238
  if (suggestion)
239
239
  lines.push(`did_you_mean: ${suggestion}`);
240
+ // A team member's 402 has no top-up link; its next step (ask the owner, or
241
+ // leave the team) is the whole remedy, so it travels with the error.
242
+ const nextStep = isTeamRefusal(status, parsed) ? nonEmptyString(parsed?.error?.details?.next_step) : undefined;
243
+ if (nextStep)
244
+ lines.push(`next_step: ${nextStep}`);
240
245
  if (requestId)
241
246
  lines.push(`request_id: ${requestId}`);
242
247
  // Machine-readable tail: the structured error result reads these lines.
@@ -247,6 +252,10 @@ export function formatHttpError(status, body, options, headerRequestId, retryAft
247
252
  lines.push(`error_code: ${parsed.error.type}`);
248
253
  return lines.join("\n");
249
254
  }
255
+ /** A 402 refused because the team that pays for this member is out of credits (API-480). */
256
+ function isTeamRefusal(status, parsed) {
257
+ return status === 402 && parsed?.error?.details?.billing?.source === "team";
258
+ }
250
259
  function nonEmptyString(value) {
251
260
  return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
252
261
  }
@@ -270,6 +279,11 @@ function describeHttpError(status, body, parsed, options) {
270
279
  if (errorType === "KEY_BUDGET_EXCEEDED") {
271
280
  return `Error: ${serverMessage ?? "This API key has spent its per-key credit limit. Raise the key's limit in the dashboard; topping up will not clear it."}`;
272
281
  }
282
+ // A team member buys no credits: the server's message names who adds
283
+ // them, and pointing at billing would send them to a page they cannot use.
284
+ if (isTeamRefusal(status, parsed)) {
285
+ return `Error: ${serverMessage ?? "The team balance is too low for this request. Ask the team's owner to add credits."}`;
286
+ }
273
287
  return `Error: Insufficient credits (${parsed?.credits_remaining ?? 0} remaining). ${said}Top up at socialcrawl.dev/dashboard/billing.`;
274
288
  case 400:
275
289
  return `Error: ${errorMessage}`;
@@ -9,7 +9,7 @@ export declare const TIMEOUT_MS = 60000;
9
9
  export declare const INLINE_MAX_ROWS = 200;
10
10
  export declare const INLINE_MAX_BYTES = 60000;
11
11
  export declare const SERVER_NAME = "socialcrawl-mcp";
12
- export declare const SERVER_VERSION = "2.7.0";
12
+ export declare const SERVER_VERSION = "2.7.1";
13
13
  /**
14
14
  * Inside a normalised `socialcrawl_request` params object: the names of the
15
15
  * endpoint params that arrived as top-level arguments and were moved into
package/dist/constants.js CHANGED
@@ -13,7 +13,7 @@ export const INLINE_MAX_BYTES = 60_000;
13
13
  // (CREDIT_LADDER) alongside the cache TTLs, so a ladder change cannot leave a
14
14
  // stale copy behind. Import it from there.
15
15
  export const SERVER_NAME = "socialcrawl-mcp";
16
- export const SERVER_VERSION = "2.7.0";
16
+ export const SERVER_VERSION = "2.7.1";
17
17
  /**
18
18
  * Inside a normalised `socialcrawl_request` params object: the names of the
19
19
  * endpoint params that arrived as top-level arguments and were moved into
@@ -6,7 +6,7 @@
6
6
  * {routes,resume,more,schedule-routes}.ts, platforms/review-history/
7
7
  * {http,engine}.ts, events/{feed,routes}.ts, webhooks/{http,limits}.ts.
8
8
  */
9
- export declare const DISCOVER_RUNS_DOC = "# SocialCrawl API \u2014 Discover runs, schedules and review history\n\nWork that keeps running after the call that started it. Start it with `socialcrawl_request`; read, export, steer and stop it with `socialcrawl_manage` (areas `discover` and `review_history`). Every read here is free; only the searches a run goes on to make are billed.\n\n## Discover runs (`/v1/prism/discover/runs`)\n\nStart a run with `socialcrawl_request` on `prism/discover` (`max_credits` is required; `async` runs it in the background). A background start answers 202 with `data.run` (`eta_s` with `eta_basis`), `data.next`, `credits_remaining` and, with `notify_url`, `data.notify` (its signing secret). Manage it with `socialcrawl_manage` `area: \"discover\"`; `id` is the run id (`run_\u2026`, `data.run.run_id`). Runs created since 14/11/2026 are kept 30 days by default (was 7); `retention_days` is 1 to 30.\n\n| Action | Route | Cost |\n|--------|-------|------|\n| `run_list` | `GET /runs` (status, kind, created_after, cursor, page_size \u2264100; `id` = a schedule id lists that schedule's runs) | 0 |\n| `run_get` | `GET /runs/{run_id}` | 0 |\n| `run_status` | `GET /runs/{run_id}/status` (`wait_s` only) | 0 |\n| `run_export` | `GET /runs/{run_id}/results.jsonl` | 0 |\n| `run_results_csv` / `run_comments_csv` | `GET /runs/{run_id}/results.csv` / `comments.csv` | 0 |\n| `run_legs` | `GET /runs/{run_id}/legs` (page_size \u2264500) | 0 |\n| `run_cancel` | `DELETE /runs/{run_id}` | 0 \u2014 rows kept, resume continues |\n| `run_resume` | `POST /runs/{run_id}/resume` `{ max_credits?, retry_failed? }` or `{ attach_stored_only: true }` | 0 itself; continued searches bill as they run |\n| `run_more` | `POST /runs/{run_id}/more` `{ new_searches?, feedback?, max_credits?, pages? }` | each new search bills at its lane price |\n| `run_comments` | `POST /runs/{run_id}/comments` `{ top_posts?, per_post?, platforms?, labels?, max_credits? }` | comment pages bill at their lane prices; `dry_run` quotes free |\n\n- **Poll `run_status`** (`GET /runs/{run_id}/status`, `wait_s` 0-25): `run`, `next` and `_warnings` only, about 2 KB where `run_get` is about 100 KB. Every run answer carries `next.poll_url` pointing at it (`status_url` unchanged). `run.progress` names its stages: `progress.stages` (states from the work left: `reading_comments`, `waiting`, `stopped`, `done`) and `progress.current_stage`, with `rows_collected`, `rows_judging`, `rows_held` and `note`; a background run fills `eta_s` with `eta_basis` (`estimate` or `measured`) and `credits_remaining`. `summary.comments` adds `posts_selected`, `posts_walked`, `posts_attached`, `stored_unattached_pages` and `count_bases`.\n- **Long-poll:** `run_get` and `run_status` with `wait_s` (0-25) answer early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key; a sixth answers at once.\n- **notify_url** on the `prism/discover` POST (https, public host): one signed POST `discover.run_settled` (`run_id`, `status`, `stopped_because`, `credits_spent`, the run, poll and results URLs) when the run completes, is partial, pauses, fails or is cancelled. It is signed like webhook deliveries (`x-socialcrawl-signature`) with `data.notify.secret` from the POST answer.\n- **Filters** (run_get and the exports): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and `tags` sent as `tag.<key>=<value>`. `format` (evidence | compact | text) and `fields` override the run's own for this read. On `run_get` only: `summary` (full | kept | none) and `summary_extra=by_week,top_terms` (kept rows per week with the stance split and mean sentiment; top hashtags and words per group). Any parameter the route does not take is a free 400 naming the next step. A cursor is signed with the filters it was issued for: send the SAME filters with it.\n- **run_export** streams every matching row; every line carries `kind` (`post`, `account`, `warning`, `removed`, `trailer`), and the last is the trailer: `{\"kind\":\"trailer\",\"complete\":true}` or `{\"kind\":\"trailer\",\"next_cursor\":\"\u2026\"}` (stopped after about 45 s; send it back with the same filters). A settled run's arrival-order export fills `engagement.percentile`.\n- **CSV:** `results.csv` is one line per kept post row (fixed columns, then one `question.<id>` column per question); `comments.csv` one line per comment, keyed by `post_id`. RFC 4180, UTF-8 with a BOM, formula-like cells guarded, the same filters and cursor as `results.jsonl`. A run that is not posts is a free 400 `csv_posts_only`.\n- **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER `max_credits`. Searches already paid for are never paid twice. `{ attach_stored_only: true }` (alone) attaches comment pages the run stored but no row shows, bills 0 and keeps the status (`data.attached`); a stopped run's `next_step` names those pages and any unsent `include=interest` calls.\n- **run_more** works on completed runs only: `pages` 1-10, `feedback.accept`/`feedback.reject` up to 100 ids each (`accept` needs `new_searches: true`). Read only the new rows with `changes_since` = `data.more.since_version`. `data.more.nothing_more` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.\n- **run_comments** (`POST /runs/{run_id}/comments`) reads comments for an existing posts run: `top_posts` 1-50 and `per_post` 1-200 (default the run's own, else 3 and 20), `platforms`, `labels` (up to 10), `max_credits` (default the quote's max). `dry_run` answers the quote free. Pages an earlier pass stored replay free. Refused free while the run runs (409 `run_running`) or owes other work (409 `run_has_unsent_work`: resume it first). The answer is 202: poll `run_status`.\n- **Background runs** write comments to each post as it is read and read up to 4 slices of 5 posts at once; `include=interest` calls run once searches end. A run started with `x-client-tag` tags every background charge, so `credits/usage?group_by=tag` equals the run's spend.\n- **Rows** carry `language_source` (`detected`, `platform`, `requested`), `author.display_name` and `author.url` (`username` null when only a name is known), `judgments.stance.best` and `scores` beside `label`, and `geo.country.known`. A windowed run with Naver cafe or web documents warns how many kept rows have no date.\n- **Caps:** a dry run and a `max_credits_below_estimate` refusal carry `recommended_max_credits` (expected cost x 2, between the minimum and `suggested_max_credits`), and `next_step` leads with it; `plan=omit` leaves `plan` out of the answer.\n- **No dry_run** on any other run or schedule route (resume and more refuse any query parameter).\n- **Errors:** 404 RUN_NOT_FOUND (not your run), 409 RUN_STATE_CONFLICT, 410 RUN_EXPIRED (retention passed), 503 store_unavailable (retryable, nothing charged).\n\n## Discover schedules (`/v1/prism/discover/schedules`)\n\nCreated by `prism/discover` with a `schedule` field. All free; each scheduled run bills like a run within `max_credits_per_run` and `max_credits_per_month`. `id` is the schedule id (`dsch_\u2026`).\n\n`schedule_list` (status active | paused | stopped, cursor, page_size \u2264100), `schedule_get` (its recent runs, this month's spend, next fire), `schedule_pause`, `schedule_resume` (`{ max_credits_per_run?, max_credits_per_month? }`, null clears the month cap), `schedule_delete` (runs keep their rows). `run_list` with the schedule id lists one schedule's runs.\n\n## Stored lists (`/v1/prism/discover/inputs`)\n\nMake one with `socialcrawl_request` on `POST prism/discover/inputs` (`{ kind: \"authors\", authors: [...] }` up to 10,000 handles, or `{ kind: \"exclude\", exclude: [...] }` up to 50,000 entries); the answer's `author_list_id` / `exclude_list_id` (`din_\u2026`) goes into a discover call. Then, free: `input_list` (every live list with `item_count` and `expires_at`, plus `live` of `limit` 500 per account), `input_append` (`id` + `{ exclude: [...] }`, 1 to 50,000 entries; duplicates skipped, the expiry moves to 31 days; past 50,000 in all it is a free 400 `exclude_list_full`), `input_delete`. An unknown, expired or foreign id, or an author list sent to append, is a 404 `input_not_found`. Lists live 30 days.\n\n## Review history (`/v1/{platform}/reviews/history/{job_id}`)\n\nStart a job with `socialcrawl_request` on the POST for the platform \u2014 it holds the price and answers 202 with `job_id` (`job_\u2026`):\n\n| Start (POST) | Poll with `platform` | Price |\n|---|---|---|\n| `trustpilot/reviews/history` | `trustpilot` (default) | holds `depth` + 5 |\n| `tripadvisor/reviews/history` | `tripadvisor` | holds `depth` |\n| `google/business/reviews/history` (exactly one of `place_id` or `cid`, `depth` 1-10,000) | `google` | 5 per started 100 reviews collected; none collected is refunded in full |\n| `yelp/business/reviews/history` | `yelp` | 1 per started 4 pages (held at 52 a language; `languages=all` holds 154); honours `Idempotency-Key` |\n\nPoll with `socialcrawl_manage` `area: \"review_history\"`, `action: \"get\"`, `id` = the job id, free. Trustpilot, Tripadvisor and Google: status queued \u2192 running \u2192 polling \u2192 succeeded | failed; once settled each page carries `data.items` and `data.job` (`credits_hold`, the settled `credits_charged`, `expires_at`); page with `offset` and `limit` (1-100) until a page is shorter than `limit`. Yelp: rows are readable while the job runs, each page carries `data.job` (`pages_read`, `reviews_collected`, per-language progress), `total` and `next_offset` (null on the last page). Jobs live 7 days.\n\n## Bulk review history (`POST /v1/prism/reviews/bulk`)\n\nOne background job over up to 20,000 businesses, places or apps: `platform` (`yelp`, `google_maps`, `tripadvisor`, `app_store`, `google_play`), `items` (for `google_maps`: place_ids from `google/business/search`, cids or Google Maps place links), optional `since` / `until`, `languages` (not Tripadvisor or App Store; on Google Maps one code, the language the text is returned in), `max_reviews_per_item`, `format` (`jsonl` | `csv`), `include` (`business`, `business_full` on Yelp, `none`), `country` (App Store, Google Play), `webhook_url` (https; the 202 shows its `webhook_secret` once) and `refresh_of` (an earlier job of this key: reuses its items and starts from the day it settled). Start it with `socialcrawl_request`. It bills 1 credit per started 4 pages over the whole job, reserved 25 credits at a time; a business that cannot be read costs nothing. When the next block cannot be held the job pauses as `paused_insufficient_credits` and resumes after a top-up (webhook events `reviews_bulk.paused`, `resumed`, `completed`, signed `x-socialcrawl-signature`). `Idempotency-Key` replays the job at 0 credits.\n\nThen, free: `action: \"bulk_get\"` (progress, each item's `status` pending | walking | waiting | done | unavailable, and signed links to the combined file, the manifest and each item's file, valid 1 hour; page items with `offset`/`limit`) and `action: \"bulk_cancel\"` (keeps and bills what was read; the job can still read `running` until it settles as `cancelled`). There is no list route: keep the job id.\n\n## follow\n\nAnswers carry ready next-step URLs in `data.next.*`. `socialcrawl_manage` `area: \"discover\"`, `action: \"follow\"`, `input: { url }` GETs one only when it is on the configured SocialCrawl API AND one of the free read routes above (batch jobs, discover runs and schedules, review history, the events feed, webhook endpoints). `status_url`, `results_url`, `changes_url` and `poll_url` are free reads. `continue_url` STARTS a billable continuation and is never followed (call `socialcrawl_request` after checking `continue_estimate`); `resume_url`/`more_url` are POSTs: use `run_resume`/`run_more`.\n";
9
+ export declare const DISCOVER_RUNS_DOC = "# SocialCrawl API \u2014 Discover runs, schedules and review history\n\nWork that keeps running after the call that started it. Start it with `socialcrawl_request`; read, export, steer and stop it with `socialcrawl_manage` (areas `discover` and `review_history`). Every read here is free; only the searches a run goes on to make are billed.\n\n## Discover runs (`/v1/prism/discover/runs`)\n\nStart a run with `socialcrawl_request` on `prism/discover` (`max_credits` is required; `async` runs it in the background). A background start answers 202 with `data.run` (`eta_s` with `eta_basis`), `data.next`, `credits_remaining` and, with `notify_url`, `data.notify` (its signing secret). Manage it with `socialcrawl_manage` `area: \"discover\"`; `id` is the run id (`run_\u2026`, `data.run.run_id`). Runs created since 14/11/2026 are kept 30 days by default (was 7); `retention_days` is 1 to 30.\n\n| Action | Route | Cost |\n|--------|-------|------|\n| `run_list` | `GET /runs` (status, kind, created_after, cursor, page_size \u2264100; `id` = a schedule id lists that schedule's runs) | 0 |\n| `run_get` | `GET /runs/{run_id}` | 0 |\n| `run_status` | `GET /runs/{run_id}/status` (`wait_s` only) | 0 |\n| `run_export` | `GET /runs/{run_id}/results.jsonl` | 0 |\n| `run_results_csv` / `run_comments_csv` | `GET /runs/{run_id}/results.csv` / `comments.csv` | 0 |\n| `run_legs` | `GET /runs/{run_id}/legs` (page_size \u2264500) | 0 |\n| `run_cancel` | `DELETE /runs/{run_id}` | 0 \u2014 rows kept, resume continues |\n| `run_resume` | `POST /runs/{run_id}/resume` `{ max_credits?, retry_failed? }` or `{ attach_stored_only: true }` | 0 itself; continued searches bill as they run |\n| `run_more` | `POST /runs/{run_id}/more` `{ new_searches?, feedback?, max_credits?, pages? }` | each new search bills at its lane price |\n| `run_comments` | `POST /runs/{run_id}/comments` `{ top_posts?, per_post?, platforms?, labels?, max_credits? }` | comment pages bill at their lane prices; `dry_run` quotes free |\n\n- **Poll `run_status`** (`GET /runs/{run_id}/status`, `wait_s` 0-25): `run`, `next` and `_warnings` only, about 2 KB where `run_get` is about 100 KB. Every run answer carries `next.poll_url` pointing at it (`status_url` unchanged). `run.progress` names its stages: `progress.stages` (states from the work left: `reading_comments`, `waiting`, `stopped`, `done`) and `progress.current_stage`, with `rows_collected`, `rows_judging`, `rows_held` and `note`; a background run fills `eta_s` with `eta_basis` (`estimate` or `measured`) and `credits_remaining`. `summary.comments` adds `posts_selected`, `posts_walked`, `posts_attached`, `stored_unattached_pages` and `count_bases`.\n- **Long-poll:** `run_get` and `run_status` with `wait_s` (0-25) answer early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key; a sixth answers at once.\n- **notify_url** on the `prism/discover` POST (https, public host): one signed POST `discover.run_settled` (`run_id`, `status`, `stopped_because`, `credits_spent`, the run, poll and results URLs) when the run completes, is partial, pauses, fails or is cancelled. It is signed like webhook deliveries (`x-socialcrawl-signature`) with `data.notify.secret` from the POST answer.\n- **Filters** (run_get and the exports): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and `tags` sent as `tag.<key>=<value>`. `format` (evidence | compact | text) and `fields` override the run's own for this read. On `run_get` only: `summary` (full | kept | none) and `summary_extra=by_week,top_terms` (kept rows per week with the stance split and mean sentiment; top hashtags and words per group). Any parameter the route does not take is a free 400 naming the next step. A cursor is signed with the filters it was issued for: send the SAME filters with it.\n- **run_export** streams every matching row; every line carries `kind` (`post`, `account`, `warning`, `removed`, `trailer`), and the last is the trailer: `{\"kind\":\"trailer\",\"complete\":true}` or `{\"kind\":\"trailer\",\"next_cursor\":\"\u2026\"}` (stopped after about 45 s; send it back with the same filters). A settled run's arrival-order export fills `engagement.percentile`.\n- **CSV:** `results.csv` is one line per kept post row (fixed columns, then one `question.<id>` column per question); `comments.csv` one line per comment, keyed by `post_id`. RFC 4180, UTF-8 with a BOM, formula-like cells guarded, the same filters and cursor as `results.jsonl`. A run that is not posts is a free 400 `csv_posts_only`.\n- **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER `max_credits`. Searches already paid for are never paid twice. `{ attach_stored_only: true }` (alone) attaches comment pages the run stored but no row shows, bills 0 and keeps the status (`data.attached`); a stopped run's `next_step` names those pages and any unsent `include=interest` calls. A page whose stored rows have expired is counted in `data.attached.posts_expired` and left as it was, never written as a post with no comments; a plain resume reads it again.\n- **run_more** works on completed runs only: `pages` 1-10, `feedback.accept`/`feedback.reject` up to 100 ids each (`accept` needs `new_searches: true`). Read only the new rows with `changes_since` = `data.more.since_version`. `data.more.nothing_more` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.\n- **run_comments** (`POST /runs/{run_id}/comments`) reads comments for an existing posts run: `top_posts` 1-50 and `per_post` 1-200 (default the run's own, else 3 and 20), `platforms`, `labels` (up to 10), `max_credits` (default the quote's max). `dry_run` answers the quote free. Pages an earlier pass stored replay free. Refused free while the run runs (409 `run_running`) or owes other work (409 `run_has_unsent_work`: resume it first). The answer is 202: poll `run_status`.\n- **Background runs** write comments to each post as it is read and read up to 4 slices of 5 posts at once; `include=interest` calls run once searches end. A run started with `x-client-tag` tags every background charge, so `credits/usage?group_by=tag` equals the run's spend.\n- **Rows** carry `language_source` (`detected`, `platform`, `requested`), `author.display_name` and `author.url` (`username` null when only a name is known), `judgments.stance.best` and `scores` beside `label`, and `geo.country.known`. A windowed run with Naver cafe or web documents warns how many kept rows have no date.\n- **Caps:** a dry run and a `max_credits_below_estimate` refusal carry `recommended_max_credits` (expected cost x 2, between the minimum and `suggested_max_credits`), and `next_step` leads with it; `plan=omit` leaves `plan` out of the answer.\n- **No dry_run** on any other run or schedule route (resume and more refuse any query parameter).\n- **Errors:** 404 RUN_NOT_FOUND (not your run), 409 RUN_STATE_CONFLICT, 410 RUN_EXPIRED (retention passed), 503 store_unavailable (retryable, nothing charged).\n\n## Discover schedules (`/v1/prism/discover/schedules`)\n\nCreated by `prism/discover` with a `schedule` field. All free; each scheduled run bills like a run within `max_credits_per_run` and `max_credits_per_month`. `id` is the schedule id (`dsch_\u2026`).\n\n`schedule_list` (status active | paused | stopped, cursor, page_size \u2264100), `schedule_get` (its recent runs, this month's spend, next fire), `schedule_pause`, `schedule_resume` (`{ max_credits_per_run?, max_credits_per_month? }`, null clears the month cap), `schedule_delete` (runs keep their rows). `run_list` with the schedule id lists one schedule's runs.\n\n## Stored lists (`/v1/prism/discover/inputs`)\n\nMake one with `socialcrawl_request` on `POST prism/discover/inputs` (`{ kind: \"authors\", authors: [...] }` up to 10,000 handles, or `{ kind: \"exclude\", exclude: [...] }` up to 50,000 entries); the answer's `author_list_id` / `exclude_list_id` (`din_\u2026`) goes into a discover call. Then, free: `input_list` (every live list with `item_count` and `expires_at`, plus `live` of `limit` 500 per account), `input_append` (`id` + `{ exclude: [...] }`, 1 to 50,000 entries; duplicates skipped, the expiry moves to 31 days; past 50,000 in all it is a free 400 `exclude_list_full`), `input_delete`. An unknown, expired or foreign id, or an author list sent to append, is a 404 `input_not_found`. Lists live 30 days.\n\n## Review history (`/v1/{platform}/reviews/history/{job_id}`)\n\nStart a job with `socialcrawl_request` on the POST for the platform \u2014 it holds the price and answers 202 with `job_id` (`job_\u2026`):\n\n| Start (POST) | Poll with `platform` | Price |\n|---|---|---|\n| `trustpilot/reviews/history` | `trustpilot` (default) | holds `depth` + 5 |\n| `tripadvisor/reviews/history` | `tripadvisor` | holds `depth` |\n| `google/business/reviews/history` (exactly one of `place_id` or `cid`, `depth` 1-10,000) | `google` | 5 per started 100 reviews collected; none collected is refunded in full |\n| `yelp/business/reviews/history` | `yelp` | 1 per started 4 pages (held at 52 a language; `languages=all` holds 154); honours `Idempotency-Key` |\n\nPoll with `socialcrawl_manage` `area: \"review_history\"`, `action: \"get\"`, `id` = the job id, free. Trustpilot, Tripadvisor and Google: status queued \u2192 running \u2192 polling \u2192 succeeded | failed; once settled each page carries `data.items` and `data.job` (`credits_hold`, the settled `credits_charged`, `expires_at`); page with `offset` and `limit` (1-100) until a page is shorter than `limit`. Yelp: rows are readable while the job runs, each page carries `data.job` (`pages_read`, `reviews_collected`, per-language progress), `total` and `next_offset` (null on the last page). Jobs live 7 days.\n\n## Bulk review history (`POST /v1/prism/reviews/bulk`)\n\nOne background job over up to 20,000 businesses, places or apps: `platform` (`yelp`, `google_maps`, `tripadvisor`, `app_store`, `google_play`), `items` (for `google_maps`: place_ids from `google/business/search`, cids or Google Maps place links), optional `since` / `until`, `languages` (not Tripadvisor or App Store; on Google Maps one code, the language the text is returned in), `max_reviews_per_item`, `format` (`jsonl` | `csv`), `include` (`business`, `business_full` on Yelp, `none`), `country` (App Store, Google Play), `webhook_url` (https; the 202 shows its `webhook_secret` once) and `refresh_of` (an earlier job of this key: reuses its items and starts from the day it settled). Start it with `socialcrawl_request`. It bills 1 credit per started 4 pages over the whole job, reserved 25 credits at a time; a business that cannot be read costs nothing. When the next block cannot be held the job pauses as `paused_insufficient_credits` and resumes after a top-up (webhook events `reviews_bulk.paused`, `resumed`, `completed`, signed `x-socialcrawl-signature`). `Idempotency-Key` replays the job at 0 credits.\n\nThen, free: `action: \"bulk_get\"` (progress, each item's `status` pending | walking | waiting | done | unavailable, and signed links to the combined file, the manifest and each item's file, valid 1 hour; page items with `offset`/`limit`) and `action: \"bulk_cancel\"` (keeps and bills what was read; the job can still read `running` until it settles as `cancelled`). There is no list route: keep the job id.\n\n## follow\n\nAnswers carry ready next-step URLs in `data.next.*`. `socialcrawl_manage` `area: \"discover\"`, `action: \"follow\"`, `input: { url }` GETs one only when it is on the configured SocialCrawl API AND one of the free read routes above (batch jobs, discover runs and schedules, review history, the events feed, webhook endpoints). `status_url`, `results_url`, `changes_url` and `poll_url` are free reads. `continue_url` STARTS a billable continuation and is never followed (call `socialcrawl_request` after checking `continue_estimate`); `resume_url`/`more_url` are POSTs: use `run_resume`/`run_more`.\n";
10
10
  export declare const EVENTS_DOC = "# SocialCrawl API \u2014 Account events feed and webhook endpoints\n\nThe account event log records what happens to this key's background work: discover runs (`discover.completed`, `discover.partial`, `discover.paused`, `discover.failed`, `discover.progress`, `discover.accounts_ready`, `discover.new_rows`, `discover.new_accounts`, `discover.new_items`), schedules (`discover.run_skipped`, `discover.run_failed`) and webhook endpoint health (`endpoint.disabled`). Pull it with the feed or have it pushed to a webhook endpoint. Use `socialcrawl_manage` `area: \"events\"`. Everything here costs **0 credits**, and no route here takes `dry_run`.\n\n## Feed (`GET /v1/events`)\n\n- **Your own cursor:** `cursor` = `oldest` (start of the 30-day retention), `now` (only new events), an event id (`evt_\u2026`) or `pagination.next_cursor` exactly as returned. Save `next_cursor` after each page.\n- **Named consumer:** `id` = a consumer name (a-z, 0-9, _ and -, up to 64). The server keeps its position; `start` (now | oldest) sets where a new consumer begins; its `types`/`subject_ids` filters bind at first use. A read commits nothing: process the page, then `ack` its `pagination.next_cursor` (`POST /v1/events/consumers/{name}/ack`, same `id`, `input: { cursor }`). Until you ack, the read returns the same page.\n- Not both `cursor` and a consumer (a free 400).\n- **Filters:** `types` (up to 50 types or patterns: `discover.completed`, `discover.*`, `*`) and `subject_ids` (up to 100 run_\u2026 or dsch_\u2026 ids). `limit` 1-500 (default 100).\n- **Long-poll:** `wait_s` (0-25) holds an empty read until an event arrives. At most 5 long-polls per key; a sixth answers at once.\n- **410 CURSOR_EXPIRED:** the position is older than the 30-day retention, so events were missed. Restart from `oldest` (a consumer restarts there on its next read and says `restarted_from` once) and tell the user which window was missed.\n- `data.next.poll_url` is a free read: `area: \"discover\"` action `follow` can GET it.\n\n## Webhook endpoints (`/v1/webhook-endpoints`)\n\nAt most **20 per API key**; an endpoint answers only to the key that created it. `id` is the endpoint id (`we_\u2026`, `data.endpoint.id`).\n\n| Action | Route |\n|--------|-------|\n| `endpoint_create` | `POST /` `{ url, types?, description?, subject_ids? }` (201) |\n| `endpoint_list` | `GET /` (limit \u2264100, cursor, status) |\n| `endpoint_get` | `GET /{id}` |\n| `endpoint_update` | `PATCH /{id}` (url, types, description, subject_ids, status enabled/disabled) |\n| `endpoint_delete` | `DELETE /{id}` |\n| `endpoint_rotate_secret` | `POST /{id}/rotate-secret` |\n| `endpoint_test` | `POST /{id}/test` `{ type? }` |\n| `endpoint_attempts` | `GET /{id}/attempts` (limit \u2264100, cursor) |\n\n- **The secret is shown ONCE.** `endpoint_create` and `endpoint_rotate_secret` return a `whsec_` secret in `data.secret`; store it immediately. Both send an Idempotency-Key (generated when you omit it, and echoed): a replay never creates a second endpoint and never shows the secret again. If it is lost, rotate with a NEW key.\n- **Rotation:** for 24 hours every delivery is signed with both the old and the new secret, so deploy the new one before then.\n- **URL rules:** a public HTTPS receiver. Private hosts and chat-app incoming webhooks are refused (400 invalid_webhook_url).\n- **Types** default to `[\"*\"]`. `endpoint_test` sends one signed sample of a subscribed type; the receiver has 15 s to answer 2xx. Answering 410 to a real delivery disables the endpoint.\n- **Retries:** a failing delivery gets 8 attempts in all, backing off over roughly 41 hours; `endpoint_attempts` shows the log. Setting `status: \"enabled\"` on a disabled endpoint resumes its parked deliveries at once.\n- **Links are full URLs.** An event's `links` (`run`, `results`, `changes`) start with the API's https origin; pass any of them to action `follow` (areas `discover`, `search_runs`, `creator_runs`).\n";
11
11
  /**
12
12
  * Universal search runs, lists and watches (UPGRADE-LOG API-073, API-077,
@@ -33,7 +33,7 @@ Start a run with \`socialcrawl_request\` on \`prism/discover\` (\`max_credits\`
33
33
  - **Filters** (run_get and the exports): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and \`tags\` sent as \`tag.<key>=<value>\`. \`format\` (evidence | compact | text) and \`fields\` override the run's own for this read. On \`run_get\` only: \`summary\` (full | kept | none) and \`summary_extra=by_week,top_terms\` (kept rows per week with the stance split and mean sentiment; top hashtags and words per group). Any parameter the route does not take is a free 400 naming the next step. A cursor is signed with the filters it was issued for: send the SAME filters with it.
34
34
  - **run_export** streams every matching row; every line carries \`kind\` (\`post\`, \`account\`, \`warning\`, \`removed\`, \`trailer\`), and the last is the trailer: \`{"kind":"trailer","complete":true}\` or \`{"kind":"trailer","next_cursor":"…"}\` (stopped after about 45 s; send it back with the same filters). A settled run's arrival-order export fills \`engagement.percentile\`.
35
35
  - **CSV:** \`results.csv\` is one line per kept post row (fixed columns, then one \`question.<id>\` column per question); \`comments.csv\` one line per comment, keyed by \`post_id\`. RFC 4180, UTF-8 with a BOM, formula-like cells guarded, the same filters and cursor as \`results.jsonl\`. A run that is not posts is a free 400 \`csv_posts_only\`.
36
- - **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER \`max_credits\`. Searches already paid for are never paid twice. \`{ attach_stored_only: true }\` (alone) attaches comment pages the run stored but no row shows, bills 0 and keeps the status (\`data.attached\`); a stopped run's \`next_step\` names those pages and any unsent \`include=interest\` calls.
36
+ - **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER \`max_credits\`. Searches already paid for are never paid twice. \`{ attach_stored_only: true }\` (alone) attaches comment pages the run stored but no row shows, bills 0 and keeps the status (\`data.attached\`); a stopped run's \`next_step\` names those pages and any unsent \`include=interest\` calls. A page whose stored rows have expired is counted in \`data.attached.posts_expired\` and left as it was, never written as a post with no comments; a plain resume reads it again.
37
37
  - **run_more** works on completed runs only: \`pages\` 1-10, \`feedback.accept\`/\`feedback.reject\` up to 100 ids each (\`accept\` needs \`new_searches: true\`). Read only the new rows with \`changes_since\` = \`data.more.since_version\`. \`data.more.nothing_more\` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.
38
38
  - **run_comments** (\`POST /runs/{run_id}/comments\`) reads comments for an existing posts run: \`top_posts\` 1-50 and \`per_post\` 1-200 (default the run's own, else 3 and 20), \`platforms\`, \`labels\` (up to 10), \`max_credits\` (default the quote's max). \`dry_run\` answers the quote free. Pages an earlier pass stored replay free. Refused free while the run runs (409 \`run_running\`) or owes other work (409 \`run_has_unsent_work\`: resume it first). The answer is 202: poll \`run_status\`.
39
39
  - **Background runs** write comments to each post as it is read and read up to 4 slices of 5 posts at once; \`include=interest\` calls run once searches end. A run started with \`x-client-tag\` tags every background charge, so \`credits/usage?group_by=tag\` equals the run's spend.
@@ -191,7 +191,11 @@ Successful responses may include an optional \`data._warnings\` string array —
191
191
 
192
192
  ## Insufficient credits
193
193
 
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.`,
194
+ Out of credits returns \`INSUFFICIENT_CREDITS\` (402) with \`credits_remaining: 0\`. A per-key spending cap returns \`KEY_BUDGET_EXCEEDED\` (402) instead, and its fix is different: raise the key's cap, don't top up. Neither is retryable; waiting does not clear them.
195
+
196
+ ## Team billing
197
+
198
+ \`GET /v1/credits/balance\` and \`GET /v1/keys/current\` carry \`data.billing\`: \`source\` (\`personal\` or \`team\`), \`team\` (\`id\`, \`name\`, \`role\`, or null), \`own_balance_set_aside\` and \`auto_recharge.enabled\`. For a member of a team, \`balance\` and every \`credits_remaining\` are what the team can spend. A member's 402 keeps the code \`INSUFFICIENT_CREDITS\` but carries no \`checkout_url\`, no \`top_up_url\` and no pack: \`error.details.billing.credits_added_by\` names who adds credits and \`next_step\` says to ask the team's owner, so relay that and never offer a top-up. When the team balance is not available to that member, \`credits_added_by\` is null and \`next_step\` says that leaving the team returns them to their own balance. An account with no team reads \`source: "personal"\` and nothing else changes.`,
195
199
  errors: `# SocialCrawl API — Errors
196
200
 
197
201
  All errors follow the same envelope — every \`/v1\` exit is JSON, never a bare gateway page:
package/dist/data/docs.js CHANGED
@@ -167,7 +167,7 @@ function buildEndpointBlock(e) {
167
167
  if (e.emptyOn404) {
168
168
  notes.push("Empty is not an error: an upstream 404 returns 200 `{items: []}` with the credit refunded.");
169
169
  }
170
- if (e.upstream.fallbackKinds && e.upstream.fallbackKinds.length > 0) {
170
+ if (e.multiSource) {
171
171
  notes.push("Reliability: multi-source with automatic fallback; charged once.");
172
172
  }
173
173
  if (e.contractDetails && e.contractDetails.length > 0) {