# Connections

Link a GitHub account to your organization, and attach it to a VM in one step so git, gh and the GitHub API work without a token in the VM.

Source: https://slashinfra.com/docs/platform/connections
Last modified: 2026-11-30T16:36:19.000Z

A connection links an outside account, such as GitHub, to your organization. Attach it to a VM with one `github` field: the VM sends requests without the token, and the key vault adds a token that lasts one hour, refreshed for you, only on GitHub’s hosts.

## Start a connection

Start returns the provider’s authorization URL. The connection exists only after you open that URL, sign in and approve; the URL is single use and expires after 10 minutes.

For GitHub, the URL opens the app’s install page. Choose the account and repositories that the VM must reach, then approve the install.

### Dashboard

- Open [Connections](https://app.slashinfra.com/svms/connections). 
- Select Add connection. The dashboard sends your browser to GitHub. 
- Sign in to GitHub and approve the install for the account and repositories the VM must reach. 
- GitHub returns you to the dashboard, which says `GitHub connected`.

You can also select Connect GitHub… in the GitHub field of a create form, a profile or a VM’s Security tab. The install opens in a new tab, and the field picks the new connection when you approve, so the form keeps what you entered.

### CLI

```bash
si org connection add github
```

Output

```text
https://github.com/apps/slashinfra/installations/new?state=...
waiting for the approval in the browser
connected github octo-org (conn_6f1c0f0e8a)
```

The command opens the URL and waits until you approve, for up to 10 minutes. With `--json` it prints the answer of the API at once and does not wait.

### curl

```bash
curl -sS -X POST "https://api.slashinfra.com/connections" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"provider":"github"}'
```

Output

```text
{"id":"conn_6f1c0f0e8a","authorize_url":"https://github.com/apps/slashinfra/installations/new?state=..."}
```

`id` is the id the connection gets when you approve. [`GET /connections/conn_6f1c0f0e8a`](https://slashinfra.com/docs/api-reference/control/connections#getConnectionsById) answers 404 `connection_not_found` until then, so a script polls it to know when the install finished.

### Python

```python
import os, requests

res = requests.post(
"https://api.slashinfra.com/connections",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"provider": "github"},
)
res.raise_for_status()
print(res.json()["authorize_url"])
```

Output

```text
https://github.com/apps/slashinfra/installations/new?state=...
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/connections', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ provider: 'github' }),
})
if (!res.ok) throw new Error(await res.text())
const { authorize_url: authorizeUrl } = (await res.json()) as {
authorize_url: string
}
console.log(authorizeUrl)
```

Output

```text
https://github.com/apps/slashinfra/installations/new?state=...
```

## List connections

List returns every connection of the organization, newest first. A connection has no name; its `conn_` id identifies it, and every answer carries the provider, account, status and creation time, never the token.

### Dashboard

- Open [Connections](https://app.slashinfra.com/svms/connections). 
- The table lists Provider, Account, Status and Actions for every connection. A connection in `error` shows Refresh failed.

The table does not show the `conn_` id. Use the CLI or the API when you need the id for a rule.

### CLI

```bash
si org connection ls
```

Output

```text
id               provider  account   status  created
conn_6f1c0f0e8a  github    octo-org  active  2026-11-29 14:17:51Z
```

### curl

```bash
curl -sS "https://api.slashinfra.com/connections" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
[{"id":"conn_6f1c0f0e8a","provider":"github","account":"octo-org","status":"active","created_ms":1795961796394}]
```

### Python

```python
import os, requests

res = requests.get(
"https://api.slashinfra.com/connections",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
for connection in res.json():
print(connection["id"], connection["provider"], connection["account"])
```

Output

```text
conn_6f1c0f0e8a github octo-org
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/connections', {
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const connections = (await res.json()) as {
id: string
provider: string
account: string
}[]
for (const connection of connections) console.log(connection.id, connection.provider, connection.account)
```

Output

```text
conn_6f1c0f0e8a github octo-org
```

## Get a connection

Get returns one connection, the rules that the `github` field adds for it, and the `env` that those rules need. You do not need them to attach a connection: send `github` instead, as in [Use a connection in a VM](https://slashinfra.com/docs/platform/connections#use-a-connection-in-a-vm). Get is for a client that writes its own rules.

### curl

```bash
curl -sS "https://api.slashinfra.com/connections/conn_6f1c0f0e8a" \
-H "Authorization: Bearer $SI_API_KEY" | python3 -m json.tool
```

Output

```text
{
"id": "conn_6f1c0f0e8a",
"provider": "github",
"account": "octo-org",
"status": "active",
"created_ms": 1795961796394,
"secret_id": "connection:conn_6f1c0f0e8a",
"secret_injections": [
{
"domain": "github.com",
"header": "authorization",
"secret_id": "connection:conn_6f1c0f0e8a",
"value_prefix": "",
"value_format": "basic_x_access_token"
},
{
"domain": "api.github.com",
"header": "authorization",
"secret_id": "connection:conn_6f1c0f0e8a",
"value_prefix": "Bearer ",
"value_format": "raw"
},
{
"domain": "uploads.github.com",
"header": "authorization",
"secret_id": "connection:conn_6f1c0f0e8a",
"value_prefix": "Bearer ",
"value_format": "raw"
},
{
"domain": "raw.githubusercontent.com",
"header": "authorization",
"secret_id": "connection:conn_6f1c0f0e8a",
"value_prefix": "Bearer ",
"value_format": "raw"
}
],
"env": {
"GH_TOKEN": "injected"
}
}
```

### Python

```python
import os, requests

res = requests.get(
"https://api.slashinfra.com/connections/conn_6f1c0f0e8a",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
connection = res.json()
print(connection["secret_id"])
for rule in connection["secret_injections"]:
print(rule["domain"], rule["value_format"])
```

Output

```text
connection:conn_6f1c0f0e8a
github.com basic_x_access_token
api.github.com raw
uploads.github.com raw
raw.githubusercontent.com raw
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/connections/conn_6f1c0f0e8a', {
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const connection = (await res.json()) as {
secret_id: string
secret_injections: { domain: string; value_format: string }[]
}
console.log(connection.secret_id)
for (const rule of connection.secret_injections) console.log(rule.domain, rule.value_format)
```

Output

```text
connection:conn_6f1c0f0e8a
github.com basic_x_access_token
api.github.com raw
uploads.github.com raw
raw.githubusercontent.com raw
```

## Use a connection in a VM

Send `github` with the connection id when you create a VM. The VM gets four rules, one for each GitHub host, and `GH_TOKEN=injected`, so `gh` sends a header that the vault replaces. An explicit `GH_TOKEN` in `env` is kept. The vault adds the token only for each rule’s exact host over HTTPS on port 443, so the VM never holds it. A connection is not in a project, so a VM of any project can use it.

A profile takes `github` the same way, and a VM created from that profile gets the connection. Send `"github": null` with the profile to create a VM without it.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms). 
- Select Create SVM. 
- Enter `repo-worker` in Name. 
- Choose `octo-org` in GitHub. 
- Select Create SVM.

### CLI

```bash
si create --name repo-worker --github
```

Output

```text
6f1c0f0e8a
```

`--github` without a value uses the organization’s only active GitHub connection. With several, name one by account or id: `--github octo-org`.

### curl

```bash
curl -sS -X POST "https://api.slashinfra.com/svms" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"name":"repo-worker","github":"conn_6f1c0f0e8a"}'
```

Output

```text
{"id":"6f1c0f0e8a","project":"proj_6f1c0f0e8a","url":"https://6f1c0f0e8a.slashinfra.dev/bin/bash","region":"eu-gra","expires_at":null,"generation":1,"labels":{}}
```

### Python

```python
import os, requests

res = requests.post(
"https://api.slashinfra.com/svms",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"name": "repo-worker", "github": "conn_6f1c0f0e8a"},
)
res.raise_for_status()
print(res.json()["id"])
```

Output

```text
6f1c0f0e8a
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'repo-worker', github: 'conn_6f1c0f0e8a' }),
})
if (!res.ok) throw new Error(await res.text())
const svm = (await res.json()) as { id: string }
console.log(svm.id)
```

Output

```text
6f1c0f0e8a
```

If the domain filter of the VM is on, add `github.com`, `api.github.com`, `uploads.github.com` and `raw.githubusercontent.com` to its allowed hosts: a rule never opens the filter. The dashboard lists each host the filter blocks, with an Allow button.

## Attach or remove on a running VM

Change an existing VM with `github` alone. Another connection replaces the GitHub rules, and `null` removes them and the `GH_TOKEN=injected` placeholder. Your other rules stay. The change applies at the next wake.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms). 
- Select `repo-worker`. 
- Open the Security tab. 
- Choose `octo-org` in GitHub to attach it, or None to remove it.

### CLI

```bash
si svm github repo-worker octo-org
si svm github repo-worker off
```

Output

```text
github octo-org (conn_6f1c0f0e8a)
github off
```

### curl

```bash
curl -sS -X PATCH "https://api.slashinfra.com/svms/repo-worker" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"github":"conn_6f1c0f0e8a"}'
```

Output

```text
{"id":"6f1c0f0e8a","project":"proj_6f1c0f0e8a","name":"repo-worker",...,"github":"conn_6f1c0f0e8a",...}
```

### Python

```python
import os, requests

res = requests.patch(
"https://api.slashinfra.com/svms/repo-worker",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"github": None},
)
res.raise_for_status()
print(res.json()["github"])
```

Output

```text
None
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/repo-worker', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ github: null }),
})
if (!res.ok) throw new Error(await res.text())
console.log(((await res.json()) as { github: string | null }).github)
```

Output

```text
null
```

A VM that already sends a secret to a GitHub host, such as the `github` preset with a personal access token, answers 400 `github_conflict`. Remove that rule first, then attach the connection.

## Delete a connection

Delete removes the connection and its tokens, and it cannot be undone. Delete answers 409 `connection_in_use` while a VM still has a rule, whether it is awake or asleep, so remove it from the VM (`si svm github repo-worker off`, or `"github": null`) or delete the VM first. A profile does not block the delete, but a VM created from a profile that names the deleted connection answers 400 `unknown_connection`.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms). 
- Select `repo-worker`. 
- Select Delete. 
- Enter `repo-worker` in Type repo-worker to confirm. 
- Select Delete SVM. 
- Open [Connections](https://app.slashinfra.com/svms/connections). 
- Select More actions on the GitHub row, then Delete. 
- Wait 5 seconds for the delete to run, or select Undo to keep the connection.

### CLI

```bash
si org connection rm conn_6f1c0f0e8a
```

Output

```text
error: This connection is in use. (connection_in_use)
```

Delete `repo-worker`, then run it again.

```bash
si rm repo-worker
si org connection rm conn_6f1c0f0e8a
```

Output

```text
deleted 6f1c0f0e8a
deleted connection conn_6f1c0f0e8a
```

### curl

The connection is still used by `repo-worker`:

```bash
curl -sS -i -X DELETE "https://api.slashinfra.com/connections/conn_6f1c0f0e8a" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
HTTP/1.1 409 Conflict
...
{"error":"This connection is in use.","code":"connection_in_use"}
```

Delete the VM, then the connection:

```bash
curl -sS -i -X DELETE "https://api.slashinfra.com/svms/6f1c0f0e8a" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
HTTP/1.1 204 No Content
...
```

```bash
curl -sS -i -X DELETE "https://api.slashinfra.com/connections/conn_6f1c0f0e8a" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
HTTP/1.1 204 No Content
...
```

### Python

```python
import os, requests

headers = {"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}
res = requests.delete("https://api.slashinfra.com/connections/conn_6f1c0f0e8a", headers=headers)
print(res.status_code, res.json()["code"])
res = requests.delete("https://api.slashinfra.com/svms/6f1c0f0e8a", headers=headers)
res.raise_for_status()
res = requests.delete("https://api.slashinfra.com/connections/conn_6f1c0f0e8a", headers=headers)
res.raise_for_status()
print(res.status_code)
```

Output

```text
409 connection_in_use
204
```

### TypeScript

```ts
const headers = { Authorization: `Bearer ${process.env.SI_API_KEY!}` }
const refused = await fetch('https://api.slashinfra.com/connections/conn_6f1c0f0e8a', {
method: 'DELETE',
headers,
})
console.log(refused.status, ((await refused.json()) as { code: string }).code)
const svm = await fetch('https://api.slashinfra.com/svms/6f1c0f0e8a', {
method: 'DELETE',
headers,
})
if (!svm.ok) throw new Error(await svm.text())
const res = await fetch('https://api.slashinfra.com/connections/conn_6f1c0f0e8a', {
method: 'DELETE',
headers,
})
if (!res.ok) throw new Error(await res.text())
console.log(res.status)
```

Output

```text
409 connection_in_use
204
```

## Options

| Field | Type | Default | Allowed values | What it changes |
| --- | --- | --- | --- | --- |   
| `provider` | string | Required | `github` | The provider whose account the connection links. | 
| `id` (path) | string | Required | A `conn_` id | The connection that get and delete act on. |

The `github` field of [`POST /svms`](https://slashinfra.com/docs/api-reference/control/svms#postSvms), [`PATCH /svms/:ref`](https://slashinfra.com/docs/api-reference/control/svms#patchSvmsByRef), [`POST /profiles`](https://slashinfra.com/docs/api-reference/control/profiles#postProfiles) and [`PUT /profiles/:ref`](https://slashinfra.com/docs/api-reference/control/profiles#putProfilesByRef):

| Field | Type | Default | Allowed values | What it changes |
| --- | --- | --- | --- | --- |   
| `github` | string or null | Keeps the stored one | A GitHub `conn_` id, or `null` | Attaches the connection’s four GitHub rules and `GH_TOKEN=injected`, or removes them for `null`. |

Every VM and profile answer carries `github`: the attached connection id, or `null`.

A connection has no update. To change the account or provider, delete the connection and start another.

## States

| State | What it means for you | What you can do |
| --- | --- | --- |   
| `active` | The token works. The vault refreshes it 10 minutes before it expires, and a VM with the rule gets the new value without a rule change. | Use the connection. Nothing else is needed. | 
| `error` | The last refresh failed. A token that has not expired still works; after expiry the rule injects nothing. | Wait for the retry. If it stays in error, fix the provider access, remove the rules, delete the connection and start again. |

The dashboard shows `active` as Active and `error` as Refresh failed.

## Errors

| Code | When | Fix |
| --- | --- | --- |   
| [`unknown_provider`](https://slashinfra.com/docs/reference/errors#unknown_provider) | Start names a provider other than `github`. | Use `github`. | 
| [`provider_unavailable`](https://slashinfra.com/docs/reference/errors#provider_unavailable) | Start names GitHub while the deployment has no GitHub App configured. | Ask the operator to configure the GitHub App. | 
| [`connection_failed`](https://slashinfra.com/docs/reference/errors#connection_failed) | The provider did not confirm the sign-in, or the token exchange failed. | Start again. | 
| [`connection_refused`](https://slashinfra.com/docs/reference/errors#connection_refused) | The sign-in at the provider was cancelled or refused. | Start again and approve the install. | 
| [`invalid_state`](https://slashinfra.com/docs/reference/errors#invalid_state) | The callback state expired, was already used, or the flow carried no code. | Start again and finish within 10 minutes. | 
| [`installation_unavailable`](https://slashinfra.com/docs/reference/errors#installation_unavailable) | The GitHub installation is not one the account that finished the flow can reach. | Choose an installation that the account can reach, or start again with another account. | 
| [`connection_not_found`](https://slashinfra.com/docs/reference/errors#connection_not_found) | Get or delete names no connection of your organization. | List the connections and use the id. | 
| [`connection_in_use`](https://slashinfra.com/docs/reference/errors#connection_in_use) | Delete runs while a VM still has a rule for the connection. | Remove the rule or delete the VM, then delete the connection. | 
| [`github_conflict`](https://slashinfra.com/docs/reference/errors#github_conflict) | `github` is sent while a secret rule already sends a credential to a GitHub host. | Remove that rule, then attach the connection. | 
| [`unknown_connection`](https://slashinfra.com/docs/reference/errors#unknown_connection) | A rule or `github` names a connection that does not exist or is not GitHub. | List the connections and use an existing id. |

Errors that any request can return are in the [error catalog](https://slashinfra.com/docs/reference/errors).

## Permissions

| Operation | Who can | Key action |
| --- | --- | --- |   
| Start a connection | Any member | `secret:write` | 
| List connections | Any member | `secret:read` | 
| Get a connection | Any member | `secret:read` | 
| Use a connection in a VM | Any member | `svm:write` | 
| Use a connection in a profile | Any member | `profile:write` | 
| Delete a connection | Any member | `secret:delete` |

## Limits

- An authorization URL works once and for 10 minutes. An expired or reused state answers 400 `invalid_state`. 
- The vault refreshes a token 10 minutes before it expires, and retries a failed refresh after 10 minutes. 
- A GitHub connection expands to four rules: `github.com`, `api.github.com`, `uploads.github.com` and `raw.githubusercontent.com`, plus `GH_TOKEN=injected` unless the VM sets `GH_TOKEN`. 
- A connection id is `conn_` and 10 letters and digits. 
- GitHub is the only provider you can connect.

The full list is in [Limits](https://slashinfra.com/docs/reference/limits).

## Next

- [Secrets](https://slashinfra.com/docs/platform/secrets): the rule fields, hosts and formats that a connection’s rules use. 
- [Open pull requests](https://slashinfra.com/docs/agents/pull-requests): clone a private repository and push a branch from a VM. 
- [Control API connections](https://slashinfra.com/docs/api-reference/control/connections): every operation, field and status code.
