> Documentation index: https://www.socialcrawl.dev/llms.txt > Every page is also available as Markdown by adding .md. # Explain an error (/docs/explain-an-error) Paste a failed response and get the fault, the fix, a corrected request and whether to retry, for free When a call fails, `GET /v1/utility/explain-error` reads the failure for you. You send the status and the body you got back. It answers with what went wrong, how to fix it and a corrected request when your own request allows one. It costs 0 credits. ## Quick start This call pastes a failure caused by a misspelled parameter. The profile request used `handel` where the endpoint takes `handle`. **cURL** ```bash title="cURL" curl -G "https://www.socialcrawl.dev/v1/utility/explain-error" \ -H "x-api-key: sc_your_key_here" \ --data-urlencode "status=400" \ --data-urlencode "body={\"success\":false,\"error\":{\"type\":\"INVALID_REQUEST\",\"message\":\"Unknown query parameter 'handel'. Did you mean 'handle'?\",\"status\":400,\"details\":{\"unknown_parameters\":[\"handel\"],\"suggestions\":{\"handel\":\"handle\"}}}}" \ --data-urlencode "request=/v1/tiktok/profile?handel=nasa" ``` **Python** ```python title="Python" import json import os import requests failed_body = { "success": False, "error": { "type": "INVALID_REQUEST", "message": "Unknown query parameter 'handel'. Did you mean 'handle'?", "status": 400, "details": { "unknown_parameters": ["handel"], "suggestions": {"handel": "handle"}, }, }, } response = requests.get( "https://www.socialcrawl.dev/v1/utility/explain-error", headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]}, params={ "status": 400, "body": json.dumps(failed_body), "request": "/v1/tiktok/profile?handel=nasa", }, ) print(response.json()["data"]) ``` **TypeScript** ```typescript title="TypeScript" const failedBody = { success: false, error: { type: "INVALID_REQUEST", message: "Unknown query parameter 'handel'. Did you mean 'handle'?", status: 400, details: { unknown_parameters: ["handel"], suggestions: { handel: "handle" }, }, }, }; const url = new URL("https://www.socialcrawl.dev/v1/utility/explain-error"); url.searchParams.set("status", "400"); url.searchParams.set("body", JSON.stringify(failedBody)); url.searchParams.set("request", "/v1/tiktok/profile?handel=nasa"); const response = await fetch(url, { headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! }, }); console.log((await response.json()).data); ``` The answer holds the fault and the fix. To use it, paste your own failure in place of the one above. ```json title="Response" { "kind": "error_explanation", "version": 1, "status": 400, "fault": "unknown_param", "error_type": "INVALID_REQUEST", "explanation": "The request sent `handel` that this endpoint does not accept. An unknown parameter is rejected before billing, so nothing was charged.", "fix_steps": [ "Rename `handel` to `handle`.", "`GET /v1/utility/endpoint?id=tiktok/profile` lists the parameters this endpoint takes." ], "corrected_request": { "method": "GET", "path": "/v1/tiktok/profile", "query": { "handle": "nasa" }, "url": "https://www.socialcrawl.dev/v1/tiktok/profile?handle=nasa", "changes": [ { "op": "rename_param", "from": "handel", "to": "handle" } ] }, "retry": false, "doc_url": "https://www.socialcrawl.dev/docs/errors#invalid-request" } ``` ## What you get back Every answer has the same fields. The answer sits in `data`, like any other response. | Field | What it holds | | --- | --- | | `kind` | Always `error_explanation`. | | `version` | The version of this answer shape. | | `status` | The HTTP status of the failure, when your paste carried one. | | `fault` | What kind of mistake it was, from the list below. | | `error_type` | The error code the API returned, such as `INVALID_REQUEST`. | | `explanation` | The fault in plain words. | | `fix_steps` | The steps that fix it, in order. | | `corrected_request` | The request to send instead. It is present only when the error's own details allow one. | | `retry` | `true` when sending the same request again can succeed, `false` when it cannot. | | `doc_url` | The page in these docs that covers this error. | A `corrected_request` holds the `method`, the `path`, the `query` to send and a ready `url`. Its `changes` list says what was changed. Here it renamed one parameter, so each change has an `op`, a `from` and a `to`. ## Faults it covers The `fault` field names one of these. Each is read from the error's type and details, so the same failure always gets the same answer. | `fault` | What it means | | --- | --- | | `unknown_param` | The request sent a parameter the endpoint does not take. | | `param_name_is_value` | A value was sent where the parameter name belongs, which query builders in no-code tools often do. | | `missing_param` | A required parameter is missing. | | `invalid_value` | A parameter has a value outside the allowed list. | | `invalid_request` | The request was malformed in another way. | | `wrong_path` | The path is not an endpoint, and the answer names the nearest real one. | | `method_not_allowed` | The endpoint does not take the HTTP method you used. | | `payload_too_large` | The request body is over the size limit. | | `auth` | The key is missing, wrong or revoked. | | `insufficient_credits` | The account cannot cover the cost of the call. | | `key_budget` | The key reached its own credit limit. | | `rate_limited` | Too many requests, or too many at once. | | `not_found` | The handle, id or URL does not exist on the platform. | | `timeout` | The source was slow, or it is paused for a while. For a paused source the answer names the option to leave out and the time to retry. | | `server_error` | An error on our side. The charge is refunded. | | `network_error` | No response arrived, which is a connection problem and not a fault in the request. | | `idempotency` | The idempotency key conflicts with an earlier request. | | `cohort_state` | A cohort request was refused because of the cohort's state or limits. | | `discover` | A Discover run failed, and the answer follows its own reason and next step. | | `not_an_error` | You pasted a successful response. | | `unknown` | The paste does not match a SocialCrawl error. | ## Parameters Give `body` or `status`. The request goes in `request` and is optional. | Parameter | What it takes | | --- | --- | | `status` | The HTTP status of the failed response. Optional when the body carries error.status | | `body` | The pasted response body: the JSON error envelope (URL-encoded or base64url) or plain text. Up to 8,000 characters. Provide this or status | | `request` | The request that failed, as a URL or /v1 path with its query string. Lets the answer return a corrected request. Credentials in it are dropped | ## Use it in an agent An agent can fix its own failed calls with four steps. Keep the `request_id` of every failed call. It is in the response body and in the `X-Request-Id` header. Call explain-error with the status and the body of the failure. When `corrected_request` is present, send its `url` instead of the original request. Send the same request again only when `retry` is `true`, and wait as [Errors and retries](/docs/handle-errors.md) describes. For a 5xx, check the [status page](/docs/status.md) first. This is an endpoint, so any agent that can make an HTTP call can use it. ## Cost and privacy The call costs 0 credits. The answer is computed from the error type and the details the API returned. Nothing is fetched from a platform. The answer is not cached. A pasted failure can carry details of your request, and the paste is the cache key, so we do not store it. ## When to write to us When the answer is wrong, or the failure is not one of yours, tell us. Send `POST /v1/feedback` with the `request_id` of the failed call, as the [support page](/docs/support.md) shows. Or write to [socialcrawl@ridio.io](mailto:socialcrawl@ridio.io) with the same `request_id`.