# 列出已连接账号

标准 URL： https://sosoapi.ai/zh-hans/docs/api/identity-api-user-social-accounts-list

契约：sha256:563d2d581da0ad29

列出工作区已连接的社交账号（Instagram、Threads、Facebook、YouTube），含连接健康状况和能力信息。排程或评论时，将其 id 用作 social_account_id。传入 workspace_id：强制明确指定目标后，缺少此字段的请求会被拒绝。

POST /identity-api/user/social-accounts/list

## 验证与权限

- **接受的凭证类别：** user_session、delegated_oauth、personal_access_token

- **委派能力：** agent:operate

- **最低工作区角色：** 此契约没有最低工作区角色要求；所有权和授权检查仍然适用。

- **访问范围：** 此用户获准访问的资源

- **需要所有工作区同意：** 否

- **变更状态：** 否

- **操作完成时：** synchronous_http_response

令牌只能使用其所有者持有的权利。每次请求会检查工作区成员资格、资源拥有权、所选工作区及已授予能力。core 与 full 配置只变更显示的工具，不会授予访问权限。

## 请求字段

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "include_authorization_grant": {
      "type": "boolean"
    }
  },
  "additionalProperties": false
}
```

## 响应与完成

成功 HTTP 状态：200

成功 HTTP 响应可能表示请求已接受，并非已完成。背景工作请存储返回 ID，持续检查同一操作直到完成。已排程或已接受的帖子，只有平台确认后才算已发布；客户端逾时无法证明结果。

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "accounts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "platform": {
            "type": "string",
            "enum": [
              "instagram",
              "threads",
              "facebook",
              "tiktok",
              "linkedin",
              "youtube",
              "x"
            ]
          },
          "handle": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "valid",
              "expiring_soon",
              "expired",
              "disconnected"
            ]
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string"
          },
          "avatar_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "follower_count": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "post_count": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "auto_sync_enabled": {
            "type": "boolean"
          },
          "last_synced_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "workspace_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "platform_user_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "instagram_login_mode": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "instagram_login",
                  "facebook_login"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "facebook_page_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "blocked_until": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "block_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "transient",
                  "account_block",
                  "auth_invalid",
                  "permanent"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "block_subcode": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "block_count": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "last_block_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "health_state": {
            "type": "string",
            "enum": [
              "ready",
              "action_required",
              "temporarily_unavailable",
              "publishing_restricted",
              "disconnected",
              "unknown"
            ]
          },
          "health_message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "health_observed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "authorization_grant": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "granted_permissions": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "inventory_source": {
                    "type": "string",
                    "enum": [
                      "oauth_token_response",
                      "provider_token_debug",
                      "provider_permissions_endpoint"
                    ]
                  },
                  "inventory_exact": {
                    "type": "boolean",
                    "const": true
                  },
                  "observed_at": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provider_api_version": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  },
                  "oauth_provider": {
                    "type": "string",
                    "enum": [
                      "instagram",
                      "threads",
                      "meta",
                      "google"
                    ]
                  },
                  "oauth_subject_id": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "granted_permissions",
                  "inventory_source",
                  "inventory_exact",
                  "observed_at",
                  "provider_api_version",
                  "oauth_provider",
                  "oauth_subject_id"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "granted_permissions": {
                    "minItems": 0,
                    "maxItems": 0,
                    "type": "array",
                    "items": {
                      "not": {}
                    }
                  },
                  "inventory_source": {
                    "type": "string",
                    "const": "unavailable"
                  },
                  "inventory_exact": {
                    "type": "boolean",
                    "const": false
                  },
                  "observed_at": {
                    "type": "null"
                  },
                  "provider_api_version": {
                    "type": "null"
                  },
                  "oauth_provider": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "instagram",
                          "threads",
                          "meta",
                          "google"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "oauth_subject_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "granted_permissions",
                  "inventory_source",
                  "inventory_exact",
                  "observed_at",
                  "provider_api_version",
                  "oauth_provider",
                  "oauth_subject_id"
                ]
              }
            ]
          },
          "current_capability_snapshot_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "capability_facts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "capability": {
                  "type": "string",
                  "enum": [
                    "can_publish_text",
                    "can_publish_image",
                    "can_publish_video",
                    "can_publish_reel",
                    "can_publish_carousel",
                    "can_publish_first_comment",
                    "can_publish_topic_tag",
                    "can_publish_link",
                    "can_upload_video",
                    "can_set_title",
                    "can_set_description",
                    "can_set_thumbnail",
                    "can_set_privacy_status",
                    "can_publish_story",
                    "can_invite_collaborators",
                    "can_tag_products",
                    "can_publish_trial_reel",
                    "can_publish_partnership",
                    "can_delete_media",
                    "can_publish_reply",
                    "can_quote_post",
                    "can_repost",
                    "can_publish_poll",
                    "can_publish_gif",
                    "can_publish_text_attachment",
                    "can_publish_ghost_post",
                    "can_tag_location",
                    "can_crossshare_to_instagram",
                    "can_auto_publish_text",
                    "can_delete_post",
                    "can_publish_multi_image",
                    "can_target_post",
                    "can_backdate_post",
                    "can_manage_native_schedule",
                    "can_update_video",
                    "can_delete_video",
                    "can_set_brand_partner"
                  ]
                },
                "observed_allowed": {
                  "anyOf": [
                    {
                      "type": "boolean"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "availability": {
                  "type": "string",
                  "enum": [
                    "available",
                    "unavailable",
                    "unknown",
                    "documented_ambiguous"
                  ]
                },
                "reason_code": {
                  "type": "string",
                  "pattern": "^[a-z0-9_]+$"
                },
                "observed_at": {
                  "type": "string"
                },
                "valid_until": {
                  "type": "string"
                },
                "provider_api_version": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 40
                },
                "required_permissions": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "granted_permissions": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "account_eligibility": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                }
              },
              "required": [
                "capability",
                "observed_allowed",
                "availability",
                "reason_code",
                "observed_at",
                "valid_until",
                "provider_api_version",
                "required_permissions",
                "granted_permissions",
                "account_eligibility"
              ]
            }
          }
        },
        "required": [
          "id",
          "platform",
          "handle",
          "status",
          "expires_at",
          "created_at",
          "health_state",
          "health_message",
          "health_observed_at",
          "current_capability_snapshot_id",
          "capability_facts"
        ]
      }
    }
  },
  "required": [
    "accounts"
  ]
}
```

