> ## 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.

> 创建一个新的 Devin 会话。可以选择性地指定快照 ID 和会话可见性等参数。

# 新建会话



## OpenAPI

````yaml zh/v1-openapi.yaml POST /v1/sessions
openapi: 3.1.0
info:
  description: Devin v1 API：个人 API key 与服务 API key
  title: Devin API v1
  version: 1.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v1/sessions:
    post:
      summary: 新建会话
      description: 根据指定的提示和配置选项创建一个新的 Devin 会话。
      operationId: create_session_endpoint_v1_sessions_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionParams'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSessionResponse'
          description: 成功响应
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: 验证错误
components:
  schemas:
    CreateSessionParams:
      properties:
        idempotent:
          default: false
          title: Idempotent
          type: boolean
        knowledge_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          description: 要使用的 Knowledge ID 列表。若为 None，则使用全部 Knowledge；若为空列表，则不使用任何 Knowledge。
          title: Knowledge Ids
        max_acu_limit:
          anyOf:
            - exclusiveMinimum: 0
              type: integer
            - type: 'null'
          description: ACU 最大值，必须为正数
          title: Max Acu Limit
        playbook_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Playbook Id
        prompt:
          title: Prompt
          type: string
        secret_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          description: 要使用的密钥 ID 列表。如果为 None，则表示使用所有密钥；如果为空列表，则表示不使用任何密钥。
          title: Secret Ids
        session_secrets:
          anyOf:
            - items:
                $ref: '#/components/schemas/SessionSecretInput'
              type: array
            - type: 'null'
          description: 要使用的会话专用机密列表。这些机密仅在当前会话中可用，不会存入组织机密中。
          title: Session Secrets
        snapshot_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Snapshot Id
        structured_output_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: 用于验证结构化输出的 JSON Schema（Draft 7），最大 64 KB。必须是自包含的（不得引用外部 $ref）。
          title: Structured Output Schema
        tags:
          anyOf:
            - items:
                type: string
              maxItems: 50
              type: array
            - type: 'null'
          description: 要添加到本次会话的标签列表。
          title: Tags
        title:
          anyOf:
            - type: string
            - type: 'null'
          description: 会话的自定义标题。如果为 None，则会自动生成标题。
          title: Title
        unlisted:
          default: false
          title: Unlisted
          type: boolean
      required:
        - prompt
      title: CreateSessionParams
      type: object
    CreateSessionResponse:
      description: 成功创建会话后返回的响应体。
      properties:
        is_new_session:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is New Session
        session_id:
          title: Session Id
          type: string
        url:
          title: Url
          type: string
      required:
        - session_id
        - url
      title: CreateSessionResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    SessionSecretInput:
      description: 用于通过 API 提供会话密钥的输入模型。
      properties:
        key:
          maxLength: 256
          minLength: 1
          title: Key
          type: string
        sensitive:
          default: true
          title: Sensitive
          type: boolean
        value:
          maxLength: 65536
          title: Value
          type: string
      required:
        - key
        - value
      title: SessionSecretInput
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    bearerAuth:
      description: 个人 API Key（apk_user_\*）或服务 API Key（apk_\*）
      scheme: bearer
      type: http

````