> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/reference/flows/flow-variables.md).

# Flow variables

Flows have access to a set of built-in variables that carry information about the running flow, such as the active environment, the identity the flow runs as, and details of the incoming request. These are the flow variables.

Flow variables appear in the **Flow Data** section of the data-binding dialog on any flow action. They can be bound to action node properties and referenced in [conditions](/reference/platform-concepts/conditions.md) and [filters](/reference/platform-concepts/filters.md), the same way [app variables](/reference/apps/data/app-variables.md) are used in apps. Their values are resolved at runtime when the flow runs.

| Variable               | Data type        | Description                                                                                                                                                                                                                                                             |
| ---------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Active Environment** | Enum             | The environment the flow is running in, either `Develop`, `Test`, `Staging`, or `Production`. Resolves the same regardless of how the flow is run. Useful to alter functionality based on whether the environment uses production data (Staging and Production) or not. |
| **Current User ID**    | Reference (User) | The identity the flow is running as. See [Identity](#identity).                                                                                                                                                                                                         |
| **Principal User ID**  | Reference (User) | The user who originated the run. See [Identity](#identity).                                                                                                                                                                                                             |
| **Service Account ID** | String           | The [service account](/reference/security/service-accounts.md) the flow is running as, if any. Empty when the flow runs as a human user. See [Identity](#identity).                                                                                                     |
| **Hostname**           | String           | The host from the incoming HTTP request. See [Request context](#request-context).                                                                                                                                                                                       |
| **IP address**         | String           | The client IP address from the incoming HTTP request. See [Request context](#request-context).                                                                                                                                                                          |
| **Client HTTP Method** | Enum             | The HTTP method of the incoming request, for example `GET` or `POST`. See [Request context](#request-context).                                                                                                                                                          |

### Identity

Three flow variables describe the identity a flow is running under. They matter most when a flow can be run both directly by a person and automatically by a service account.

**Current User ID** is the effective identity the flow runs as. **Principal User ID** is the user who originated the run, and is always populated. **Service Account ID** is the service account in effect, and is empty when the flow runs as a human user.

When a flow runs on behalf of a person, Current User ID and Principal User ID both resolve to that person and Service Account ID is empty. When a flow runs as a service account, Service Account ID is populated and Current User ID resolves to the service account. Principal User ID stays with the person who initiated the run where there is one, so the human behind the call is preserved even when the flow acts as a service account.

| Trigger                                                                                 | Current User ID     | Principal User ID   | Service Account ID  |
| --------------------------------------------------------------------------------------- | ------------------- | ------------------- | ------------------- |
| [Run Flow](/library/action-nodes/run-flow.md) from an app, as a normal user             | the user            | the user            | empty               |
| Run Flow from an app, with **Run as Service Account**                                   | the service account | the user            | the service account |
| [API Endpoint](/reference/flows/api-endpoints.md) called with a service account API key | the service account | the service account | the service account |
| [Schedule](/reference/flows/schedules.md)                                               | the service account | the service account | the service account |

{% hint style="info" %}
**Good to know**

Current User ID and Principal User ID are id-only references to the User object class. They are used to reference a user object downstream, for example to filter a query or update the caller's own record, and resolve without a database read. The referenced user object cannot be browsed into from the binding. Service Account ID is a plain string and can be read directly.
{% endhint %}

### Request context

**Hostname**, **IP address**, and **Client HTTP Method** describe the incoming HTTP request. They are populated only when the flow is run through an API Endpoint. For any other trigger, such as Run Flow from an app or a schedule, they resolve to empty and the flow continues without error.

{% hint style="info" %}
**Good to know**

If you bind a request-context variable in an action that is not guaranteed to run from a web request, for example an action reachable only by a schedule, a non-blocking alert appears on the action at design time. The value will be empty in those runs. The alert does not prevent you from saving.
{% endhint %}

{% hint style="warning" %}
**Important**

Hostname and IP address are derived from request headers (such as `X-Forwarded-For`) and can be spoofed by the caller. Do not use them as the sole basis for an access-control decision.
{% endhint %}

### Resource files

The [resource files](/reference/resources/files.md) uploaded to your solution are available in flows. A flow can use a resource file as a whole file, for example to attach it to an email with the [Send Email](/library/action-nodes/send-email.md) action node or to pass its URL to a request.


---

# 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.appfarm.io/reference/flows/flow-variables.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.
