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

# Deploy to Fly.io From an Agent Without Exposing Tokens

> Let agents deploy and manage Fly.io apps, Machines, volumes, and secrets. The gateway injects your API token, so it never reaches the agent.

## Overview

Buckle connects AI agents to Fly.io so they can deploy and manage applications, Machines, volumes, and secrets. The gateway injects your API token into requests automatically.

## What you will set up

* A Fly.io API token stored in Buckle
* Automatic `Bearer` injection on requests to `api.machines.dev` and `api.fly.io`
* Per-agent, per-tool access to apps and Machines

## Setup

**1. Create an API token**

Generate a token from the [Fly.io dashboard](https://fly.io/dashboard) or run:

```bash theme={null}
fly tokens create org
```

**2. Connect in Buckle**

Open the Buckle dashboard, go to **Settings** > **Apps** > **Fly.io**, and paste your API token.

![Buckle connect window for Fly.io, showing the setup guide link and the fields to fill in.](https://mintcdn.com/onecli-17d3f772/hJP3XqgFsBDnXHKy/images/integrations/flyio/buckle-connect-flyio.png?fit=max\&auto=format\&n=hJP3XqgFsBDnXHKy\&q=85\&s=687e37a459f86e98a7a3454713f79c34)

The Fly.io connect window in Buckle.

## How it works

1. Your API token is encrypted and stored by Buckle
2. When an agent sends a request to `api.machines.dev` or `api.fly.io`, the gateway intercepts it
3. The gateway injects the token as an `Authorization: Bearer` header
4. The request is forwarded to Fly.io

Agents never see the raw token.

## What agents can do

| Area | Examples |
| - | - |
| **Apps** | Create, list, and manage Fly applications |
| **Machines** | Start, stop, and configure Fly Machines |
| **Volumes** | Create and manage persistent storage volumes |
| **Secrets** | Set and unset application secrets |
| **Deployments** | Deploy new releases |
| **Certificates** | Manage TLS certificates for custom domains |

## Use cases

* Coding agents deploying applications after building
* Infrastructure agents scaling Machines up or down
* Monitoring agents checking application health
* Agents managing secrets and environment variables

## Controlling access

Access is per agent: [grant](/docs/guides/agent-access.md) the connection to each agent that needs it, choosing per tool what runs freely, what needs human approval, and what stays blocked — a read-only agent is a single grant. Organization [rules](/docs/guides/rules.md) add guardrails on top, like rate limits and blanket blocks. Everything is checked before credential injection, so a blocked request never reaches Fly.io.

## FAQ

> [accordion] How do I rotate my Fly.io token?
>
> Create a new token with `fly tokens create org` or in the dashboard, then paste it into **Settings** > **Apps** > **Fly.io**. Agents pick up the new token automatically. Then revoke the old one.

> [accordion] How do I keep the token out of the agent's context?
>
> Don't set `FLY_API_TOKEN` in the agent's environment. Store the token in Buckle, and the gateway injects it at the proxy. See [How it works](/docs/how-it-works.md).

> [accordion] Can I require approval before an agent deploys?
>
> Yes. Set write tools to need approval when you [grant](/docs/guides/agent-access.md) the connection, or add [rules](/docs/guides/rules.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.