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

# Save an app file

> Saves a file into the app, the same way saving in the app editor does.

Base44 writes the file, applies it to the app, and takes care of what the path implies: a backend function is redeployed, an entity or agent schema is parsed and validated, and a change that affects row-level security records a revertible notice on the app's chat.

Sending an empty `content` deletes the file. That is the app editor's own convention for this path, so treat an empty string as a delete rather than as a way to blank a file.

Paths are relative to the app root. Entity and agent schemas, workflows and email templates each have one canonical location, and a legacy shorthand is refused with a 400 naming the canonical form. A path that escapes the app is refused the same way.

Writing a backend function deploys it, so the request takes as long as the deploy and answers 422 carrying the compiler's diagnostics when the code doesn't build. Use [Save several app files](/api-reference/save-several-app-files) to write a batch of frontend files in one call.

Set `branch_id` to save the file on a [branch](/developers/references/app-management/get-started/concepts#branches) instead of main. The change goes to the branch's own code, and a backend function is deployed for the branch only. On a branch, files that define the app's resources, such as entity and agent schemas, are refused with a 409, except on an app imported from GitHub. To add entities or fields on the branch, use [Send chat message](/api-reference/send-chat-message) with the same `branch_id`. Other resource changes must be made on main.

The response is the app document as it stands after the change, the same shape [Get app](/api-reference/get-app) returns. On a branch, it's main's app document, so it doesn't show the change.

<Note>This endpoint accepts a personal API key or a workspace API key, which acts as the workspace owner. A read-only key is refused.</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/write
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/write:
    post:
      summary: Save an app file
      description: >-
        Saves a file into the app, the same way saving in the app editor does.


        Base44 writes the file, applies it to the app, and takes care of what
        the path implies: a backend function is redeployed, an entity or agent
        schema is parsed and validated, and a change that affects row-level
        security records a revertible notice on the app's chat.


        Sending an empty `content` deletes the file. That is the app editor's
        own convention for this path, so treat an empty string as a delete
        rather than as a way to blank a file.


        Paths are relative to the app root. Entity and agent schemas, workflows
        and email templates each have one canonical location, and a legacy
        shorthand is refused with a 400 naming the canonical form. A path that
        escapes the app is refused the same way.


        Writing a backend function deploys it, so the request takes as long as
        the deploy and answers 422 carrying the compiler's diagnostics when the
        code doesn't build. Use [Save several app
        files](/api-reference/save-several-app-files) to write a batch of
        frontend files in one call.


        Set `branch_id` to save the file on a
        [branch](/developers/references/app-management/get-started/concepts#branches)
        instead of main. The change goes to the branch's own code, and a backend
        function is deployed for the branch only. On a branch, files that define
        the app's resources, such as entity and agent schemas, are refused with
        a 409, except on an app imported from GitHub. To add entities or fields
        on the branch, use [Send chat message](/api-reference/send-chat-message)
        with the same `branch_id`. Other resource changes must be made on main.


        The response is the app document as it stands after the change, the same
        shape [Get app](/api-reference/get-app) returns. On a branch, it's
        main's app document, so it doesn't show the change.


        <Note>This endpoint accepts a personal API key or a workspace API key,
        which acts as the workspace owner. A read-only key is refused.</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: write_file_api_api_apps__app_id__coding_write_post
      parameters:
        - 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
        - name: branch_id
          in: query
          required: false
          schema:
            type: string
            description: >-
              ID of the branch to work on, as returned by [List
              branches](/api-reference/list-branches). Omit it to work on the
              app's main branch.
            title: Branch Id
          description: >-
            ID of the branch to work on, as returned by [List
            branches](/api-reference/list-branches). Omit it to work on the
            app's main branch.
          example: 68f1a2b3c4d5e6f708192a3b
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WritePayload'
      responses:
        '200':
          description: >-
            The app after the write. With `branch_id`, main's app, which a
            branch write doesn't change.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserApp'
        '400':
          description: >-
            `file_path` escapes the app, or uses a legacy location for an entity
            or agent schema, a workflow or an email template instead of its
            canonical one. A write that adds an import across the
            frontend/backend boundary (frontend code importing `base44/`, or
            backend code importing `src/` or `@/`) answers 400 with error code
            `cross_boundary_import`; an import the file already had doesn't
            block the save. An entity schema change the platform refuses to save
            answers 400 with error code `invalid_entity_schema`. On an app
            imported from GitHub, a `branch_id` whose branch is the repository's
            default branch answers 400 with `extra_data.reason`
            `invalid_branch_name`.
        '401':
          description: Missing or invalid credentials.
        '403':
          description: You don't have access to this app, or your API key is read-only.
        '404':
          description: App not found, or no branch you can see has this `branch_id`.
        '409':
          description: >-
            Main is protected and you sent no `branch_id` (`branch_protected`),
            or the branch in `branch_id` was merged (`branch_scope_read_only`),
            is being updated from main (`branch_sync_in_progress`), or can't
            take this path (`operation_blocked_on_branch`). The reason is in
            `extra_data.reason`.
        '413':
          description: >-
            `function_source_too_large`: the function's source (its file paths
            and contents together) is over the 12 MiB per-function storage cap,
            so its source wasn't stored. The function may already be deployed,
            and on a file save the file itself may already be written to the
            app. `details` carries `function_name`, `size_bytes` and
            `limit_bytes`. Make the function smaller, for example by moving
            large data out of its code.
          content:
            application/json:
              examples:
                function_source_too_large:
                  summary: function_source_too_large
                  value:
                    error:
                      code: function_source_too_large
                      message: >-
                        Backend function 'export' source is 18084640 bytes —
                        exceeds the 12582912-byte per-function storage cap
                      details:
                        function_name: export
                        size_bytes: 18084640
                        limit_bytes: 12582912
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '422':
          description: >-
            A backend function in this write failed to build. The detail carries
            the compiler diagnostics. An entity schema whose RLS rules reference
            a reserved record field (`app_id`, `entity_name`, `region`,
            `environment`, `is_deleted` or `_id`) is saved as a file, but the
            entity keeps its previous schema: the call answers 422 with error
            code `rls_reserved_field` and the path in `details.file_path`.
        '503':
          description: >-
            Sandbox temporarily unavailable (`sandbox_unavailable`): the app's
            sandbox could not be created or reached. Retry after the
            `Retry-After` seconds.
          content:
            application/json:
              examples:
                sandbox_unavailable:
                  summary: sandbox_unavailable
                  value:
                    error:
                      code: sandbox_unavailable
                      message: Sandbox temporarily unavailable, please retry
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
      security:
        - PersonalAccessTokenAuth:
            - full_access
        - WorkspaceApiKeyAuth:
            - full_access
        - WorkspaceApiKeyBearerAuth:
            - full_access
