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

# Heroku

> Connect Heroku so CloudThinker can review apps, dynos, logs, add-ons, and pipelines through a read-only connection

Connect Heroku to let CloudThinker agents list your apps, read dyno formation and recent logs, review add-ons and their plans, and show which pipeline stage each app sits in. CloudThinker only reads, but it uses one Heroku **API token**, and that token has full write access to every app and team its user can reach, so protect it.

***

## Prerequisites

* A Heroku account that belongs to the apps, teams, and pipelines you want to investigate.
* Optional: the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli), signed in as that account with `heroku login`. You can use the Heroku Dashboard instead.
* The **Admin** role in your CloudThinker workspace, which can add and edit connections. See [Roles](https://docs.cloudthinker.io/guide/security/roles.md).

***

## Setup

**1. Create an API token**

Sign in as the account CloudThinker should use, then pick one way:

* **CLI**: run this. `2592000` seconds is 30 days. Without `--expires-in`, the token never expires.

  ```bash theme={null}
  heroku authorizations:create -d cloudthinker --expires-in 2592000
  ```

* **Dashboard**: go to **Account settings → Applications → Authorizations** and click **Create authorization**. Enter `cloudthinker` as the description, set an expiry, and create it.

Copy the token. With the CLI, it's the value on the `Token:` line of the output. It starts with `HRKU-`. Keep the `global` scope; see [Required permissions](#required-permissions) for why.

To cancel it later, run `heroku authorizations` to find its id, then `heroku authorizations:revoke <id>`.

**2. Add the connection in CloudThinker**

In the sidebar, click **More → Workspace settings → Connections**. On the **Builtin Connections** tab, search for **Heroku**, paste the token into **API token**, and click **Connect**.

**Success state:** the Heroku card shows **Connected**.

**3. Run the verify prompt**

Run the [verify prompt](#verify-the-connection) to confirm the token can read your account.

**Success state:** CloudThinker returns your apps with their dyno formation.

***

## Connection details

| Field | Description | Example |
| - | - | - |
| **API token** | Authorization token from `heroku authorizations:create`. It inherits the account's access to every app and team it can reach. | `HRKU-...` |

***

## Required permissions

A Heroku token can't be limited to some apps. It can reach whatever its user can, so least privilege comes from the account you create it with.

* **Use the `global` scope.** The Heroku CLI that agents use resolves the token's own account before it lists apps or pipelines. Heroku's `identity` scope is read-only but covers only account information, and the `read`, `write`, `read-protected`, and `write-protected` scopes exclude account information. No single narrower scope covers both, so a token with one of them fails when it lists apps and pipelines.
* **Use a dedicated account.** Add it only to the teams and apps CloudThinker needs.
* **If you sign in with SSO**, create the token from a separate non-SSO user for the integration.

> [!WARNING]
>
> A `global` token has full write access at Heroku. If it leaks, whoever holds it can change or delete every app its user can reach. Use a dedicated low-privilege account and a short expiry.

> [!TIP]
>
> This connection only reads. Agents can't restart, scale, or change apps, whatever the token allows.

***

## Agent capabilities

| Capability | Description |
| - | - |
| **Apps** | List apps and read one app's stack, region, and maintenance state |
| **Logs** | Read an app's latest application log lines, without router noise: 40 lines by default, up to 200 if you ask |
| **Dynos** | Show the dyno formation: type, size, quantity, and state of each process |
| **Add-ons** | List add-ons per app or across the account, and browse add-on services and plans |
| **Teams and private spaces** | List the teams and private spaces the account can reach |
| **Pipelines** | List pipelines and show the apps in each stage |

Agents never read config vars, environment values, or database credentials. For queries against a Heroku Postgres database, add a separate [PostgreSQL connection](https://docs.cloudthinker.io/guide/connections/postgresql.md).

### Verify the connection

```text theme={null}
Check my Heroku connection and list my apps with their dyno formation
```

### Example prompts

```text theme={null}
My checkout app on Heroku is throwing errors. Read its recent logs and dynos, and tell me what's wrong
List the add-on plans attached to each of my Heroku apps as a table
Which stage of the web pipeline is each app in, and is any app in maintenance mode?
```

Name the app or pipeline in your prompt when the account has many apps. The answer stays focused on it.

***

## Troubleshooting

> [accordion] 401 Unauthorized
>
> The token is wrong, expired, or revoked. Create a new one, then open the connection, click the edit icon on the instance, click **Replace…** in **Edit Instance**, paste the token, and click **Save and test**.

> [accordion] 403 Forbidden on an app or team
>
> The token's account isn't a member of that app or team. Add the account in Heroku, then ask again.

> [accordion] 404 Couldn't find that user
>
> The token can't read its own account, which is what a narrow scope looks like. Add-ons and teams still list, but apps and pipelines fail. Create a new authorization with the default `global` scope and replace it on the connection. See [Rotate a credential](https://docs.cloudthinker.io/guide/connections/overview.md#rotate-a-credential).

> [accordion] 404 for a named app, add-on, or pipeline
>
> The name is wrong, or it belongs to an account the token can't see. Ask CloudThinker to list your apps or pipelines, then use a name from that list.

> [accordion] 429 Too Many Requests
>
> Heroku throttled the account. Wait a few minutes, then ask about one app at a time so each run makes fewer calls.

> [accordion] No private spaces are listed
>
> Private spaces are a Heroku Enterprise feature. If your account has none, an empty list is the correct answer.

***

## Security

* **Least privilege** — grant only the permissions the agents need for your use case; start read-only and widen later.
* **Read-only by default** — use read-only credentials unless you want agents to make changes through this connection.
* **Rotate credentials** — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
* **Revoke on offboarding** — remove the credential at the provider when you delete a connection or a teammate leaves.

- **No read-only token on Heroku**: the read-only advice above doesn't apply here. The connection needs a `global` token, which always carries full write access at Heroku, and a narrower scope breaks it. CloudThinker itself only reads, so limit the risk with a dedicated low-privilege account and a short expiry.
- **Plan rotation**: pass `--expires-in` when you create the token. When you no longer need it, find its id with `heroku authorizations` and run `heroku authorizations:revoke <id>`.
- **Treat logs as sensitive**: an app can print secrets into its own logs. CloudThinker avoids quoting lines that look like tokens or passwords, but don't rely on that alone.

***

## Related

> [card] [PostgreSQL Connection](https://docs.cloudthinker.io/guide/connections/postgresql.md)
>
> Query a Heroku Postgres database with its own credentials

> [card] [Connections overview](https://docs.cloudthinker.io/guide/connections/overview.md)
>
> See every platform you can connect and how to rotate a credential


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