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

# Import a Claude Code or Codex session

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

Imports a Claude Code or Codex session into an imported app as a Base Code branch, with the session's conversation in that branch's chat. You continue the work there with the AI. The `base44 sessions import` CLI command calls this endpoint.

Send the session file as `file` in a `multipart/form-data` body. Base Code reads a Claude Code transcript, the `.jsonl` file under `~/.claude/projects/`, or a Codex rollout, the `rollout-*.jsonl` file under `~/.codex/sessions/`. The file can be up to 25 MB.

The conversation is cut at the prompt that asked for the import, so that prompt and everything after it are left out. Only typed messages and the AI's replies are kept, and at most the newest 400 turns are written. Thinking, tool arguments, and tool output are dropped.

The session continues on its own branch when that branch is in the app's GitHub repository and isn't the default branch. Base Code adopts that branch as it is, so stop working on it locally. If Base Code already has an active branch with that name, the import is refused and nothing is written. In every other case Base Code creates a new branch named after the session's first message. It starts from the session's branch when that's in the repository, and from the default branch when it isn't. `continued` and `source_ref` say which one happened.

Authenticate with a personal access token, sent as `Authorization: Bearer <token>`. Where the user isn't signed in, such as on a cloud machine, send the one-time import key that Base Code's Import session dialog creates in its place. The key starts with `b44imp_`, works once and only for the app it was created for, and expires after 10 minutes. The import then runs as the user who opened the dialog.

Send an `Idempotency-Key` header, such as a UUID, and repeat it when you retry after a lost response, a `409` `conflict`, or a `5xx`. A retry with the same key, file, and `source_branch` returns the first import's response and writes nothing. Only a successful import is remembered, for 24 hours, so a retry after an error imports again. An upload with an import key can't be retried at all: the key works once, so a retry gets a `401`.



## OpenAPI