components:
  schemas:
    WritePayload:
      properties:
        file_path:
          type: string
          title: File Path
          description: Path of the file, relative to the app root.
        content:
          type: string
          title: Content
          description: >-
            Full contents to save. An empty string deletes the file, which is
            this endpoint's convention rather than a way to blank one.
      type: object
      required:
        - file_path
        - content
      title: WritePayload
      example:
        content: |
          export default function About() {
            return <h1>About</h1>;
          }
        file_path: src/pages/About.jsx
    UserApp:
      properties:
        id:
          type: string
          title: Id
          description: ID of the app.
          example: 6820f3a4e7b91d003c45a1f2
        created_date:
          type: string
          format: date-time
          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:
          type: string
          format: date-time
          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'
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
          description: Email of the user who created the app.
          example: developer@example.com
        organization_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization Id
          description: ID of the workspace the app belongs to.
          example: 67e0b12c4d8a3f005b21c9e4
        app_type:
          type: string
          title: App Type
          description: >-
            Kind of app, set when it's created. One of `user_app` (a web app),
            `user_agent` (an AI agent), `mobile_app` (a native mobile app),
            `user_game` (a game), `slide` (a presentation), or `imported_app`
            (an app imported from an existing code repository). List apps
            returns it as stored, so an older agent app can report `agent`
            instead of `user_agent`, and some older apps don't include it. Get
            app always returns one of the values above.
          default: user_app
          example: user_app
        name:
          type: string
          title: Name
          description: Display name of the app.
          default: untitled
          example: My CRM
        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
        logo_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Logo Url
          description: >-
            URL of the app's logo, or `null` if it has none. Set it with [Set
            app logo](/api-reference/set-app-logo) or [Generate app
            logo](/api-reference/generate-app-logo).
          example: >-
            https://storage.base44.com/6820f3a4e7b91d003c45a1f2/3f2504e0_logo.png
        social_image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Social Image Url
          description: >-
            URL of the image shown when the app is shared on social platforms,
            or `null` if none was set, in which case the logo is shown instead.
            Set it with [Set social image](/api-reference/set-social-image).
          example: >-
            https://storage.base44.com/6820f3a4e7b91d003c45a1f2/7c9e6679_social.png
        public_settings:
          type: string
          enum:
            - private_with_login
            - public_with_login
            - public_without_login
            - workspace_with_login
          title: Public Settings
          description: >-
            Who can open the published app. Each value is described under
            [Update app](/api-reference/update-app), which also changes it.
          default: public_with_login
          example: public_with_login
        auth_config:
          $ref: '#/components/schemas/AuthConfiguration'
          description: >-
            Which login methods the app's login page offers. If the workspace
            enforces SSO for apps, the login page offers only SSO, whatever
            these are set to. Change them with [Update
            app](/api-reference/update-app).
        hide_entity_created_by:
          type: boolean
          title: Hide Entity Created By
          description: >-
            Whether the app's entity records leave out the email of the user who
            created each one (`created_by`). Newer apps always leave the email
            out, whatever this is set to.
          default: false
          example: true
        is_remixable:
          type: boolean
          title: Is Remixable
          description: >-
            Whether others can remix the app. While it's `true`, the published
            app also shows the Base44 badge if `public_settings` is
            `public_with_login` or `public_without_login`.
          default: false
          example: false
        main_branch_protected:
          type: boolean
          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. Always `true` for imported
            apps. Change it with [Set main branch protection (owner or admin
            only)](/api-reference/set-main-branch-protection-owner-or-admin-only).
          default: false
          example: false
        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
        is_unpublished:
          type: boolean
          title: Is Unpublished
          description: >-
            Whether the app was taken offline with [Unpublish
            app](/api-reference/unpublish-app) and hasn't been published again
            since. While it's `true`, the published URL is offline and
            `last_deployed_at` still shows the last publish. Read-only: an
            update that sends it is applied without it.
          default: false
          example: false
        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. Read-only: an
            update that sends it is applied without it.
          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
        cover_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Cover Url
          description: >-
            URL of a generated cover image with the app's name and logo, made
            for apps that require login, which get no screenshot. `null` until
            one is made.
          example: https://storage.base44.com/6820f3a4e7b91d003c45a1f2/covers/cover.png
        owner_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner Id
          description: >-
            ID of the user who owns the app. It starts as the creator and
            changes when ownership is transferred.
          example: 6706af53b9c1e2004a37d85f
        status:
          $ref: '#/components/schemas/StatusObject'
          description: >-
            The app's current build status. Poll while a build is in progress to
            watch it finish. This tracks building, not publishing.
        dev_environment_enabled:
          type: boolean
          title: Dev Environment Enabled
          description: >-
            Whether test data is on, which gives the app a test database next to
            its live one.
          default: false
          example: false
      type: object
      title: UserApp
    StandardErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/StandardError'
          description: What went wrong.
      type: object
      required:
        - error
      title: StandardErrorEnvelope
      description: The error body returned in the standard envelope.
    AuthConfiguration:
      properties:
        enable_username_password:
          type: boolean
          title: Enable Username Password
          description: Whether people can sign in to the app with an email and password.
          default: false
          example: true
        enable_google_login:
          type: boolean
          title: Enable Google Login
          description: Whether people can sign in to the app with a Google account.
          default: true
          example: true
        enable_microsoft_login:
          type: boolean
          title: Enable Microsoft Login
          description: Whether people can sign in to the app with a Microsoft account.
          default: false
          example: false
        enable_facebook_login:
          type: boolean
          title: Enable Facebook Login
          description: Whether people can sign in to the app with a Facebook account.
          default: false
          example: false
        enable_apple_login:
          type: boolean
          title: Enable Apple Login
          description: Whether people can sign in to the app with an Apple account.
          default: false
          example: false
      type: object
      title: AuthConfiguration
      description: Authentication configuration for user applications
    StatusObject:
      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/PaywallStatusContext'
            - 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: StatusObject
      description: The app's current build status.
    StandardError:
      properties:
        code:
          type: string
          title: Code
          description: >-
            Stable machine-readable cause of the failure. Match on this, not on
            `message`.
          example: not_found
        message:
          type: string
          title: Message
          description: Human-readable explanation. It isn't a stable contract.
          example: App not found
        details:
          additionalProperties: true
          type: object
          title: Details
          description: >-
            Structured context for the failure, or an empty object when there's
            none.
          example: {}
      type: object
      required:
        - code
        - message
      title: StandardError
    PaywallStatusContext:
      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: PaywallStatusContext
  securitySchemes:
    PersonalAccessTokenAuth:
      type: http
      scheme: bearer
      description: >-
        Personal access token, sent as `Authorization: Bearer <token>`. Each
        operation lists the permission it needs: `read_only` or `full_access`. A
        full-access token can call every operation. A read-only token can call
        only the operations that list `read_only`; anything else returns 403
        `read_only_credential_route_not_allowed`.
    WorkspaceApiKeyAuth:
      type: apiKey
      in: header
      name: api_key
      description: >-
        Workspace API key, sent as `api_key: <key>`. Each operation that accepts
        one lists what the key needs: a permission, `read_only` or
        `full_access`, like a personal access token, or a scope. A key without
        the scope gets 403 `workspace_api_key_scope_required`.
    WorkspaceApiKeyBearerAuth:
      type: http
      scheme: bearer
      description: >-
        Workspace API key, sent as `Authorization: Bearer <key>`. Accepted
        wherever `api_key` is, with the same permission.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.