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

# Deploy function

> Deploy a function to the serverless runtime platform asynchronously. Deployment happens in the background and may take 10-60 seconds.

You'll receive a 202 Accepted response immediately. To check deployment status:
1. Poll GET /functions/{id} to monitor status field
2. Wait for status to change from 'draft' to 'deployed' (success) or 'error' (failure)
3. Check last_deployed_at timestamp to confirm deployment completion

Deployment process:
- For `cloudflare_worker`: Code is deployed to Cloudflare's global edge network
- For `supabase_function`: Code is deployed to Supabase Edge Functions with Deno runtime

Deployment will fail (status='error') if:
- Function code has syntax errors
- Function type is 'supabase_function' but no Supabase project is configured
- Runtime platform API is unavailable

After successful deployment, the function is immediately available for invocation via POST /functions/{id}/invoke.




## OpenAPI

````yaml /api/platform/v1/openapi-workflows.yaml post /functions/{function_id}/deploy
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}/deploy:
    parameters:
      - name: function_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: Function identifier
    post:
      tags:
        - Functions
      summary: Deploy function
      description: >
        Deploy a function to the serverless runtime platform asynchronously.
        Deployment happens in the background and may take 10-60 seconds.


        You'll receive a 202 Accepted response immediately. To check deployment
        status:

        1. Poll GET /functions/{id} to monitor status field

        2. Wait for status to change from 'draft' to 'deployed' (success) or
        'error' (failure)

        3. Check last_deployed_at timestamp to confirm deployment completion


        Deployment process:

        - For `cloudflare_worker`: Code is deployed to Cloudflare's global edge
        network

        - For `supabase_function`: Code is deployed to Supabase Edge Functions
        with Deno runtime


        Deployment will fail (status='error') if:

        - Function code has syntax errors

        - Function type is 'supabase_function' but no Supabase project is
        configured

        - Runtime platform API is unavailable


        After successful deployment, the function is immediately available for
        invocation via POST /functions/{id}/invoke.
      operationId: deployFunction
      responses:
        '202':
          description: Deployment initiated successfully (processing in background)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionDeployResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          description: Function cannot be deployed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Supabase project required for Supabase functions
components:
  schemas:
    FunctionDeployResponse:
      type: object
      required:
        - message
        - function_id
        - status
      properties:
        message:
          type: string
          description: Deployment confirmation message
          example: Function deployment initiated
        function_id:
          type: string
          format: uuid
          description: ID of the function being deployed
        status:
          type: string
          description: Deployment status indicator
          example: deploying
      description: >
        Async deployment response (HTTP 202 Accepted). Deployment happens in the
        background and may take 10-60 seconds. Poll GET /functions/{id} to check
        when status changes from 'draft' to 'deployed' (or 'error' if deployment
        fails).
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
  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

````