````yaml /developers/references/app-management/app-management-openapi.json post /api/apps/{app_id}/imported/session-imports
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}/imported/session-imports:
    post:
      summary: Import a Claude Code or Codex session
      description: >-
        <Info>This API is in beta. Endpoints, fields, and behavior may still
        change, so avoid depending on it in production.</Info>


        Imports a Claude Code or Codex session into an imported app as a Base
        Code branch, with the session's conversation in that branch's chat. You
        continue the work there with the AI. The `base44 sessions import` CLI
        command calls this endpoint.


        Send the session file as `file` in a `multipart/form-data` body. Base
        Code reads a Claude Code transcript, the `.jsonl` file under
        `~/.claude/projects/`, or a Codex rollout, the `rollout-*.jsonl` file
        under `~/.codex/sessions/`. The file can be up to 25 MB.


        The conversation is cut at the prompt that asked for the import, so that
        prompt and everything after it are left out. Only typed messages and the
        AI's replies are kept, and at most the newest 400 turns are written.
        Thinking, tool arguments, and tool output are dropped.


        The session continues on its own branch when that branch is in the app's
        GitHub repository and isn't the default branch. Base Code adopts that
        branch as it is, so stop working on it locally. If Base Code already has
        an active branch with that name, the import is refused and nothing is
        written. In every other case Base Code creates a new branch named after
        the session's first message. It starts from the session's branch when
        that's in the repository, and from the default branch when it isn't.
        `continued` and `source_ref` say which one happened.


        Authenticate with a personal access token, sent as `Authorization:
        Bearer <token>`. Where the user isn't signed in, such as on a cloud
        machine, send the one-time import key that Base Code's Import session
        dialog creates in its place. The key starts with `b44imp_`, works once
        and only for the app it was created for, and expires after 10 minutes.
        The import then runs as the user who opened the dialog.


        Send an `Idempotency-Key` header, such as a UUID, and repeat it when you
        retry after a lost response, a `409` `conflict`, or a `5xx`. A retry
        with the same key, file, and `source_branch` returns the first import's
        response and writes nothing. Only a successful import is remembered, for
        24 hours, so a retry after an error imports again. An upload with an
        import key can't be retried at all: the key works once, so a retry gets
        a `401`.
      operationId: create_session_import_api_apps__app_id__imported_session_imports_post
      parameters:
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            description: ID of the imported app to import the session into.
            title: App Id
          description: ID of the imported app to import the session into.
          example: 6820f3a4e7b91d003c45a1f1
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            minLength: 8
            maxLength: 100
            description: >-
              A value you generate for this import, 8 to 100 characters, such as
              a UUID. Send the same value when you retry the import, and a new
              one for every other import. A retry with the same value, file, and
              `source_branch` within 24 hours returns the first response instead
              of importing again. Keys are scoped to the user and the app.
            title: Idempotency-Key
          description: >-
            A value you generate for this import, 8 to 100 characters, such as a
            UUID. Send the same value when you retry the import, and a new one
            for every other import. A retry with the same value, file, and
            `source_branch` within 24 hours returns the first response instead
            of importing again. Keys are scoped to the user and the app.
          example: 5d0e2a9c-6f1b-4c3e-8a7d-2b9f0c1e4a6d
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SessionImportUpload'
      responses:
        '200':
          description: The branch the session was imported into.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionImportResponse'
              example:
                branch_id: 6820f3a4e7b91d003c45a1f3
                branch_name: fix-login-redirect
                source: claude_code
                turn_count: 42
                branch_url: >-
                  /apps/6820f3a4e7b91d003c45a1f1/editor/preview?branch=fix-login-redirect
                continued: true
                source_ref: fix-login-redirect
        '400':
          description: '`invalid_request`: The file is empty.'
          content:
            application/json:
              examples:
                invalid_request:
                  summary: invalid_request
                  value:
                    error:
                      code: invalid_request
                      message: Cannot upload empty file
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '401':
          description: >-
            `unauthenticated`: The credentials are missing or invalid, or were
            sent as an `api_key` query parameter. An import key also gets this
            when it's invalid, expired, or already used, or when the user who
            created it has signed out since.
          content:
            application/json:
              examples:
                unauthenticated:
                  summary: unauthenticated
                  value:
                    error:
                      code: unauthenticated
                      message: This import key is invalid, expired or already used.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '403':
          description: >-
            `forbidden`: The credential's user doesn't have write access to the
            app, or the import key was created for another app. A read-only
            personal access token is refused, and so is a workspace API key.
            `route_does_not_accept_keys`: A workspace API key that runs as its
            workspace's owner is refused.
          content:
            application/json:
              examples:
                forbidden:
                  summary: forbidden
                  value:
                    error:
                      code: forbidden
                      message: This import key belongs to another app.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '404':
          description: >-
            `not_found`: The app doesn't exist, isn't an imported app, or
            session import isn't available for it.
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    error:
                      code: not_found
                      message: Session import isn't available for this app.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '409':
          description: >-
            `branch_exists`: Base Code already has an active branch for the
            session's branch, and nothing was written. `details.branch_name` and
            `details.branch_url` point at it. `repository_not_connected`: The
            app isn't connected to its GitHub repository. `conflict`: The app or
            its repository changed while the branch was being created. Retry the
            import with the same `Idempotency-Key`. `idempotency_key_mismatch`:
            The `Idempotency-Key` was already used with a different file or
            `source_branch`. `idempotency_key_in_use`: An import with the same
            `Idempotency-Key` is still running. Retry it shortly.
            `auth_required_for_workspace`, `sso_required_for_workspace`, or
            `mfa_required_for_workspace`: The app's workspace needs the user who
            created the import key to sign in again.
          content:
            application/json:
              examples:
                branch_exists:
                  summary: branch_exists
                  value:
                    error:
                      code: branch_exists
                      message: Base Code already has a branch for fix-login-redirect.
                      details:
                        branch_name: fix-login-redirect
                        branch_url: >-
                          /apps/6820f3a4e7b91d003c45a1f1/editor/preview?branch=fix-login-redirect
                repository_not_connected:
                  summary: repository_not_connected
                  value:
                    error:
                      code: repository_not_connected
                      message: Connect this app to its GitHub repository first.
                      details: {}
                idempotency_key_mismatch:
                  summary: idempotency_key_mismatch
                  value:
                    error:
                      code: idempotency_key_mismatch
                      message: >-
                        This Idempotency-Key was already used with a different
                        file or source_branch.
                      details: {}
                idempotency_key_in_use:
                  summary: idempotency_key_in_use
                  value:
                    error:
                      code: idempotency_key_in_use
                      message: >-
                        An import with this Idempotency-Key is still running.
                        Retry shortly.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '411':
          description: >-
            `content_length_required`: The request has no `Content-Length`
            header.
          content:
            application/json:
              examples:
                content_length_required:
                  summary: content_length_required
                  value:
                    error:
                      code: content_length_required
                      message: Content-Length header required
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '413':
          description: '`file_too_large`: The request or the file is larger than 25 MB.'
          content:
            application/json:
              examples:
                file_too_large:
                  summary: file_too_large
                  value:
                    error:
                      code: file_too_large
                      message: File too large (max 26214400 bytes)
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '422':
          description: >-
            `unsupported_file`: The file isn't a Claude Code or Codex session,
            or it has nothing to import before the import prompt.
            `repository_mismatch`: The session was recorded in a different
            repository from the app's. `invalid_request`: `file` is missing,
            `source_branch` is longer than 255 characters, or `Idempotency-Key`
            is shorter than 8 or longer than 100 characters.
          content:
            application/json:
              examples:
                unsupported_file:
                  summary: unsupported_file
                  value:
                    error:
                      code: unsupported_file
                      message: This file isn't a Claude Code or Codex session.
                      details: {}
                repository_mismatch:
                  summary: repository_mismatch
                  value:
                    error:
                      code: repository_mismatch
                      message: This session was recorded in a different repository.
                      details: {}
                invalid_request:
                  summary: invalid_request
                  value:
                    error:
                      code: invalid_request
                      message: Invalid request
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '429':
          description: >-
            `rate_limited`: The base limit is 6 imports per minute, scoped to
            the user, and reported in the `X-RateLimit-*` headers. Retry after
            the number of seconds in `Retry-After`. See [Rate
            limits](/developers/references/apps-api/get-started/rate-limits) for
            the multiplier your plan gets.
          content:
            application/json:
              examples:
                rate_limited:
                  summary: rate_limited
                  value:
                    error:
                      code: rate_limited
                      message: Rate limit exceeded.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
      security:
        - PersonalAccessTokenAuth:
            - full_access
