# Work with a site context

Source: https://zotonic.com/docs/2949/work-with-a-site-context

URI: https://zotonic.com/id/2949

Language: en

A context carries the site and request-related state used by Zotonic APIs. Pass it through your functions instead of storing one context globally.

In a trusted local shell, select the site explicitly:

```erlang
C = z:c(garden).
z_context:site(C).
```

This creates a fresh context; it does not automatically log in an administrator. It does not reproduce a visitor's session or permissions. In a model, controller, or event handler, use the supplied request context and preserve it when the API returns an updated context.

Background work needs a deliberate context and authorization policy. See [Inspect content from the Erlang shell](/id/1639), [Keep permission checks at the boundary](/id/1536), and [Run work outside a request](/id/2963).

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2949?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2949?language=en>)
