> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取当前用户信息

## 权限

无需任何权限。任何有效的 v3 凭据均可调用此端点来查询自身身份，包括服务用户、个人访问令牌 (PAT) 用户、Devin 会话和 Windsurf 会话。响应结构取决于调用方的 `principal_type` (`service_user`、`pat_user`、`devin_brain` 或 `windsurf_session`) 。


## OpenAPI

````yaml zh/v3-openapi.yaml GET /v3/self
openapi: 3.1.0
info:
  description: 采用 Service User 身份验证和 RBAC 的 Devin v3 API
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/self:
    get:
      tags:
        - self
      summary: 获取当前用户信息
      operationId: handle_get_self_v3_self_get
      responses:
        '200':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ServiceUserSelf'
                  - $ref: '#/components/schemas/PatUserSelf'
                  - $ref: '#/components/schemas/DevinBrainUserSelf'
                  - $ref: '#/components/schemas/WindsurfSessionUserSelf'
                title: Response Handle Get Self V3 Self Get
          description: 成功响应
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 未授权
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 禁止访问
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 未找到
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 冲突
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 已移除
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 无法处理的内容
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 请求过于频繁
components:
  schemas:
    ServiceUserSelf:
      description: 已认证服务用户的身份信息。
      properties:
        org_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Org Id
        principal_type:
          const: service_user
          title: Principal Type
          type: string
        service_user_id:
          title: Service User Id
          type: string
        service_user_name:
          title: Service User Name
          type: string
      required:
        - principal_type
        - service_user_id
        - service_user_name
      title: ServiceUserSelf
      type: object
    PatUserSelf:
      description: 已认证 PAT 用户的身份信息。
      properties:
        api_key_id:
          title: Api Key Id
          type: string
        api_key_name:
          title: Api Key Name
          type: string
        devin_sessions_org_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            调用者的 Devin Cloud 会话所在的组织：由 x-cog-org-id
            指定；未指定时，使用用户可见的第一个组织。无论哪种情况，该组织都必须允许用户使用 Devin
            会话，且不能是企业的主组织。不存在符合条件的组织时，为 Null。
          title: Devin Sessions Org Id
        org_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Org Id
        primary_billing_org_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            用户的 CLI 和 Desktop 用量计入的组织：账户所属的组织，或企业中用户的主要计费组织。如果不存在此组织，或用户无权在其中使用
            Devin 会话，则为 Null。
          title: Primary Billing Org Id
        principal_type:
          const: pat_user
          title: Principal Type
          type: string
        user_id:
          title: User Id
          type: string
        user_name:
          title: User Name
          type: string
      required:
        - principal_type
        - user_id
        - user_name
        - api_key_id
        - api_key_name
      title: PatUserSelf
      type: object
    DevinBrainUserSelf:
      description: 已通过身份验证的 Devin brain 会话的身份信息。
      properties:
        creator_service_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Creator Service User Id
        devin_id:
          title: Devin Id
          type: string
        org_id:
          title: Org Id
          type: string
        principal_type:
          const: devin_brain
          title: Principal Type
          type: string
        user_id:
          title: User Id
          type: string
      required:
        - principal_type
        - devin_id
        - org_id
        - user_id
      title: DevinBrainUserSelf
      type: object
    WindsurfSessionUserSelf:
      description: 已通过身份验证的 Windsurf 会话用户的身份信息。
      properties:
        devin_sessions_org_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            调用者的 Devin Cloud 会话所在的组织：由 x-cog-org-id
            指定的组织；若未指定，则为用户可见的第一个组织。无论哪种情况，该组织都必须允许用户使用 Devin
            会话，且不能是企业的主组织。没有符合条件的组织时为 Null。
          title: Devin Sessions Org Id
        org_id:
          title: Org Id
          type: string
        primary_billing_org_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            用户的 CLI 和 Desktop 用量计入的组织：账户所属的组织，或企业中用户的主要计费组织。如果不存在此组织，或用户无权在其中使用
            Devin 会话，则为 Null。
          title: Primary Billing Org Id
        principal_type:
          const: windsurf_session
          title: Principal Type
          type: string
        user_id:
          title: User Id
          type: string
        user_name:
          anyOf:
            - type: string
            - type: 'null'
          title: User Name
      required:
        - principal_type
        - user_id
        - org_id
      title: WindsurfSessionUserSelf
      type: object
    ProblemDetail:
      description: >-
        v3 API 的 RFC 9457 application/problem+json 错误响应体。


        detail 沿用自旧版 {"detail": ...} 响应体，以保持向后兼容；其他成员字段为新增字段。errors
        包含字段级验证失败信息（仅 422）。
      properties:
        detail:
          anyOf:
            - type: string
            - type: 'null'
          description: 针对此次具体情况的、便于人理解的说明。
          title: Detail
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          description: 因操作被阻止而拒绝请求时返回的机器可读代码（例如 "user_frozen"、"migrated_session"）。
          title: Error Code
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: 字段级验证错误（仅适用于 422 响应）。
          title: Errors
        instance:
          anyOf:
            - type: string
            - type: 'null'
          description: 此次出现对应的 URI 引用（请求路径）。
          title: Instance
        status:
          description: HTTP 状态码。
          title: Status
          type: integer
        title:
          description: 对问题类型的简短、便于理解的概述。
          title: Title
          type: string
        type:
          default: about:blank
          description: 用于标识问题类型的 URI 引用。
          title: Type
          type: string
      required:
        - title
        - status
      title: ProblemDetail
      type: object
  securitySchemes:
    bearerAuth:
      description: 服务用户凭据（前缀：cog_）
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.