# Context: StdOut

The last thing written to the stdout file descriptor during a run is passed to the next run. Typically, this is used to pass state between runs using a JSON encoded string of an object that includes, for example, a list of IDs of resources that have already been processed or a timestamp of the most recently processed resource. The string passed to stdout is also used to power the data behind a [dynamic config](/getting-started/anatomy-of-an-integration/pandium.yaml-spec/dynamic-configurations.md).

Below is an example of how to retrieve the contents of a context variable from the environment:

{% tabs %}
{% tab title="Python" %}

```python
import os
os.environ['PAN_CTX_LAST_SUCCESSFUL_RUN_STD_OUT']
```

{% endtab %}

{% tab title="JavaScript (Node)" %}

```
process.env.PAN_CTX_LAST_SUCCESSFUL_RUN_STD_OUT
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
ENV["PAN_CTX_LAST_SUCCESSFUL_RUN_STD_OUT"]
```

{% endtab %}
{% endtabs %}

### Context Variables

Below is a list of variables that are injected into the run environment with the `PAN_CTX` prefix.

<table><thead><tr><th width="336.3333333333333">name</th><th width="599">description</th><th width="236">notes</th></tr></thead><tbody><tr><td><strong>PAN_CTX_INTEGRATION_ID</strong></td><td>The Pandium ID of the Integration that is running currently.</td><td>an integer unique to your account</td></tr><tr><td><strong>PAN_CTX_INTEGRATION_NAME</strong></td><td>The name of the Integration that is running currently</td><td></td></tr><tr><td><strong>PAN_CTX_TENANT_ID</strong></td><td>The Pandium ID of the Tenant that is running currently.</td><td>An integer unique to your account</td></tr><tr><td><strong>PAN_CTX_TENANT_NAME</strong></td><td>The name of the Tenant that is running currently.</td><td></td></tr><tr><td><strong>PAN_CTX_RUN_MODE</strong></td><td>An enum of one of the following values: <code>init</code> , <code>normal</code>, <code>webhook</code></td><td></td></tr><tr><td><strong>PAN_CTX_RUN_TRIGGERS</strong></td><td>List of objects that contain the payload data for run triggers</td><td>Can view the mode, source, and payload data as well as headers it was sent with</td></tr><tr><td><strong>PAN_CTX_ENV</strong></td><td>The environment the sync is running in, i.e. dev/staging/prod</td><td></td></tr><tr><td><strong>PAN_CTX_LAST_RUN_START_TIME</strong></td><td>A datetime that represents the time the last run started. i.e. <code>2021-07-24 20:04:21 +0000 UTC</code></td><td>Will appear in environment only after first run.</td></tr><tr><td><strong>PAN_CTX_LAST_RUN_COMPLETION_TIME</strong></td><td>A datetime that represents the time the last run completed. i.e. <code>2021-07-24 20:07:21 +0000 UTC</code></td><td>Will appear in environment only after first run.</td></tr><tr><td><strong>PAN_CTX_LAST_RUN_PHASE</strong></td><td>An enum of one of the following values: <code>Succeeded</code>, <code>Failed (Platform Issue)</code>, <code>Failed (Integration Issue)</code> , <code>Failed (Timeout)</code></td><td>Will appear in environment only after first run.</td></tr><tr><td><strong>PAN_CTX_LAST_RUN_STD_OUT</strong></td><td>The JSON encoded string that was optionally printed to <em>stdout</em> during last Run.</td><td></td></tr><tr><td><strong>PAN_CTX_LAST_SUCCESSFUL_RUN_START_TIME</strong></td><td>A datetime that represents the time the last successful run. i.e. <code>2021-07-24 20:04:21 +0000 UTC</code></td><td>Will appear in environment only after <em>successful</em> first run.</td></tr><tr><td><strong>PAN_CTX_LAST_SUCCESSFUL_RUN_COMPLETION_TIME</strong></td><td>A datetime that represents the time the last successful run completed. i.e. <code>2021-07-24 20:07:21 +0000 UTC</code></td><td>Will appear in environment only after <em>successful</em> first run</td></tr><tr><td><strong>PAN_CTX_LAST_SUCCESSFUL_RUN_PHASE</strong></td><td>An enum of one of the following values: <code>Succeeded</code>, <code>Failed (Platform Issue)</code>, <code>Failed (Integration Issue)</code> , <code>Failed (Timeout)</code></td><td>Will appear in environment only after <em>successful</em> first run</td></tr><tr><td><strong>PAN_CTX_LAST_SUCCESSFUL_RUN_STD_OUT</strong></td><td>The JSON encoded string that was optionally printed to <em>stdout</em> during last successful Run.</td><td></td></tr></tbody></table>

A good way to use the saved state between runs via stdout is to continue running large syncs sequentially in a 'dynamic sync' process.

Below are some examples of writing to stdout in various languages

{% tabs %}
{% tab title="C#" %}

```
Console.WriteLine("Hello World")
```

{% endtab %}

{% tab title="Java" %}

```java
System.out.println("Hello World!");
```

{% endtab %}

{% tab title="NodeJS" %}

```
console.log('Hello World')
```

{% endtab %}

{% tab title="PHP" %}

```php
echo "Hello World" . "\n"
```

{% endtab %}

{% tab title="Python" %}

```python
print("Hello World!")
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
puts "Hello Word!"
```

{% endtab %}
{% endtabs %}

{% hint style="danger" %} <mark style="color:red;">Please Note: When handling context/stdout, there is a 128kb limit that is supported within Pandium</mark>
{% endhint %}


---

# 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://docs.pandium.com/getting-started/anatomy-of-an-integration/environment-variables/stdout.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.
