> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/design/api-mapping/environment-api.md).

# Environment API

Admin UI can load a global “environment” payload from the backend. This payload is meant for small, UI-focused configuration values.

The endpoint is defined by the `ENV_URL` environment variable. It defaults to `/GetAdminEnvironment`.

On page load (and when the UI decides to refresh), Admin UI calls this endpoint. It then exposes the returned values to screens and widgets.

## Home Page Configuration

If the environment API returns the fields below, Admin UI can change the landing behavior. This is useful for branding, custom dashboards, and AI entry points.

* **landingRedirect**: For redirecting global home page visits to another admin UI page (e.g. /app/custom)
* **landingTemplatePath**: For pulling template for the global home page (e.g. request/cms\_rpc/GlobalLandingPage)
* **aiTemplatePath**: For pulling template for the AI agent home page (e.g. request/cms\_rpc/AIAgentsPage)

{% hint style="info" %}
Template paths are gateway API paths. Use the same format you use elsewhere in Admin UI, like `request/...`.
{% endhint %}

## UI Widget Customizations

Any other returned values are available to UI elements under `_meta.environment`. Use this for small feature flags and UI tweaks driven by the backend.

### Response example

The environment API should return a JSON object. Keep it flat and small when possible.

```json
{
  "landingRedirect": "/app/custom",
  "landingTemplatePath": "request/cms_rpc/GlobalLandingPage",
  "aiTemplatePath": "request/cms_rpc/AIAgentsPage",
  "features": {
    "enableAdvancedSearch": true
  },
  "ui": {
    "defaultRegion": "EU"
  }
}
```

This becomes accessible as:

* `_meta.environment.landingRedirect`
* `_meta.environment.features.enableAdvancedSearch`
* `_meta.environment.ui.defaultRegion`

### Good practices

* Do not return secrets. This payload is visible to any user with UI access.
* Prefer stable keys. Changing key names breaks widgets and templates.
* Keep it fast. It is called during UI initialization.
* Use it for UI configuration only. Do not treat it as a general data API.

### Troubleshooting

* **Nothing shows up in `_meta.environment`:** Verify `ENV_URL` is set and reachable from the UI.
* **Landing template does not render:** Check that `landingTemplatePath` points to a working gateway endpoint.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rierino.com/design/api-mapping/environment-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
