# Connecting social accounts

Publishing to YouTube, TikTok, Instagram, Facebook, X, LinkedIn or Threads needs that platform's account connected to the team. Connecting always needs the account owner in a browser, because each platform asks them to sign in and approve on its own consent screen. An agent cannot do that step, but it can hand it over: a **connect link** is a URL the agent sends to its human, who opens it without logging in to Faceless.

## The flow

1. Create a link for the platform (scope `accounts:write`, by a key or OAuth grant of a team admin; API keys act as the team admin):

```bash
curl -X POST https://faceless.so/api/v1/accounts/connect-links \
  -H "Authorization: Bearer $FACELESS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: connect-youtube-1" \
  -d '{"platform":"youtube"}'
```

```json
{
	"success": true,
	"data": {
		"id": "665f1b2a9c31a2b3c4d5ef01",
		"platform": "youtube",
		"status": "pending",
		"url": "https://faceless.so/connect/Xq3v9cJ2kq0pN8sT1wYb5mF7aR4dL6hG2zE0uK9iP3o",
		"expiresAt": "2026-12-01T11:00:00.000Z",
		"accounts": [],
		"statusUrl": "/api/v1/accounts/connect-links/665f1b2a9c31a2b3c4d5ef01"
	}
}
```

2. Send `url` to your human and say which platform it is for. The page shows the workspace name and the platform, then the platform's own sign-in, then which account to connect (a Facebook sign-in can offer several Pages).

3. Poll `GET /accounts/connect-links/{id}` (scope `accounts:read`) every 5 to 10 seconds:

| status      | meaning                                                                    | what to do                                                             |
| ----------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `pending`   | not opened yet                                                             | keep polling, or remind your human                                     |
| `opened`    | they started signing in                                                    | keep polling                                                           |
| `connected` | done; `accounts` lists what was connected (`authId`, `label`, `isDefault`) | publish with that `authId`, or leave it out to use the default account |
| `failed`    | the last attempt did not finish (`error` says why)                         | they can open the same link again while it is valid                    |
| `expired`   | an hour passed with no connection                                          | create a new link                                                      |

The connected account also appears in `GET /accounts`.

## Rules

- A link works for **one hour** and connects **once**. After that, create a new one.
- The `url` is shown only when the link is made (`GET` returns `url: null`). Treat it like a password: anyone who opens it before it is used can connect their own account to the team.
- The link connects as the team admin who made it. A key or grant of a plain member gets `403 forbidden_scope`.
- Creating links is free and limited to 10 per 5 minutes per key.
- CLI: `faceless connect link youtube`, then `faceless connect status <id>`. MCP: `faceless_create_connect_link` and `faceless_get_connect_link`.

## When an account is missing

Publishing to a platform with no connected account answers `400` with next steps an agent can follow:

```json
{
	"success": false,
	"error": {
		"type": "invalid_input",
		"message": "No YouTube account is connected to this team. Create a connect link (POST /api/v1/accounts/connect-links) and send it to the account owner, then retry.",
		"code": "account_not_connected",
		"platform": "youtube",
		"actions": [
			{
				"id": "createConnectLink",
				"method": "POST",
				"href": "https://faceless.so/api/v1/accounts/connect-links",
				"body": { "platform": "youtube" },
				"scopes": ["accounts:write"],
				"mcpTool": "faceless_create_connect_link",
				"humanRequired": true
			},
			{ "id": "openAccountsPage", "href": "https://faceless.so/accounts", "humanRequired": true }
		]
	}
}
```

Scheduling a post (`POST /posts/schedule`) and creating or updating a series that posts to a platform with no account still succeed, because the account can be connected before anything is due, but the answer carries `data.warnings` with the same `code`, `platform` and `actions`.
