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

# Redeploy a backend function

> <Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Deploys the code you send as one of the app's backend functions and saves it as that function's source, the same way **Save & Redeploy** does in the builder's code editor.

The function is deployed from the `code` in the request, not from the source already stored in the app. To redeploy a function unchanged, send its current source. The deploy runs even when the code is identical, which is how you recover a function whose deployment is missing or out of date. A name that no function has yet creates a new function.

The request waits for the deploy to finish, and fails with the compiler's diagnostics when the code doesn't build. An app runs one deploy at a time. If another deploy for the app is still running after a short wait, the call is rejected and is safe to retry.

Backend functions need a Builder plan or higher on the app's workspace. If the app has no backend functions yet, the first redeploy sets them up.

The deploy always lands on the app's main line, and is rejected while main is protected.

This is limited to 50 requests a minute per caller for each app. Some workspaces have a different limit.

The response is the app document as it stands after the change, the same shape [Get app](/api-reference/get-app) returns.

<Note>This endpoint accepts a personal API key belonging to a user with editor access to the app. A read-only key is refused, and workspace API keys are not accepted.</Note>

<Warning>The response includes fields beyond the ones documented here. Don't rely on undocumented response fields, as they can change at any time. Send only the fields documented here. Other request fields are not supported and their behavior can change.</Warning>



## OpenAPI

````yaml /developers/references/app-management/app-management-openapi.json post /api/apps/{app_id}/coding/redeploy-function/{function_name}
openapi: 3.1.0
info:
  title: Base44 App Management API
  version: 1.0.0
servers:
  - url: https://app.base44.com
security:
  - PersonalAccessTokenAuth: []
paths:
  /api/apps/{app_id}/coding/redeploy-function/{function_name}:
    post:
      summary: Redeploy a backend function
      description: >-
        <Info>This API is in beta. Endpoints, fields, and behavior may still
        change, so avoid depending on it in production.</Info>


        Deploys the code you send as one of the app's backend functions and
        saves it as that function's source, the same way **Save & Redeploy**
        does in the builder's code editor.


        The function is deployed from the `code` in the request, not from the
        source already stored in the app. To redeploy a function unchanged, send
        its current source. The deploy runs even when the code is identical,
        which is how you recover a function whose deployment is missing or out
        of date. A name that no function has yet creates a new function.


        The request waits for the deploy to finish, and fails with the
        compiler's diagnostics when the code doesn't build. An app runs one
        deploy at a time. If another deploy for the app is still running after a
        short wait, the call is rejected and is safe to retry.


        Backend functions need a Builder plan or higher on the app's workspace.
        If the app has no backend functions yet, the first redeploy sets them
        up.


        The deploy always lands on the app's main line, and is rejected while
        main is protected.


        This is limited to 50 requests a minute per caller for each app. Some
        workspaces have a different limit.


        The response is the app document as it stands after the change, the same
        shape [Get app](/api-reference/get-app) returns.


        <Note>This endpoint accepts a personal API key belonging to a user with
        editor access to the app. A read-only key is refused, and workspace API
        keys are not accepted.</Note>


        <Warning>The response includes fields beyond the ones documented here.
        Don't rely on undocumented response fields, as they can change at any
        time. Send only the fields documented here. Other request fields are not
        supported and their behavior can change.</Warning>
      operationId: >-
        redeploy_function_api_apps__app_id__coding_redeploy_function__function_name__post
      parameters:
        - name: function_name
          in: path
          required: true
          schema:
            type: string
            description: >-
              Name of the backend function, as a path under `functions/`. Send
              the bare name, the name with its file extension, or the name
              followed by `/entry.ts`. Nested functions have slashes in their
              name, and you send those as they are.
            title: Function Name
          description: >-
            Name of the backend function, as a path under `functions/`. Send the
            bare name, the name with its file extension, or the name followed by
            `/entry.ts`. Nested functions have slashes in their name, and you
            send those as they are.
          example: sendWelcomeEmail
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            description: ID of the app whose code to change.
            title: App Id
          description: ID of the app whose code to change.
          example: 6820f3a4e7b91d003c45a1f2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              title: RedeployBackendFunction
              type: object
              required:
                - code
              properties:
                code:
                  type: string
                  description: Full source of the function to deploy and save.
                  example: |
                    Deno.serve(async (req) => {
                      return Response.json({ ok: true });
                    });
            example:
              code: |
                Deno.serve(async (req) => {
                  return Response.json({ ok: true });
                });
      responses:
        '200':
          description: The app after the deploy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppSummary'
        '400':
          description: >-
            `function_name` is empty, isn't a valid function name, or points at
            one of the app's frontend files instead of a backend function.
        '401':
          description: Missing or invalid credentials.
        '403':
          description: >-
            You don't have editor access to this app, your API key is read-only,
            or you used a workspace API key. Backend functions also need a
            Builder plan or higher on the app's workspace.
        '404':
          description: App not found.
        '409':
          description: >-
            The app's main line is protected, the app moved to another workspace
            during the deploy, or another deploy for the app is still running.
        '422':
          description: >-
            The body has no `code`, or the code was rejected or failed to build.
            A build failure carries the compiler diagnostics in the detail.
        '429':
          description: Too many redeploys for this app from you in the last minute.
