# See which workflows use each connection

**GET** `/api/connections/usage`

Lists, for each connection, the workflows that use it.

Needs [an API token](https://docs.gorunner.io/api/authentication#scopes) with the **Read** permission for connections (`connection:read`).

## Request

It takes no parameters.

## Before you delete or replace

Each workflow is listed once, however many steps use the connection. `inLive`: the published version uses it, so production does. `inDraft`: the draft does. Triggers, branches, loops and error steps all count.

Then [move those workflows](https://docs.gorunner.io/api/connections/replace-connection-references) before you [delete it](https://docs.gorunner.io/api/connections/delete-connection).

## Responses

- 200 OK

  Workflows by connection ID. A connection no workflow uses is left out, not listed empty. A key can name a connection that is gone, while a workflow still names it.

- 403 `FORBIDDEN`

  The token lacks the **Read** permission for connections.

- 500 `INTERNAL_ERROR`

  The use couldn’t be worked out. Try again.

Any call can also answer: [`401 UNAUTHORIZED`](https://docs.gorunner.io/errors#UNAUTHORIZED) · [`401 TOKEN_ENDED`](https://docs.gorunner.io/errors#TOKEN_ENDED) · [`403 TOKEN_SURFACE_OFF`](https://docs.gorunner.io/errors#TOKEN_SURFACE_OFF) · [`403 FEATURE_OFF`](https://docs.gorunner.io/errors#FEATURE_OFF) · [`403 EMBED_NOT_ALLOWED`](https://docs.gorunner.io/errors#EMBED_NOT_ALLOWED) · [`403 EMBED_NOT_AVAILABLE`](https://docs.gorunner.io/errors#EMBED_NOT_AVAILABLE) · [`403 ACCOUNT_SUSPENDED`](https://docs.gorunner.io/errors#ACCOUNT_SUSPENDED) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`503 BUSY`](https://docs.gorunner.io/errors#BUSY) · [`503 PAUSED`](https://docs.gorunner.io/errors#PAUSED) · [`503 SERVICE_UNAVAILABLE`](https://docs.gorunner.io/errors#SERVICE_UNAVAILABLE). See [Errors](https://docs.gorunner.io/api/errors#by-status).

Request

**curl**

```bash
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…"  # needs Read for connections

curl "$GORUNNER/api/connections/usage" \
  -H "Authorization: Bearer $GORUNNER_TOKEN"
```

**JavaScript**

```js
const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;

const res = await fetch(
  `${GORUNNER}/api/connections/usage`,
  {
    headers: { Authorization: `Bearer ${TOKEN}` },
  },
);
const { data } = await res.json();
```

**Python**

```python
import os, requests

GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]

res = requests.get(
    f"{GORUNNER}/api/connections/usage",
    headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]
```

Response · 200 OK

```json
{
  "data": {
    "0f8b2c7e-4a51-4d3e-9b2a-6c1d2e3f4a5b": [
      {
        "id": "3b1e5c2a-7d4f-4e8b-a1c6-5f2d9b0e7a31",
        "name": "Order intake",
        "status": "active",
        "inLive": true,
        "inDraft": true
      }
    ]
  }
}
```

**Every field**

It takes no body.

### Response · 200 OK

- `data` · object: Reverse index: connection id → the workflows referencing it. A connection with no usage is ABSENT from the map rather than mapped to an empty array; treat a missing key as zero usage.
  - `{key}` · array of objects: Each key’s value.
    - `id` · UUID: The referencing workflow’s id.
    - `name` · string: The referencing workflow’s name.
    - `status` · string: The referencing workflow’s state. `active` is live, but only `inLive` says its production runs use the connection: a live workflow whose draft alone names it does not use it yet. One of `draft`, `active`, `paused`.
    - `inLive` · boolean: The workflow’s published version (what production runs) names the connection. False for a workflow never published.
    - `inDraft` · boolean: The workflow’s draft names the connection.

Related: [Move workflows to another connection](https://docs.gorunner.io/api/connections/replace-connection-references) · [Delete a connection](https://docs.gorunner.io/api/connections/delete-connection)

Source: https://docs.gorunner.io/api/connections/get-connection-usage
