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

# セッションを作成

> 新しいセッションを作成します。

<div id="permissions">
  ## 権限
</div>

組織レベルで `ManageOrgSessions` 権限が付与されたサービスユーザーが必要です。

<div id="additional-permissions-for-advanced-features">
  ### 高度な機能用の追加権限
</div>

| 機能                  | 必要な権限                    |
| ------------------- | ------------------------ |
| `create_as_user_id` | `ImpersonateOrgSessions` |

<div id="devin-mode">
  ## Devin モード
</div>

`devin_mode` パラメータは、このセッションで使用する Devin のエージェントモードを制御します。

| Mode     | Description                            |
| -------- | -------------------------------------- |
| `normal` | デフォルトのエージェントモードです。高速で、長期的な計画立案に優れています。 |
| `fast`   | 約 2 倍高速で、コストは 4 倍、知能は同じです。             |

省略した場合、セッションでは組織のデフォルトモードが使用されます。高速モードには、Web アプリと同じ機能フラグおよび Enterprise のエージェントプレビューに関する制限が適用されます。

<div id="user-impersonation">
  ## ユーザーのなりすまし
</div>

`create_as_user_id` パラメータを使用すると、別のユーザーに代わってセッションを作成できます。これには以下が必要です:

1. サービスユーザーが `ImpersonateOrgSessions` 権限を持っていること
2. 対象ユーザーが組織のメンバーであること
3. 対象ユーザーが `UseDevinSessions` 権限を持っていること


## OpenAPI

