Swift SDK reference

Package layout and configuration for the Spectron Swift client.

ItemValue
Packagesurrealdb.swift
ProductSpectron
Install.product(name: "Spectron", package: "surrealdb.swift")
Importimport Spectron
let memory = try Spectron(
context: "acme-prod",
endpoint: "https://api.spectron.example",
apiKey: "sk-spec-..."
)
SettingPurpose
contextPath segment after /api/v1/
endpointBase URL (no trailing slash)
apiKeyContext API key
Authorization: Bearer <key>
SDK areaHTTP
FactsPOST /api/v1/{ctx}/facts, POST .../facts/batch
Query / contextPOST .../query, POST .../context
ChatPOST .../chat
DocumentsPOST/GET/DELETE .../documents
SessionsPOST/GET/DELETE .../sessions
EntitiesGET/DELETE .../entities/{type}/{name}
Governance.../scopes, .../principals, .../keys

Full tables: REST API.

  • Pass onBehalfOf: to act as another principal. It is sent as the X-Spectron-On-Behalf-Of header.

  • Writes carry an Idempotency-Key header for safe retry deduplication.

All failures throw SpectronError with fields status, title, detail, retryAfter, typeURI, instance and extensions. The kind maps to .base, .auth, .scope, .notFound, .validation, .rateLimit or .server. See Errors.

See Swift SDK for usage patterns.

Was this page helpful?