<!-- https://cutedyno.com/docs/api/create-connect-session -->

# Create a connect session

`POST https://api.cutedyno.com/v1/connect/sessions`

Starts an OAuth flow for one profile and returns the URL to redirect your customer to.



Required permission: `connections:write`

Accepts `profileId` to target a specific profile. Omit it to use the key’s home profile.

Required permission: `connections:write`

Accepts an `Idempotency-Key` header.

## Body

- `platform` (enum, required) One of: facebook, instagram, tiktok, linkedin, youtube.
- `profileId` (string) — Profile to act on. Defaults to the profile the API key was created in.
- `redirectUrl` (string) — HTTPS URL to return the user to once they finish.

## Request

```bash
curl -X POST "https://api.cutedyno.com/v1/connect/sessions" \
  -H "Authorization: Bearer $CUTEDYNO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "profileId": "profile_a1b2c3d4",
  "platform": "facebook",
  "redirectUrl": "https://cdn.example.com/media/launch.jpg"
}'
```

```typescript
import { CuteDyno } from '@cutedyno/node';

const cutedyno = new CuteDyno();

const result = await cutedyno.accounts.connect({
  profileId: "profile_a1b2c3d4",
  platform: "facebook",
  redirectUrl: "https://cdn.example.com/media/launch.jpg"
});
console.log(result);
```

```python
import os
import requests

url = "https://api.cutedyno.com/v1/connect/sessions"
headers = {"Authorization": f"Bearer {os.environ['CUTEDYNO_API_KEY']}"}

payload = {
    "profileId": "profile_a1b2c3d4",
    "platform": "facebook",
    "redirectUrl": "https://cdn.example.com/media/launch.jpg"
}

response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
print(response.json())
```

## Response 201

- `authUrl` (string, required)
- `state` (string, required)
- `session` (ConnectSession, required)

```json
{
  "authUrl": "https://cdn.example.com/media/launch.jpg",
  "state": "string",
  "session": {
    "id": "a1b2c3d4-0000-4000-8000-000000000000",
    "platform": "facebook",
    "status": "pending",
    "authUrl": "https://cdn.example.com/media/launch.jpg",
    "url": "https://cdn.example.com/media/launch.jpg",
    "errorMessage": "Shipping today.",
    "createdAt": "string",
    "completedAt": "string",
    "expiresAt": "string"
  }
}
```

## Errors

- `invalid_request` (400) — The request body or query string failed validation. The message names the offending field.
- `invalid_api_key` (401) — The key does not exist, was revoked, or is malformed. Keys start with cdyn_live_.
- `profile_not_accessible` (403) — The requested profile is outside this key’s scope, or belongs to another account.
- `rate_limit_exceeded` (429) — Too many requests for this key. Honour the Retry-After header before retrying.
- `internal_error` (500) — Something failed on our side. Retry with the same Idempotency-Key; report the requestId if it persists.