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

# Generate session insights

> Trigger on-demand generation of session insights.

Returns ``already_exists`` if insights have already been generated.
Otherwise kicks off generation in the background. Poll the
GET insights endpoint to retrieve results once generation completes.

<Note>
  The `devin_id` is the session ID prefixed with `devin-` (e.g., `devin-abc123`).
</Note>

## Permissions

Requires a service user with the `ManageOrgSessions` permission at the organization level.

## Behavior

* If insights have already been generated (or generation is in progress), the endpoint returns `{ "status": "already_exists" }` without re-triggering.
* If no insights exist (or the last attempt failed), the endpoint triggers generation in the background and returns `{ "status": "started" }`.
* Poll the [GET session insights](/api-reference/v3/sessions/get-organizations-session-insights) endpoint to retrieve results once generation completes.


## OpenAPI

````yaml /v3-openapi.yaml POST /v3/organizations/{org_id}/sessions/{devin_id}/insights/generate
openapi: 3.1.0
info:
  description: Devin v3 API with Service User authentication and RBAC
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/organizations/{org_id}/sessions/{devin_id}/insights/generate:
    post:
      tags:
        - sessions
      summary: Generate session insights
      description: |-
        Trigger on-demand generation of session insights.

        Returns ``already_exists`` if insights have already been generated.
        Otherwise kicks off generation in the background. Poll the
        GET insights endpoint to retrieve results once generation completes.
      operationId: >-
        handle_generate_session_insights_v3_organizations__org_id__sessions__devin_id__insights_generate_post
      parameters:
        - description: 'Devin session ID (prefix: devin-)'
          in: path
          name: devin_id
          required: true
          schema:
            anyOf:
              - type: string
              - type: 'null'
            example: devin-abc123def456
            title: Devin Id
        - description: 'Organization ID (prefix: org-)'
          in: path
          name: org_id
          required: true
          schema:
            anyOf:
              - type: string
              - type: 'null'
            example: org-abc123def456
            title: Org Id
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionInsightsGenerateResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    SessionInsightsGenerateResponse:
      description: Response from triggering session insights generation.
      properties:
        session_id:
          description: The session ID for which insights generation was triggered.
          title: Session Id
          type: string
        status:
          description: The status of the generation request.
          title: Status
          type: string
      required:
        - session_id
        - status
      title: SessionInsightsGenerateResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      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: 'Service User credential (prefix: cog_)'
      scheme: bearer
      type: http

````