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.
Endpoint
Section titled “Endpoint”POST /v1/pages/content/serializeAuthentication
Section titled “Authentication”| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sw_api_live_... |
Content-Type | Yes | application/json |
Required scope:
pages:content:serializeRequest Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Page URL to serialize. |
extraction_mode | string | No | Optional extraction profile. Omit unless instructed otherwise. |
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. |
Example Request
Section titled “Example Request”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:
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())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);Response
Section titled “Response”{ "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 } }}Response Fields
Section titled “Response Fields”| 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. |
Pagination Example
Section titled “Pagination Example”If content_view_truncated is true, request the next slice:
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 }'Credits
Section titled “Credits”A successful billable page serialization response costs 1 credit.
Failed validation, blocked responses, or unsupported pages may return billing.billable: false.
Errors
Section titled “Errors”| Status | Meaning |
|---|---|
400 | Invalid URL, unsupported extraction profile, or invalid character limits. |
401 | Missing or invalid API key. |
402 | Insufficient credits for a billable request. |
403 | API key is missing pages:content:serialize. |
503 | Page extraction is temporarily unavailable. |