````yaml ja/v3-openapi.yaml POST /v3/organizations/{org_id}/sessions
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/organizations/{org_id}/sessions:
    post:
      tags:
        - sessions
      summary: セッションを作成
      description: 新しいセッションを作成します。
      operationId: handle_create_session_v3_organizations__org_id__sessions_post
      parameters:
        - description: '組織 ID（接頭辞: org-）'
          in: path
          name: org_id
          required: true
          schema:
            anyOf:
              - type: string
              - type: 'null'
            example: org-abc123def456
            title: Org Id
        - in: query
          name: devin_id
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Devin Id
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionCreateRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionResponse'
          description: 成功レスポンス
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: バリデーションエラー
components:
  schemas:
    SessionCreateRequest:
      properties:
        attachment_urls:
          anyOf:
            - items:
                format: uri
                maxLength: 2083
                minLength: 1
                type: string
              type: array
            - type: 'null'
          title: Attachment Urls
        bypass_approval:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Bypass Approval
        child_playbook_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Child Playbook Id
        create_as_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Create As User Id
        devin_mode:
          anyOf:
            - enum:
                - normal
                - fast
                - lite
                - ultra
              type: string
            - type: 'null'
          description: >-
            セッションの Devin agent mode を上書きします。'normal' はデフォルトの Agent mode、'fast' は
            Fast mode、'lite' は Devin Lite、'ultra' は Devin Ultra
            を使用します。Fast、Lite、Ultra には、web app と同じ機能フラグおよび Enterprise agent
            preview の制限が適用されます。
          title: Devin Mode
        knowledge_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Knowledge Ids
        max_acu_limit:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Acu Limit
        platform:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            セッションのVMプラットフォームを上書きします（例: 'windows'）。省略した場合（または 'inherit'
            に設定した場合）、親Devin
            によって作成されたセッションは親のプラットフォームを継承し、それ以外の場合は組織のデフォルトが使用されます。値は組織に設定されているプラットフォームと一致している必要があります（大文字・小文字は区別されません）。認識されない値は、組織で利用可能なプラットフォームラベルをエラー本文に一覧表示した400エラーで拒否されます。
          title: Platform
        playbook_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Playbook Id
        prompt:
          title: Prompt
          type: string
        repos:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Repos
        resumable:
          default: true
          description: 停止後にセッションを再開できるよう、セッションの VM 状態を保持するかどうか。使い捨てセッションの場合は false に設定します。
          title: Resumable
          type: boolean
        secret_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Secret Ids
        session_links:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Session Links
        session_secrets:
          anyOf:
            - items:
                $ref: '#/components/schemas/SessionSecretInput'
              type: array
            - type: 'null'
          title: Session Secrets
        structured_output_required:
          anyOf:
            - type: boolean
            - type: 'null'
          description: >-
            true の場合（デフォルト）、agent は自分のターンが終了する前に is_final=true を指定して
            provide_structured_output を必ず呼び出す必要があります。false
            の場合、このツールは利用可能ですが必須ではなく、特定のターンで呼び出される保証はありません。
          title: Structured Output Required
        structured_output_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            構造化出力を検証するための JSON Schema（Draft 7）。最大 64KB。自己完結している必要があり（外部 $ref
            や外部参照は使用できません）。
          title: Structured Output Schema
        tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tags
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
      required:
        - prompt
      title: SessionCreateRequest
      type: object
    SessionResponse:
      properties:
        acus_consumed:
          title: Acus Consumed
          type: number
        category:
          anyOf:
            - enum:
                - bug_fixing
                - ci_cd_and_devops
                - code_quality_and_security
                - code_review
                - code_review_and_analysis
                - data_and_automation
                - documentation_and_content
                - feature_development
                - migrations_and_upgrades
                - other
                - refactoring_and_optimization
                - research_and_exploration
                - security
                - unit_test_generation
              type: string
            - type: 'null'
          description: 分類が実行されている場合の、セッションに割り当てられたユースケースカテゴリです。get/list エンドポイントでのみ設定されます。
          title: Category
        child_session_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Child Session Ids
        created_at:
          title: Created At
          type: integer
        is_archived:
          default: false
          title: Is Archived
          type: boolean
        org_id:
          title: Org Id
          type: string
        origin:
          anyOf:
            - enum:
                - webapp
                - slack
                - teams
                - api
                - linear
                - jira
                - automation
                - cli
                - desktop
                - code_scan
                - other
              type: string
            - type: 'null'
          description: セッションの作成元です。
          title: Origin
        parent_session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Session Id
        playbook_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Playbook Id
        pull_requests:
          items:
            $ref: '#/components/schemas/SessionPullRequest'
          title: Pull Requests
          type: array
        service_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Service User Id
        session_id:
          title: Session Id
          type: string
        status:
          enum:
            - new
            - claimed
            - running
            - exit
            - error
            - suspended
            - resuming
          title: Status
          type: string
        status_detail:
          anyOf:
            - enum:
                - working
                - waiting_for_user
                - waiting_for_approval
                - finished
                - inactivity
                - user_request
                - usage_limit_exceeded
                - out_of_credits
                - out_of_quota
                - no_quota_allocation
                - payment_declined
                - org_usage_limit_exceeded
                - total_session_limit_exceeded
                - error
              type: string
            - type: 'null'
          description: >-
            セッションの現在のステータスに関する追加情報です。status が 'running'
            の場合は、'working'（作業中）、'waiting_for_user'（ユーザー入力が必要）、'waiting_for_approval'（セーフモードでアクションの承認待ち）、または
            'finished'（タスク完了）です。status が 'suspended'
            の場合は、'inactivity'、'user_request'、'usage_limit_exceeded'、'out_of_credits'、'out_of_quota'、'no_quota_allocation'、'payment_declined'、'org_usage_limit_exceeded'、'total_session_limit_exceeded'、'error'
            などの一時停止理由です。get/list エンドポイントでのみ設定されます。
          title: Status Detail
        structured_output:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: セッションからの検証済み構造化出力。GET/list エンドポイントでのみ設定されます。
          title: Structured Output
        subcategory:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            セッションに割り当てられたサブカテゴリの表示名です。カテゴリが設定されていても、サブカテゴリが割り当てられていない、または特定されなかった場合は
            'Other' になります。get/list エンドポイントでのみ設定されます。
          title: Subcategory
        tags:
          items:
            type: string
          title: Tags
          type: array
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
        updated_at:
          title: Updated At
          type: integer
        url:
          title: Url
          type: string
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
      required:
        - session_id
        - url
        - status
        - tags
        - org_id
        - created_at
        - updated_at
        - acus_consumed
        - pull_requests
      title: SessionResponse
      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
    SessionPullRequest:
      properties:
        pr_state:
          anyOf:
            - type: string
            - type: 'null'
          title: Pr State
        pr_url:
          title: Pr Url
          type: string
      required:
        - pr_url
        - pr_state
      title: SessionPullRequest
      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: 'サービスユーザーの認証情報（接頭辞: cog_）'
      scheme: bearer
      type: http

````