Import a Claude Code or Codex session
Changed on<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 50 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, the images pasted into them, and the AI's replies are kept, and at most the newest 400 turns are written. Thinking, tool arguments, and tool output, including its screenshots, are dropped. The newest 20 pasted PNG, JPEG, GIF, and WebP images are attached to their messages. A message whose images weren't imported, because there were more or they couldn't be read or stored, says how many.
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.
Importing a session again adds only what's new. When the same session was imported before into a branch that's still active, Base Code writes only the messages that come after the ones it already has, after anything said on the branch since, and sets reimported to true. turn_count then counts the new messages, so 0 means the branch was already up to date. The code isn't touched: the branch already follows the session's pushed commits. If that branch was merged or archived, the import creates a new branch as above.
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.
Request
- Base URLhttps://app.base44.com
- URLhttps://app.base44.com/api/apps/{app_id}/imported/session-imports
- AuthHTTP bearer
Path parameters
ID of the imported app to import the session into.
Headers
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.
Request body multipart/form-data
Example request
{
"source_branch": "fix-login-redirect"
}Response
The branch the session was imported into.
Example response
{
"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"
}Changes
- info
added the optional property
to the response with the status
- info
- info
endpoint added
- info