Skip to content

Contexts

Contexts let you group related MolnOS resources under a shared name. A context represents a logical boundary around a piece of software—an app, a system, a project—giving you a way to organize and manage resources together without imposing rigid hierarchy.

A context is a named container with an optional intent (what it’s for) and freeform attributes (metadata). Resources like functions, databases, storage buckets, and sites can all belong to a context.

Unlike organizational models in major clouds (AWS accounts, GCP projects), contexts are a soft boundary. They don’t enforce strong isolation—they’re a way to keep things organized and provide meaning to your landscape. Additionally, these allow you to add a boundary to generate code and configuration to, using the AI generation capabilities in MolnOS.

A default context is always available.

  • Organization: Group the functions, databases, and storage that make up a single application
  • AI generation: The AI uses a context’s intent and attributes to understand what you’re building and generate appropriate code
  • Lifecycle management: Delete all resources in a context at once when decommissioning
  • Visibility: See at a glance what resources belong together

Contexts are managed through the HTTP API at /contexts/* endpoints.

Terminal window
POST /contexts
{
"name": "url-shortener",
"intent": "A URL shortener API with analytics and custom short codes",
"attributes": {
"storage": "kv",
"auth": "apiKey"
}
}
  • name (required) - Unique name, 1-64 characters
  • intent (optional) - Human-readable description of purpose, up to 1000 characters
  • attributes (optional) - Any JSON object with custom metadata
Terminal window
GET /contexts

Returns all contexts with a summary of associated resources.

Terminal window
GET /contexts/{contextName}

Returns the context along with its associated resources.

Terminal window
PATCH /contexts/{contextName}

Update the intent or attributes:

{
"intent": "Updated description of this context",
"attributes": {
"auth": "jwt",
"features": ["rate-limiting"]
}
}
Terminal window
DELETE /contexts/{contextName}

Deletes the context. The default context cannot be deleted.

Terminal window
DELETE /contexts/{contextName}/resources

Removes all resources (functions, databases, storage, sites, etc.) associated with the context.

Resources are associated with contexts in three ways:

  1. Via IaC: Resources defined in an IaC configuration are automatically registered to the context specified in that config
  2. At creation: When deploying a function or creating a database table, pass a context parameter to associate it
  3. Automatically: Resources created without an explicit context are placed in the default context

Contexts can contain any other resource types.

Context operations require appropriate permissions:

  • contexts.context.create - Create new contexts
  • contexts.context.get - List and view contexts
  • contexts.context.update - Update context intent and attributes
  • contexts.context.delete - Delete contexts
  • contexts.context.delete-resources - Delete all resources in a context