# Link an account

> Connect a LinkedIn account to your workspace with a hosted link.

Before you can call any method, a LinkedIn account has to be **linked** to your workspace. The simplest and most reliable way is a **hosted connection link**: you create a link, send your user to it, and CorrectInbox walks them through connecting. You never handle their credentials.

## Create a hosted link

```http
POST /v1/accounts/link
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `provider` | string | yes | The provider to connect. Use `LINKEDIN`. |
| `success_redirect_url` | string | no | Where to send the user after they connect. |
| `failure_redirect_url` | string | no | Where to send the user if they cancel or it fails. |
| `name` | string | no | A label to help you recognise the account later. |

```bash
curl -X POST https://api.correctinbox.com/v1/accounts/link \
  -H "X-API-KEY: $CORRECTINBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "LINKEDIN",
    "success_redirect_url": "https://yourapp.com/connected",
    "name": "Sales seat 1"
  }'
```

```js
const res = await fetch("https://api.correctinbox.com/v1/accounts/link", {
  method: "POST",
  headers: {
    "X-API-KEY": process.env.CORRECTINBOX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    provider: "LINKEDIN",
    success_redirect_url: "https://yourapp.com/connected",
    name: "Sales seat 1",
  }),
});
const { url } = await res.json();
```

```python
res = requests.post(
    "https://api.correctinbox.com/v1/accounts/link",
    headers={"X-API-KEY": os.environ["CORRECTINBOX_API_KEY"]},
    json={
        "provider": "LINKEDIN",
        "success_redirect_url": "https://yourapp.com/connected",
        "name": "Sales seat 1",
    },
)
url = res.json()["url"]
```

**Response**

```json
{
  "object": "account_link",
  "url": "https://connect.correctinbox.com/s/lnk_3kd9f2",
  "expires_at": "2026-02-01T10:12:00Z"
}
```

Redirect your user to `url`. The link is single‑use and expires. When the user finishes, the account becomes `connected` and (if you listen) a [`account.connected` webhook](/webhooks) fires.

## Confirming the link

Linking succeeds the moment the account is operational. Poll the account or listen for the webhook rather than assuming success from the redirect alone:

```bash
curl https://api.correctinbox.com/v1/accounts \
  -H "X-API-KEY: $CORRECTINBOX_API_KEY"
```

A freshly linked account starts in `connected` status. New provider accounts sometimes have limited access to actions like search until they are more established on the platform — see [Connection status](/connection-status).
