# Connect an app

Connect an app such as Slack or Gmail to a project as an [integration](/docs/integrations.md), so your agents can use its tools.

## Before you start

You need an agent. See [Create an agent](/docs/agents/create-agent.md).

## Connect an app

**Studio**

1. In your project, open **Settings** > **Integrations**.
2. Click **Connect** beside Slack.
3. Under **Sharing**, keep **With my team**.
4. Under **Environments**, keep all three ticked.
5. Click **Connect**.
6. In the window that opens, sign in to Slack.
7. Allow Veryfront access.
8. Look under **Connected**. You should now see Slack listed with 1 connection.

**Code**

1. In the project's folder, look the app up:

```bash
npx veryfront integration list --search slack
```

2. Connect it, and allow Veryfront access in the browser that opens:

```bash
npx veryfront integration connect slack --scope project
```

3. Check its status:

```bash
npx veryfront integration status slack --scope project
```

4. Read the output. You should now see `"connected": true` for `slack`.

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. Start a connection to Slack for the project with your [API key](/docs/authentication/api-keys.md):

```bash
curl -X POST https://api.veryfront.com/projects/$PROJECT/integrations/slack/connect-sessions \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope": "project", "redirect_uri": "https://veryfront.com"}'
```

3. Open the `connect_url` from the response in a browser. It works once, for a few minutes.
4. Sign in to Slack and allow Veryfront access.
5. Check the connection. You should now see `"connected": true`:

```bash
curl "https://api.veryfront.com/projects/$PROJECT/integrations/slack/connection-status?scope=project" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

## Sign-in by app

| Sign-in | You give                               | Example      |
| ------- | -------------------------------------- | ------------ |
| OAuth   | A sign-in in your browser              | Slack, Gmail |
| API key | Environment variables, per environment | Algolia      |

* Some apps take your own OAuth app: set the variables its `byo_oauth_app_override` names.
* Mock mode (Zendesk and others): `PATCH /projects/<project ID>/integrations/zendesk` with `execution_mode` `mock`. Tools return sample data.

## Troubleshooting

**If the API answers "Invalid redirect URI"**, `redirect_uri` isn't a Veryfront address. Keep `https://veryfront.com`.

## With MCP

1. Call `veryfront__create_connect_session` with `{ "project_reference": "my-project", "name": "slack", "scope": "project", "redirect_uri": "https://veryfront.com" }`. Give the person the `connect_url` from the answer to open; it works once, for a few minutes.
2. After they sign in to Slack and allow access, call `veryfront__get_connection_status` with `{ "project_reference": "my-project", "name": "slack", "scope": "project" }`. It worked when the answer has `"connected": true`.

## Next steps

* [Add a tool](/docs/agents/tools.md)
* [Use integrations](/docs/mcp/integrations.md)