components:
  schemas:
    AppSummary:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: ID of the app.
          example: 6820f3a4e7b91d003c45a1f2
        first_prompt_model_comparison:
          anyOf:
            - $ref: '#/components/schemas/FirstPromptModelComparisonPublicState'
            - type: 'null'
          description: >-
            Accepted first-prompt model comparison, including its durable
            comparison ID.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Display name of the app.
          example: My CRM
        slug:
          anyOf:
            - type: string
            - type: 'null'
          title: Slug
          description: >-
            URL slug for the app, auto generated from the name and app ID or set
            to a custom value, or `null` if the app has no slug yet. The
            published URL is built from it.
          example: my-crm-3c45a1f2
        user_description:
          anyOf:
            - type: string
            - type: 'null'
          title: User Description
          description: >-
            Description of the app, or `null` if none was set. An app created
            without a `name` gets a generated description once a build turn
            changes it.
          example: A CRM to track leads and deals
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
          description: Email of the user who created the app.
          example: developer@example.com
        created_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created Date
          description: Time the app was created, as a UTC timestamp in ISO 8601 format.
          example: '2026-08-01T09:15:00'
        updated_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated Date
          description: >-
            Time the app document was last written, as a UTC timestamp in ISO
            8601 format.
          example: '2026-08-02T14:30:00'
        status:
          anyOf:
            - $ref: '#/components/schemas/AppStatusResponse'
            - type: 'null'
          description: >-
            The app's current build status. Poll while a build is in progress to
            watch it finish. This tracks building, not publishing.
        last_deployed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Deployed At
          description: >-
            Time the app was last published, as a UTC timestamp in ISO 8601
            format, or `null` if it has never been published.
          example: '2026-08-02T14:30:00'
        screenshot_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Screenshot Url
          description: >-
            URL of a screenshot of the published app. Captured shortly after
            each publish, so it can briefly lag or be `null` right after
            publishing.
          example: https://storage.base44.com/screenshots/6820f3a4e7b91d003c45a1f2.png
        preview_screenshot_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Preview Screenshot Url
          description: >-
            URL of a preview screenshot taken before publishing, distinct from
            `screenshot_url`, or `null` if none has been captured.
          example: https://storage.base44.com/previews/6820f3a4e7b91d003c45a1f2.png
        main_branch_protected:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Main Branch Protected
          description: >-
            Whether the app's main branch is protected, so changes to main must
            go through a branch that's merged back. Change it with [Set main
            branch protection](/api-reference/set-main-branch-protection).
          example: false
      type: object
      title: AppSummary
      description: An app in a workspace, limited to the properties the caller requested.
    FirstPromptModelComparisonPublicState:
      properties:
        id:
          type: string
          title: Id
        client_creation_id:
          type: string
          title: Client Creation Id
        models:
          items:
            type: string
          type: array
          title: Models
        status:
          type: string
          enum:
            - preparing
            - running
            - failed
            - selected
            - cancelled
          title: Status
      type: object
      required:
        - id
        - client_creation_id
        - models
        - status
      title: FirstPromptModelComparisonPublicState
    AppStatusResponse:
      properties:
        state:
          type: string
          enum:
            - ready
            - processing
            - error
          title: State
          description: >-
            Where the app is in its build lifecycle. Ready means idle with no
            build in progress, processing means the app is being generated or
            modified, and error means the last build failed. This tracks
            building, not publishing.
          example: ready
        details:
          anyOf:
            - type: string
            - type: 'null'
          title: Details
          description: >-
            Human readable note about the current state, such as what is being
            processed or why it failed, or `null` when there is nothing to
            report.
          example: Publishing app
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: >-
            ID of the request that last changed the status, or `null` if the
            status has never changed. Useful when reporting an issue.
          example: a1b2c3d4e5f67890abcdef12
        last_updated_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Updated Date
          description: >-
            Time the status was last updated, as a UTC timestamp in ISO 8601
            format.
          example: '2026-08-02T14:30:00Z'
        error_source:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Source
          description: >-
            Where the failure originated when `state` is `error`, or `null`
            otherwise. A value of `paywall` means the work was blocked because
            the app's workspace has no credits left.
          example: build
        paywall_context:
          anyOf:
            - $ref: '#/components/schemas/PaywallStatusContextResponse'
            - type: 'null'
          description: >-
            Present when the operation was blocked by a plan limit, describing
            what was evaluated, or `null` otherwise.
      type: object
      required:
        - state
      title: AppStatusResponse
      description: The app's current build status.
    PaywallStatusContextResponse:
      properties:
        billing_organization_id:
          type: string
          title: Billing Organization Id
          description: ID of the billing organization the paywall was evaluated against.
          example: 67e0b12c4d8a3f005b21c9e4
        user_id:
          type: string
          title: User Id
          description: ID of the user the paywall was evaluated for.
          example: 6706af53b9c1e2004a37d85f
        evaluated_at:
          type: string
          format: date-time
          title: Evaluated At
          description: >-
            Time the paywall condition was evaluated, as a UTC timestamp in ISO
            8601 format.
          example: '2026-08-02T14:30:00Z'
      type: object
      required:
        - billing_organization_id
        - user_id
        - evaluated_at
      title: PaywallStatusContextResponse
  securitySchemes:
    PersonalAccessTokenAuth:
      type: http
      scheme: bearer
      description: 'Personal access token, sent as `Authorization: Bearer <token>`.'

````