Webhooks
Instead of polling /status, pass webhook.url when creating a world (POST /v1/worlds) to receive signed HTTPS POST callbacks whenever the job or any derived export reaches a terminal state.
{
"model": "echo-2",
"input": { "type": "text", "prompt": "Minimalist concrete art gallery" },
"webhook": {
"url": "https://your-server.example.com/webhooks/spaitial"
}
}
Events
event (X-Spaitial-Event) | Trigger |
|---|---|
world.completed | World generation reached COMPLETED. data carries the completed world object. |
world.failed | World generation reached FAILED. data is null and error carries { code, message }. |
world.cancelled | World generation was cancelled via POST .../cancel. data is null. |
world.export.completed | A requested export (mesh, mesh-simplified, floorplan, or zip) reached READY. |
world.export.failed | A requested export failed. error and export.error carry { code, message }. |
Request headers
Every webhook delivery carries these HTTP headers:
Content-Type: application/json
User-Agent: SpaitialWebhook/1.0
X-Spaitial-Event: world.completed
X-Spaitial-Request-ID: req_abc123
X-Spaitial-Delivery-ID: wd_550e8400-e29b-41d4-a716-446655440000
X-Spaitial-Delivery-Attempt: 1
X-Spaitial-Signature: sha256=8f4a2e...
Verify X-Spaitial-Signature
Retrieve your signing secret (webhook_secret) from the Webhooks page in the Developer Portal. Compute the HMAC-SHA256 digest over the exact raw request body bytes (before JSON parsing or re-serialization) and compare in constant time:
- Node.js
- Python
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifySpaitialWebhook(
rawBody: Buffer,
signatureHeader: string | undefined,
webhookSecret: string,
): boolean {
if (!signatureHeader?.startsWith("sha256=")) return false;
const expected = Buffer.from(
`sha256=${createHmac("sha256", webhookSecret).update(rawBody).digest("hex")}`,
"utf8",
);
const actual = Buffer.from(signatureHeader, "utf8");
return expected.length === actual.length && timingSafeEqual(expected, actual);
}
import hashlib
import hmac
def verify_spaitial_webhook(
raw_body: bytes,
signature_header: str | None,
webhook_secret: str,
) -> bool:
if not signature_header or not signature_header.startswith("sha256="):
return False
digest = hmac.new(
webhook_secret.encode("utf-8"),
raw_body,
hashlib.sha256,
).hexdigest()
expected = f"sha256={digest}"
return hmac.compare_digest(expected, signature_header)
Payload shapes
World terminal event (world.completed)
{
"event": "world.completed",
"delivery_id": "wd_550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2026-11-20T12:08:43Z",
"request_id": "req_abc123",
"status": "COMPLETED",
"created_at": "2026-11-20T12:00:00Z",
"updated_at": "2026-11-20T12:08:42Z",
"completed_at": "2026-11-20T12:08:42Z",
"validation": { "passed": true, "issues": [] },
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Minimalist concrete art gallery",
"output_type": "splat",
"splat_url": "https://api.spaitial.ai/v1/worlds/requests/req_abc123/splat",
"splat_format": "spz",
"panorama_url": "https://api.spaitial.ai/v1/worlds/requests/req_abc123/panorama",
"thumbnail_url": "https://img.spaitial.ai/.../thumbnail.webp",
"viewer_url": "https://app.spaitial.ai/worlds/550e8400-e29b-41d4-a716-446655440000",
"cameras_url": null,
"visibility": { "is_public": false, "is_listed": false }
}
}
Multi-scan Echo-3 captures (zips) also include top-level scans and optional warnings on world.completed. On world.failed, data is null and top-level error contains { code, message } (plus validation.issues when a capture archive failed validation).
Export terminal event (world.export.completed)
{
"event": "world.export.completed",
"delivery_id": "wd_7c9e6679-7425-40de-944b-e07fc1f90ae7",
"timestamp": "2026-11-20T12:11:10Z",
"request_id": "req_abc123",
"status": "COMPLETED",
"created_at": "2026-11-20T12:00:00Z",
"updated_at": "2026-11-20T12:11:09Z",
"completed_at": "2026-11-20T12:08:42Z",
"data": null,
"export": {
"type": "mesh",
"status": "READY",
"download_url": "https://api.spaitial.ai/v1/worlds/requests/req_abc123/exports/mesh?download=1"
}
}
When export.type is "floorplan" (or a "zip" containing "floorplan"), the export block also carries the floorplan pixel-to-world mapping object. See Exports and coordinates.
Delivery, timeouts, and retries
- URL validation:
webhook.urlmust usehttps://and resolve to a public IP address. Loopback and private RFC 1918 addresses fail upfront with400 INVALID_WEBHOOK_URL. - Acknowledge fast: Return any
2xxstatus code within 30 seconds, then process downloads asynchronously in your own queue. - Retries: Non-
2xxresponses and timeouts retry up to 5 times with exponential backoff.X-Spaitial-Delivery-Attemptincrements on each attempt whileX-Spaitial-Delivery-IDstays constant. - Idempotent handling: At-least-once delivery means the same
X-Spaitial-Delivery-IDcan arrive more than once on network splits. Deduplicate incoming events ondelivery_id.