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
HeaderRequiredValue
AuthorizationYesBearer sw_api_live_...
Content-TypeYesapplication/json

Required scope:

pages:content:serialize
FieldTypeRequiredDescription
urlstringYesPage URL to serialize.
extraction_modestringNoOptional extraction profile. Omit unless instructed otherwise.
max_charsintegerNoMaximum returned content characters. 1 to 25,000. Defaults to 12,000.
offsetintegerNoCharacter 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": {
"max_chars": 12000
}
}
}
FieldTypeDescription
serialization.content_viewstringNormalized text representation of title, metadata, headings, body copy, and relevant page sections.
serialization.content_view_truncatedbooleanWhether more content is available beyond max_chars.
serialization.next_offsetinteger or nullUse this value as offset to fetch the next slice.
serialization.billingobjectWhether 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.

StatusMeaning
400Invalid URL, unsupported extraction profile, or invalid character limits.
401Missing or invalid API key.
402Insufficient credits for a billable request.
403API key is missing pages:content:serialize.
503Page extraction is temporarily unavailable.