Skip to content

Serialize content

Extracts one URL into Sleepwalker’s normalized page content view.

Use this when an agent or integration needs the cleaned page content only, not prompt suggestions, trend discovery, scoring, or a saved run.

POST /v1/pages/content/serialize
Header Required Value
Authorization Yes Bearer sw_api_live_...
Content-Type Yes application/json

Required scope:

pages:content:serialize
Field Type Required Description
url string Yes Page URL to serialize.
extraction_mode string No Accepts ssr, csr, or full. The current one-off endpoint always executes static SSR extraction; the other values remain accepted for compatibility. Defaults to ssr.
max_chars integer No Maximum returned content characters. 1 to 25,000. Defaults to 12,000.
offset integer No Character offset for paginating long content. Defaults to 0.
Terminal window
curl -s https://api.sleepwalker.ai/v1/pages/content/serialize \
-H "Authorization: Bearer sw_api_live_..." \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.sleepwalker.ai",
"max_chars": 12000,
"offset": 0
}'

The same request in Python and JavaScript:

Python
import requests
resp = requests.post(
"https://api.sleepwalker.ai/v1/pages/content/serialize",
headers={"Authorization": "Bearer sw_api_live_..."},
json={
"url": "https://www.sleepwalker.ai",
"max_chars": 12000,
"offset": 0,
},
)
resp.raise_for_status()
print(resp.json())
JavaScript
const resp = await fetch("https://api.sleepwalker.ai/v1/pages/content/serialize", {
method: "POST",
headers: {
Authorization: "Bearer sw_api_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://www.sleepwalker.ai",
max_chars: 12000,
offset: 0,
}),
});
const data = await resp.json();
console.log(data);
{
"serialization": {
"url": "https://www.sleepwalker.ai",
"http_status": 200,
"content_view": "Title: Sleepwalker\nMeta description: ...",
"content_view_offset": 0,
"content_view_chars": 9000,
"content_view_truncated": false,
"next_offset": null,
"billing": {
"billable": true,
"estimated_credits": "1.00"
},
"payload_limits": {
"raw_extraction_returned": false,
"max_chars": 12000
}
}
}
Field Type Description
serialization.content_view string Normalized text representation of title, metadata, headings, body copy, and relevant page sections.
serialization.content_view_truncated boolean Whether more content is available beyond max_chars.
serialization.next_offset integer or null Use this value as offset to fetch the next slice.
serialization.billing object Whether the response is billable, its credit cost, and credit status.

If content_view_truncated is true, request the next slice:

Terminal window
curl -s https://api.sleepwalker.ai/v1/pages/content/serialize \
-H "Authorization: Bearer sw_api_live_..." \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.sleepwalker.ai",
"max_chars": 12000,
"offset": 12000
}'

A successful billable page serialization response costs 1 credit.

Failed validation, blocked responses, or unsupported pages may return billing.billable: false.

Status Meaning
400 Invalid URL or unsupported extraction_mode.
401 Missing or invalid API key.
402 Insufficient credits for a billable request.
403 API key is missing pages:content:serialize.
422 url is missing, or max_chars/offset has the wrong type or falls outside its declared bound.
503 Credit storage is temporarily unavailable. Try again shortly.

Extraction failures and API-key rate limits are documented in Errors.