cpsl.App is the root object for a Capsule application. It is the Python interface to the Capsule platform: you declare surfaces, state, runtime requirements, filesystems, channels, and product settings here, and Capsule uses that definition for both local serve and hosted deploys.
The App object does two jobs at once:
- it is where you declare the surfaces and data model of the app
- it is the thing Capsule serializes when you run
capsule serveorcapsule deploy
Constructor
Constructor arguments
| Argument | Meaning |
|---|---|
name | App name used for deploys and lookups |
image | Runtime image spec. Required for functional apps |
channels | External transport declarations. Web chat is implicit |
keep_warm_seconds | Keep the runtime warm after activity |
secrets | Workspace secret names to inject into the runtime |
filesystems | Mount-path to FileSystem mapping |
price | Price in cents |
pricing_type | "one_time" or "monthly" |
App-building methods
Most of theApp API is declarative. You call these once while the module is imported, and Capsule remembers the resulting config.
app.collection(...)
Declare a persistent collection and get back a CollectionRef you can use from handlers.
app.setting(...)
Declare a scoped setting that can be bound to UI widgets or read from Python.
app.theme(...)
Configure colors, fonts, tagline, logo, and preset.
app.add_integration(...)
Declare a user-facing integration.
app.add_page(...)
Register a React/TSX page.
app.page(...)
Decorator for Python DSL pages. The function must return cpsl.ui.Page.
app.data(...)
Register a named JSON data source.
Functional-only methods
These are only valid when the app was created withimage=... on the constructor:
app.boot()app.shutdown()app.enter()app.exit()app.message()app.schedule(cron)app.endpoint(...)app.asgi(...)app.task(...)
Class-based apps
For class-based apps, use@app.cls(...) and the global decorators from cpsl:
@app.cls(...) arguments
| Argument | Meaning |
|---|---|
image | Runtime image spec |
price | Price in cents |
pricing_type | "one_time" or "monthly" |
channels | External channels |
keep_warm_seconds | Warm runtime window |
secrets | Secret names to inject |
filesystems | Mount-path to FileSystem mapping |
app.settings
Every App has a settings accessor:
await app.settings.get(key)await app.settings.set(key, value)await app.settings.get_all(keys=None)