SocialCrawl

Dashboard, errors and words

Explain a failed call

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
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
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
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.

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.

FieldWhat it holds
kindAlways error_explanation.
versionThe version of this answer shape.
statusThe HTTP status of the failure, when your paste carried one.
faultWhat kind of mistake it was, from the list below.
error_typeThe error code the API returned, such as INVALID_REQUEST.
explanationThe fault in plain words.
fix_stepsThe steps that fix it, in order.
corrected_requestThe request to send instead. It is present only when the error's own details allow one.
retrytrue when sending the same request again can succeed, false when it cannot.
doc_urlThe 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.

faultWhat it means
unknown_paramThe request sent a parameter the endpoint does not take.
param_name_is_valueA value was sent where the parameter name belongs, which query builders in no-code tools often do.
missing_paramA required parameter is missing.
invalid_valueA parameter has a value outside the allowed list.
invalid_requestThe request was malformed in another way.
wrong_pathThe path is not an endpoint, and the answer names the nearest real one.
method_not_allowedThe endpoint does not take the HTTP method you used.
payload_too_largeThe request body is over the size limit.
authThe key is missing, wrong or revoked.
insufficient_creditsThe account cannot cover the cost of the call.
key_budgetThe key reached its own credit limit.
rate_limitedToo many requests, or too many at once.
not_foundThe handle, id or URL does not exist on the platform.
timeoutThe 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_errorAn error on our side. The charge is refunded.
network_errorNo response arrived, which is a connection problem and not a fault in the request.
idempotencyThe idempotency key conflicts with an earlier request.
cohort_stateA cohort request was refused because of the cohort's state or limits.
discoverA Discover run failed, and the answer follows its own reason and next step.
not_an_errorYou pasted a successful response.
unknownThe paste does not match a SocialCrawl error.

Parameters

Give body or status. The request goes in request and is optional.

ParameterWhat it takes
statusThe HTTP status of the failed response. Optional when the body carries error.status
bodyThe pasted response body: the JSON error envelope (URL-encoded or base64url) or plain text. Up to 8,000 characters. Provide this or status
requestThe 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 describes. For a 5xx, check the status page 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 shows. Or write to socialcrawl@ridio.io with the same request_id.

On this page

Ready to build?

Start getting social data for free and scale as your project grows. No credit card needed.