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

# List function invocations

> Retrieve recent invocation history for a function, including console logs captured during execution.

Returns the most recent invocations (up to 20 by default) with:
- Request/response payloads
- Status codes and execution duration
- Console logs (info, warn, error messages)
- Error details for failed invocations

Use the `status` parameter to filter by success or failure.




## OpenAPI

````yaml /api/platform/v1/openapi-workflows.yaml get /functions/{function_id}/invocations
openapi: 3.1.0
info:
  title: Kapso Platform API – Advanced Resources
  version: 0.1.0
  description: >
    Build WhatsApp automation workflows and serverless functions. Create
    multi-step conversation flows, inspect executions, and deploy custom logic.
servers:
  - url: https://api.kapso.ai/platform/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Workflows
    description: Create and manage conversation workflows and executions
  - name: Workflow Triggers
    description: Configure workflow triggers to automate execution
  - name: Functions
    description: Manage serverless functions, deployments, and secrets
  - name: WhatsApp Conversations
    description: Query WhatsApp conversation data and related resources
paths:
  /functions/{function_id}/invocations:
    parameters:
      - name: function_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: Function identifier
    get:
      tags:
        - Functions
      summary: List function invocations
      description: >
        Retrieve recent invocation history for a function, including console
        logs captured during execution.


        Returns the most recent invocations (up to 20 by default) with:

        - Request/response payloads

        - Status codes and execution duration

        - Console logs (info, warn, error messages)

        - Error details for failed invocations


        Use the `status` parameter to filter by success or failure.
      operationId: listFunctionInvocations
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum:
              - success
              - failed
          description: |
            Filter by invocation status:
            - `success`: Status codes 200-299
            - `failed`: Status codes outside 200-299
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 20
            default: 10
          description: Maximum number of invocations to return (max 20)
      responses:
        '200':
          description: Invocations retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionInvocationsResponse'
              example:
                data:
                  function_id: 550e8400-e29b-41d4-a716-446655440000
                  function_name: calculate-shipping
                  invocations:
                    - id: 660e8400-e29b-41d4-a716-446655440001
                      status_code: 200
                      duration_ms: 45
                      request_body:
                        weight: 5.5
                        distance: 120
                      response_body:
                        cost: 24.75
                        currency: USD
                      error_message: null
                      created_at: '2025-01-15T10:30:00.000Z'
                      console_logs:
                        - level: info
                          message: Calculating shipping for weight 5.5
                          logged_at: '2025-01-15T10:30:00.000Z'
                    - id: 660e8400-e29b-41d4-a716-446655440002
                      status_code: 500
                      duration_ms: 12
                      request_body:
                        weight: -1
                      response_body: null
                      error_message: Invalid weight value
                      created_at: '2025-01-15T10:25:00.000Z'
                      console_logs:
                        - level: error
                          message: 'Invalid weight: -1'
                          logged_at: '2025-01-15T10:25:00.000Z'
                          stack: |-
                            Error: Invalid weight value
                                at validateWeight...
                  total: 2
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  schemas:
    FunctionInvocationsResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - function_id
            - function_name
            - invocations
            - total
          properties:
            function_id:
              type: string
              format: uuid
              description: Function identifier
            function_name:
              type: string
              description: Function display name
            invocations:
              type: array
              items:
                $ref: '#/components/schemas/FunctionInvocationDetail'
            total:
              type: integer
              description: Number of invocations returned
      description: Function invocations with console logs
    FunctionInvocationDetail:
      type: object
      required:
        - id
        - status_code
        - created_at
      properties:
        id:
          type: string
          format: uuid
          description: Invocation identifier
        status_code:
          type: integer
          description: HTTP status code returned by the function
        duration_ms:
          type:
            - integer
            - 'null'
          description: Execution duration in milliseconds
        request_body:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Request payload sent to the function
        response_body:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Response returned by the function
        error_message:
          type:
            - string
            - 'null'
          description: Error message if invocation failed
        created_at:
          type: string
          format: date-time
          description: Invocation timestamp
        console_logs:
          type: array
          description: Console logs captured during execution
          items:
            $ref: '#/components/schemas/FunctionConsoleLog'
      description: Single function invocation with execution details
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
    FunctionConsoleLog:
      type: object
      required:
        - level
        - message
        - logged_at
      properties:
        level:
          type: string
          description: Log level (info, warn, error, debug)
        message:
          type: string
          description: Log message content
        logged_at:
          type: string
          format: date-time
          description: Timestamp when the log was recorded
        stack:
          type:
            - string
            - 'null'
          description: Stack trace (if error)
      description: Console log entry from function execution
  responses:
    UnauthorizedError:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````