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

# Deploy function

> Publish the function. If `sourceCode` or `dependencies` are provided in the body, they replace the current draft before deployment. Returns immediately with a deployment ID — poll `GET /v1/functions/deployments/{deploymentId}` until status is `active` or `failed`.



## OpenAPI

````yaml /openapi.json post /v1/functions/{functionId}/deploy
openapi: 3.0.3
info:
  title: Zavu Unified Messaging Layer API
  version: 0.2.0
  description: >
    Unified multi-channel messaging API for Zavu.


    Supported channels:

    - **SMS**: Simple text messages

    - **WhatsApp**: Rich messaging with media, buttons, lists, CTA URL buttons,
    and templates

    - **Telegram**: Bot messaging with text, media, and interactive elements

    - **Email**: Transactional emails via Amazon SES


    Design goals:

    - Simple `send()` entrypoint for developers

    - Project-level authentication via Bearer token

    - Support for all WhatsApp message types (text, image, video, audio,
    document, sticker, location, contact, buttons, list, cta_url, reaction,
    template)

    - If a non-text message type is sent, WhatsApp channel is used automatically

    - 24-hour WhatsApp conversation window enforcement

    - Universal `to` field accepts phone numbers (E.164), email addresses, or
    numeric chat IDs (Telegram/Instagram)
servers:
  - url: https://api.zavu.dev
security:
  - bearerAuth: []
paths:
  /v1/functions/{functionId}/deploy:
    post:
      tags:
        - Functions
      summary: Deploy function
      description: >-
        Publish the function. If `sourceCode` or `dependencies` are provided in
        the body, they replace the current draft before deployment. Returns
        immediately with a deployment ID — poll `GET
        /v1/functions/deployments/{deploymentId}` until status is `active` or
        `failed`.
      operationId: deployFunction
      parameters:
        - $ref: '#/components/parameters/FunctionIdParam'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FunctionDeployRequest'
      responses:
        '202':
          description: Deployment queued.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionDeploymentResponse'
        '400':
          description: Invalid request or function in a non-deployable state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Function not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    FunctionIdParam:
      name: functionId
      in: path
      required: true
      description: Zavu Function ID.
      schema:
        type: string
  schemas:
    FunctionDeployRequest:
      type: object
      description: >-
        Optional source/dependencies update applied before deploying. Omit both
        fields to redeploy the current draft as-is.
      properties:
        sourceCode:
          type: string
          description: New source code to publish (replaces the draft).
          maxLength: 900000
        dependencies:
          type: object
          additionalProperties:
            type: string
          description: New dependency map (replaces existing dependencies).
    FunctionDeploymentResponse:
      type: object
      required:
        - deployment
      properties:
        deployment:
          $ref: '#/components/schemas/FunctionDeployment'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: invalid_request
        message:
          type: string
          example: Phone number is invalid
        details:
          type: object
          additionalProperties: true
    FunctionDeployment:
      type: object
      required:
        - id
        - functionId
        - version
        - status
        - createdAt
      properties:
        id:
          type: string
          example: fnd_abc123
        functionId:
          type: string
        version:
          type: integer
          description: Monotonically increasing deployment version, starting at 1.
        status:
          $ref: '#/components/schemas/FunctionDeploymentStatus'
        sourceCodeBytes:
          type: integer
          nullable: true
        bundleBytes:
          type: integer
          nullable: true
        errorMessage:
          type: string
          nullable: true
          description: Failure reason when status is 'failed'.
        deployedAt:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
    FunctionDeploymentStatus:
      type: string
      description: Stage of a function deployment.
      enum:
        - pending
        - bundling
        - uploading
        - publishing
        - active
        - failed
        - superseded
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````