# POST /start_channel_connect

Source: https://heyeveryone.ai/docs/api/start_channel_connect

> https://heyeveryone.ai/api/v1/start_channel_connect

## Operation

```json
{
  "post": {
    "description": "Start connecting a social account to a workspace. For OAuth platforms it returns an authorizeUrl: a person opens it in their browser, signed in to heyeveryone as the same account, and approves access on the platform; the account then appears in list_channel_accounts. The link works once and expires after 15 minutes. For Bluesky it returns the fields (handle and an app password) a person enters in heyeveryone. Fails with not_configured when heyeveryone has no app credentials for that platform here. For test accounts use connect_sandbox_account. Platforms that sign in separately per account type take `accountType` (get_channel_capabilities lists them as connectChoices). LinkedIn: 'profile' (a personal profile, the default) or 'page' (company pages the person administers; not_configured until LinkedIn has approved company pages for heyeveryone here). Leave accountType out on every other platform.",
    "operationId": "start_channel_connect",
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "workspaceId": {
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                "type": "string"
              },
              "platform": {
                "enum": [
                  "x",
                  "linkedin",
                  "threads",
                  "bluesky",
                  "instagram",
                  "facebook",
                  "tiktok",
                  "youtube",
                  "sandbox"
                ],
                "type": "string"
              },
              "returnTo": {
                "maxLength": 500,
                "pattern": "^\\/(?!\\/)[^\\s\\\\]*$",
                "type": "string"
              },
              "accountType": {
                "pattern": "^[a-z][a-z_]{0,30}$",
                "type": "string"
              }
            },
            "required": [
              "workspaceId",
              "platform"
            ],
            "type": "object"
          }
        }
      },
      "required": true
    },
    "responses": {
      "200": {
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "additionalProperties": false,
                  "properties": {
                    "kind": {
                      "const": "oauth2",
                      "type": "string"
                    },
                    "authorizeUrl": {
                      "format": "uri",
                      "type": "string"
                    },
                    "expiresAt": {
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                      "type": "string"
                    }
                  },
                  "required": [
                    "kind",
                    "authorizeUrl",
                    "expiresAt"
                  ],
                  "type": "object"
                },
                {
                  "additionalProperties": false,
                  "properties": {
                    "kind": {
                      "const": "credentials",
                      "type": "string"
                    },
                    "fields": {
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "secret": {
                            "type": "boolean"
                          },
                          "help": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "key",
                          "label",
                          "secret",
                          "help"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "kind",
                    "fields"
                  ],
                  "type": "object"
                }
              ]
            }
          }
        },
        "description": "Success"
      },
      "400": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "invalid_input: the body does not match the schema"
      },
      "401": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "unauthenticated: missing, invalid, expired or revoked token"
      },
      "403": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "forbidden: the agent may not do this (for example, another workspace)"
      },
      "404": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "not_found"
      },
      "409": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "conflict"
      },
      "422": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "Service-specific errors: not_configured, use_sandbox, connect_failed"
      },
      "429": {
        "$ref": "#/components/responses/RateLimited"
      },
      "500": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "internal_error"
      }
    },
    "summary": "Start connecting a channel",
    "tags": [
      "workspace"
    ],
    "x-heyeveryone-kind": "mutation"
  }
}
```

## Referenced definitions

```json
{
  "schemas": {
    "Error": {
      "properties": {
        "error": {
          "description": "A stable error code, for example forbidden.",
          "type": "string"
        },
        "message": {
          "description": "What went wrong, in plain words.",
          "type": "string"
        }
      },
      "required": [
        "error",
        "message"
      ],
      "type": "object"
    }
  },
  "responses": {
    "RateLimited": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "description": "rate_limited: too many requests from this agent, account or address (docs/setup/agents.md, Rate limits); wait the Retry-After seconds, then retry",
      "headers": {
        "Retry-After": {
          "description": "Seconds to wait before retrying.",
          "schema": {
            "minimum": 1,
            "type": "integer"
          }
        }
      }
    }
  }
}
```

## Authentication

```json
{
  "bearer": {
    "description": "Personal access token (hey_pat_...)",
    "scheme": "bearer",
    "type": "http"
  },
  "oauth": {
    "flows": {
      "authorizationCode": {
        "authorizationUrl": "https://heyeveryone.ai/oauth/authorize",
        "refreshUrl": "https://heyeveryone.ai/oauth/token",
        "scopes": {
          "agent": "Act as your agent in the workspaces you choose"
        },
        "tokenUrl": "https://heyeveryone.ai/oauth/token"
      }
    },
    "type": "oauth2"
  }
}
```

## Security requirements

```json
[
  {
    "bearer": []
  },
  {
    "oauth": [
      "agent"
    ]
  }
]
```
