> ## Documentation Index
> Fetch the complete documentation index at: https://docs.triform.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions

> Atomic Python units: structure, contracts, workflow

## Structure

* Action.py — Implementation.
* README — Purpose, I/O, examples.
* requirements.txt — Pure‑Python dependencies (no binary installs).

## Contract

* Inputs — Typed, minimal, documented.
* Outputs — Deterministic structure; document edge cases.

## Workflow

1. Define input/output and write `Action.py`.
2. Pin dependencies in `requirements.txt`.
3. Test with small Payloads via Execute.
4. Reuse across Flows and as Agent tools.

## Loop Support

Actions now support iterative execution with loops:

* **For loops** — Iterate over collections and lists
* **While loops** — Continue until a condition is met
* **Loop state management** — Proper handling of iteration context and variables

This allows Actions to handle batch processing, repeated operations, and conditional iterations natively.

## OAuth Integration

Actions can access OAuth credentials for third-party API integrations:

```python theme={null}
from triform import get_oauth_token

def my_action(data: dict) -> dict:
    # Access OAuth token configured via modifiers
    token = get_oauth_token('google')
    
    # Use in API requests
    headers = {'Authorization': f'Bearer {token.access_token}'}
    response = requests.get('https://api.example.com/data', headers=headers)
    
    return response.json()
```

**Supported features:**

* Automatic token refresh before expiration
* Secure credential injection at runtime
* Multi-provider support (Google, GitHub, Slack, Microsoft, etc.)
* Token management handled by the platform

See [Modifiers](/concepts/modifiers) for configuring OAuth credentials.

## File Storage

Actions can save and retrieve files using the Storage system:

```python theme={null}
from triform import save_file, get_file

def process_document(data: dict) -> dict:
    # Save a generated file
    report_path = save_file(
        filename="report.pdf",
        content=generate_pdf(data),
        content_type="application/pdf"
    )
    
    # Retrieve a file
    template = get_file(data["template_path"])
    
    return {"report": report_path}
```

**Available functions:**

* `save_file(filename, content, content_type)` — Store a file
* `get_file(path)` — Retrieve a file's content

See [Storage](/concepts/storage) for complete documentation.

> warning: Dependencies — Only packages that do not require binary installs in the build image are supported.