## 错误与安全重试

检查 HTTP 状态和响应正文。400 验证错误可能包含 ZodError；处理程序错误使用 error、message 和 code 字段。保留 request_id 或 x-request-id 以便诊断，但不要保留凭证。先解决 401/403 访问错误再重试，并在收到 429 时遵循 Retry-After。如写入结果不确定或返回 5xx，先读取现有结果。仅在支持时复用幂等键；重试行为因操作而异，并不保证恰好交付一次。

## 示例

这些示例使用已依schema检查的虚构值。请将 ID 替换为你有权使用的 ID、将媒体替换为已就绪素材，并将日期替换为已确认的发布时间。提交写入前，请检查账号资格。本页不会发送 API 请求。

在服务器上将 SOSOAPI_ACCESS_TOKEN 设为此操作接受的凭证，且不要放入浏览器代码。agent 请使用 sosoapi auth login 通过浏览器登录，并由 CLI 更新凭证。

request.json

```json
{}
```

cURL

```bash
curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/user/social-accounts/list" \
  -H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json
```

JavaScript

```js
// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/user/social-accounts/list", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.
```

CLI

```bash
npx sosoapi api post /identity-api/user/social-accounts/list < request.json
```

合成响应示例

```json
{
  "accounts": []
}
```

## 相关工具与指南

MCP：sosoapi_list_connected_accounts

[API 参考](https://sosoapi.ai/zh-hans/docs/api)
