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

# Crea sessione

> Crea una nuova sessione.

<div id="permissions">
  ## Autorizzazioni
</div>

Richiede un utente di servizio con l'autorizzazione `ManageOrgSessions` a livello di organizzazione.

<div id="additional-permissions-for-advanced-features">
  ### Autorizzazioni aggiuntive per funzionalità avanzate
</div>

| Funzionalità        | Autorizzazione richiesta |
| ------------------- | ------------------------ |
| `create_as_user_id` | `ImpersonateOrgSessions` |

<div id="devin-mode">
  ## Modalità Devin
</div>

Il parametro `devin_mode` controlla quale modalità Agent di Devin viene usata per la sessione:

| Modalità | Descrizione                                                                         |
| -------- | ----------------------------------------------------------------------------------- |
| `normal` | La modalità Agent predefinita. Veloce e adatta alla pianificazione a lungo termine. |
| `fast`   | \~2x più veloce, 4x più costosa, stessa intelligenza.                               |

Se omesso, la sessione usa la modalità predefinita dell'organizzazione. La modalità veloce è soggetta alle stesse restrizioni del feature flag e dell'anteprima degli agent Enterprise previste per l'app web.

<div id="user-impersonation">
  ## Impersonazione utente
</div>

Il parametro `create_as_user_id` consente di creare una sessione per conto di un altro utente. Questo richiede che:

1. L'utente di servizio abbia l'autorizzazione `ImpersonateOrgSessions`
2. L'utente di destinazione sia un membro dell'organizzazione
3. L'utente di destinazione abbia l'autorizzazione `UseDevinSessions`


## OpenAPI

````yaml it/v3-openapi.yaml POST /v3/organizations/{org_id}/sessions
openapi: 3.1.0
info:
  description: API Devin v3 con autenticazione utente di servizio e RBAC
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/organizations/{org_id}/sessions:
    post:
      tags:
        - sessions
      summary: Crea sessione
      description: Crea una nuova sessione.
      operationId: handle_create_session_v3_organizations__org_id__sessions_post
      parameters:
        - description: 'ID dell''organizzazione (prefisso: 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: Risposta con esito positivo
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Errore di validazione
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
                - fusion
              type: string
            - type: 'null'
          description: >-
            Applica un override alla modalità Agent di Devin per la sessione.
            'normal' usa la modalità Agent predefinita, 'fast' usa la modalità
            Fast, 'lite' usa Devin Lite, 'ultra' usa Devin Ultra e 'fusion' usa
            Fusion. Le modalità in anteprima sono soggette allo stesso flag di
            funzionalità e alle stesse restrizioni di anteprima dell'agente
            Enterprise della web app.
          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: >-
            Override della piattaforma VM per la sessione (ad es. 'windows'). Se
            omessa (o impostata su 'inherit'), una sessione creata da un Devin
            padre eredita la piattaforma del padre; altrimenti viene usata
            quella predefinita dell'organizzazione. Qualsiasi valore deve
            corrispondere a una piattaforma configurata per la tua
            organizzazione (senza distinzione tra maiuscole e minuscole); i
            valori non riconosciuti vengono rifiutati con un 400 il cui corpo
            dell'errore elenca le etichette delle piattaforme disponibili per
            l'org.
          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: >-
            Indica se preservare lo stato della VM della sessione dopo la sua
            interruzione, così da poterla riprendere. Impostare su false per le
            sessioni temporanee.
          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: >-
            Se true (predefinito), l'agente DEVE chiamare
            provide_structured_output con is_final=true prima della fine del suo
            turno. Se false, il tool è disponibile ma non obbligatorio: non è
            garantito che venga chiamato in un determinato turno.
          title: Structured Output Required
        structured_output_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            JSON Schema (Draft 7) per la convalida dell’output strutturato.
            Dimensione massima 64 KB. Deve essere autonomo (nessun $ref
            esterno).
          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: >-
            La categoria del caso d'uso assegnata alla sessione, se la
            categorizzazione è stata eseguita. Valorizzato solo negli endpoint
            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: L'origine da cui è stata creata la sessione.
          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: >-
            Ulteriore dettaglio sullo stato corrente della sessione. Quando
            status è 'running': 'working' (sta lavorando attivamente),
            'waiting_for_user' (richiede input dell'utente),
            'waiting_for_approval' (in attesa dell'approvazione di un'azione in
            modalità sicura) oppure 'finished' (attività completata). Quando
            status è 'suspended': il motivo della sospensione, ad esempio
            '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' oppure 'error'. Valorizzato solo
            negli endpoint get/list.
          title: Status Detail
        structured_output:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            Output strutturato convalidato dalla sessione. Impostato solo sugli
            endpoint GET/list.
          title: Structured Output
        subcategory:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Il nome visualizzato della sottocategoria assegnata alla sessione.
            'Other' quando è impostata una categoria ma non è stata assegnata né
            risolta alcuna sottocategoria. Valorizzato solo negli endpoint
            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: Modello di input per un secret di sessione fornito tramite 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: 'Credenziale dell''utente del servizio (prefisso: cog_)'
      scheme: bearer
      type: http

````