components:
  schemas:
    SessionImportUpload:
      properties:
        file:
          type: string
          format: binary
          title: File
          description: >-
            The session file, a Claude Code `.jsonl` transcript or a Codex
            `rollout-*.jsonl` file of up to 25 MB.
        source_branch:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Source Branch
          description: >-
            The Git branch the session is on now. It wins over the branch
            recorded in the file, which can predate a push. Leave it out to use
            the file's branch.
          examples:
            - fix-login-redirect
      type: object
      required:
        - file
      title: SessionImportUpload
      description: A Claude Code or Codex session to import.
    SessionImportResponse:
      properties:
        branch_id:
          type: string
          title: Branch Id
          description: ID of the Base Code branch the session was imported into.
          examples:
            - 6820f3a4e7b91d003c45a1f3
        branch_name:
          type: string
          title: Branch Name
          description: >-
            Name of that branch. When `continued` is `true`, it's the session's
            own Git branch.
          examples:
            - fix-login-redirect
        source:
          type: string
          enum:
            - claude_code
            - codex
          title: Source
          description: >-
            The tool that recorded the session. Either `"claude_code"` or
            `"codex"`.
          examples:
            - claude_code
        turn_count:
          type: integer
          title: Turn Count
          description: Number of messages written to the branch's chat.
          examples:
            - 42
        branch_url:
          type: string
          title: Branch Url
          description: >-
            Path of the branch in the app editor. Append it to the Base44
            address to open it.
          examples:
            - >-
              /apps/6820f3a4e7b91d003c45a1f1/editor/preview?branch=fix-login-redirect
        continued:
          type: boolean
          title: Continued
          description: >-
            Whether the session continues on its own branch. The value is `true`
            when Base Code adopted the session's branch and `false` when it
            created a new branch from `source_ref`.
          examples:
            - true
        source_ref:
          type: string
          title: Source Ref
          description: >-
            Git branch the Base Code branch comes from. It's the session's
            branch when that's in the repository, and the repository's default
            branch when it isn't.
          examples:
            - fix-login-redirect
      type: object
      required:
        - branch_id
        - branch_name
        - source
        - turn_count
        - branch_url
        - continued
        - source_ref
      title: SessionImportResponse
    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.
    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
  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`.

````

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