---
title: "Import Claude Session"
method: POST
path: "/api/v1/user-sessions/import-claude-session"
tags: ["user_sessions"]
---

# Import Claude Session

`POST /api/v1/user-sessions/import-claude-session`

Import messages from a Claude CLI session into a new Omnara session.

This creates:
1. A new user_session linked to the workspace's main worktree
2. A new agent_session for the imported messages
3. All messages from the Claude CLI session

The agent_session_id can then be used as the resume_session_id when
starting the SDK to resume from the imported session.

## Request body

- ImportClaudeSessionRequest — Request to import messages from a Claude CLI session. This creates a new user_session and agent_session, then imports all the provided messages into the database. The agent_session_id can then be used as the resume_session_id when starting the SDK.
  - `workspace_id` string, required — Workspace ID to import the session into
  - `worktree_name` string, nullable — Optional worktree name (null for main workspace)
  - `claude_session_id` string, required — Original Claude CLI session ID (used as SDK resume ID)
  - `messages` ImportableMessage[], required — Messages to import from the Claude CLI session
    - `message_id` string, required — UUID of the message
    - `role` string, required — Role: 'user' or 'assistant'
    - `content` ImportableMessageContent, required — Content for an importable message from Claude CLI.
      - `type` string, required — Content type: 'text', 'tool_call', 'tool_result', or 'agent_complete'
      - `text` string, nullable — Text content of the message
      - `name` string, nullable — Name of the tool being called
      - `tool_use_id` string, nullable — Unique identifier for the tool use
      - `arguments` object, nullable — Arguments passed to the tool call
      - `output` unknown
      - `is_error` boolean, nullable — Whether the tool execution resulted in an error
      - `success` boolean, nullable — Whether the agent completed successfully
      - `message` string, nullable — Completion message from the agent
    - `created_at` string, required — ISO timestamp of when the message was created
    - `metadata` object, nullable — Optional metadata attached to the message
  - `session_name` string, nullable — Optional name for the imported session

## Response `201`

Successful Response

- ImportClaudeSessionResponse — Response from importing a Claude CLI session.
  - `success` boolean, required — Whether the import was successful
  - `user_session_id` string, nullable — ID of the created user session
  - `agent_session_id` string, nullable — ID of the created agent session
  - `message_count` integer — Number of messages successfully imported
  - `error` string, nullable — Error message if the import failed

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/omnara/apis/omnara-api.md) · [All operations](https://skmtc.dev/omnara/apis/omnara-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/omnara/omnara-api/revisions/624048e40cad/schema)
