drift Docs
Start
What is Drift?
The tour, if you are new here.
Why Drift?
The case for a smaller cloud.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, five unit prices, two rules.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Accounts, tokens and scopes.
Security
Boundaries, sandboxing and hardening.

Atomic The directive

Every handler declares exactly one trigger, plus optional keywords on the same line. Two triggers on one line is an error.

Trigger Meaning
http=<method>:<route>An HTTP endpoint. Methods: get, post, put, delete, patch. Route params use :name (e.g. http=get:items/:id).
queue=<name>Runs for each message on the named Backbone queue.
cron="<expr>"Parses (quote it so the spaces survive) but the deploy path refuses it: “@atomic cron= triggers aren't supported by the deploy path yet (only http= and queue= are wired)”. Declare schedules in the Driftfile instead; see Triggers.
ValuesMeaning
  • auth=
    Values
    none · apikey
    Meaning
    Protection gate (see Authentication). Defaults to none. Any other value deploys and then answers 403 to every caller.
  • stream=
    Values
    sse · ws
    Meaning
    Marks the function as streaming, so the slice hijacks the connection instead of buffering one response. See Streaming.
  • secrets=
    Values
    KEY1,KEY2
    Meaning
    Names the Backbone secrets this function may read. The runner fetches them and injects them as DRIFT_SECRET_<NAME> environment variables, uppercased.

The comment marker can be //, #, or --, whichever is natural for the language.

Read secrets through the SDK, not the environment.

drift.Backbone.Secret.Get("STRIPE_KEY") (lowercase in the interpreted SDKs) resolves the value whichever way the runtime delivered it. Reading os.environ directly works only on the per-invocation subprocess path. Python and Node functions served by the slice's persistent language server get their secrets in the request envelope instead, and the env var is absent.

Routing

A function's address is the method and path from its @atomic directive: http=post:users answers only POST /api/users. The method is part of the identity, not a detail. A request with a different method to the same path doesn't fall through to this function, it 404s. There's nothing to branch on inside the handler (you were routed here because you're the POST handler), so drift.Request deliberately doesn't expose the method.

So GET /users (list) and POST /users (create) are two functions with two handlers, two @atomic directives and two billing units. The path /users is a human grouping, not the unit; the unit is the function.

The /api space is shared across every element, so two functions declaring the same method+path collide wherever they live. drift project deploy refuses the whole project and names both.

Method-and-path identity is why most CLI commands that address a single function take --method: without it, get:users and post:users are indistinguishable by name.