# set-env Action

Used in [FLAT tests](https://sevenval.gitbook.io/flat/reference/testing) to change the environment of the FLAT app under test.

Normally, env vars are set on server start-up and are immutable later on. They are available in the pre-defined variable [`$env`](https://sevenval.gitbook.io/flat/variables#predefined-variables).

The action allows to override variables in the `$env` structure for testing purposes.

## Syntax

```markup
<set-env>
{
  "VAR_NAME": "VALUE",
  "BUILD_TIME": {{ unixtime() - 3600 }}
}
</set-env>
```

The action argument is a JSON Object. The property values should be of type string.

As env vars from the system (shell or `docker`) can only be strings, numeric or boolean values are cast to their *string representation*.

If the value is `null`, the env var is unset.

The action argument may be a [JSON template](https://sevenval.gitbook.io/flat/reference/templating).

## See also

* [`$env`](https://sevenval.gitbook.io/flat/variables#predefined-variables) (reference)
* [Using Env Vars](https://sevenval.gitbook.io/flat/cookbook/envvars) (cookbook)
* [Testing](https://sevenval.gitbook.io/flat/reference/testing) (reference)


---

# Agent Instructions: 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:

```
GET https://sevenval.gitbook.io/flat/reference/actions/set-env.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
