---
title: "Export Agent"
method: POST
path: "/v1/agents/{agent_id}/export"
tags: ["API v1", "Agents", "Agents Import/Export"]
---

# Export Agent

`POST /v1/agents/{agent_id}/export`

## Request

- Base URL: `https://api.xpander.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.xpander.ai/v1/agents/{agent_id}/export`
- Auth: API key in header `x-api-key`

Exports an AI agent into a reusable template with configuration and knowledge bases

## Path parameters

- `agent_id` string, required

## Request body

- ExportAgentRequest
  - `name` string, required
  - `description` string, nullable
  - `icon` string, nullable
  - `with_knowledge_bases` boolean, nullable

## Response `200`

Successful Response

- AgentTemplate
  - `id` string, required
  - `name` string, required
  - `description` string, nullable
  - `icon` string, required
  - `organization_id` string, nullable
  - `agent_definition` AgentDefinition
    - `id` string, required
    - `name` string, required
    - `description` string, nullable
    - `unique_name` string, nullable
    - `icon` string, nullable
    - `avatar` string, nullable
    - `type` 'manager' | 'regular' | 'a2a' | 'curl' | 'orchestration': Enumeration of the agent types. Attributes: Manager: marks the agent as a Managing agent. Regular: marks the agent as a regular agent. A2A: marks the agent as an external agent used via A2A protocol. Curl: marks the agent as an external agent used via a CURL. Orchestration: marks the agent as an Orchestration object.
    - `prompts` string[], nullable
    - `source_nodes` AIAgentSourceNode[], nullable
      - `id` string, nullable
      - `type` 'workbench' | 'sdk' | 'task' | 'assistant' | 'webhook' | 'mcp' | 'a2a' | 'telegram' | 'slack' | 'whatsapp' | 'ms-teams' | 'email' | 'api', required
      - `targets` string[], nullable
      - `metadata` object, nullable
    - `attached_tools` Connector[], nullable
      - `id` string, required
      - `operation_ids` string[], required
    - `access_scope` 'personal' | 'organizational' | 'project'
    - `instructions` AIAgentInstructions
      - `role` string[], nullable
      - `goal` string[], nullable
      - `general` string, nullable
      - `dynamic_prompt_enabled` boolean, nullable
      - `dynamic_prompt_code` string, nullable
      - `dynamic_prompt_position` 'before' | 'after', nullable
    - `oas` object, nullable
    - `graph` AIAgentGraphItemOutput[], nullable
      - `id` string, nullable
      - `item_id` string, required
      - `name` string, nullable
      - `type` 'source_node' | 'agent' | 'workflow' | 'tool' | 'human_in_the_loop' | 'xpsleep-agent-delay' | 'custom_agent' | 'storage' | 'local_db' | 'coding_agent' | 'mcp' | 'skills', required
      - `sub_type` 'sdk' | 'task' | 'assistant' | 'webhook' | 'operation' | 'custom_function' | 'local_tool'
      - `targets` string[], required
      - `settings` AIAgentGraphItemSettingsOutput
        - `instructions` string, nullable
        - `description` string, nullable
        - `schemas` AIAgentGraphItemSchema
          - `input` object, nullable
          - `output` object, nullable
        - `advanced_filtering_options` AIAgentGraphItemAdvancedFilteringOption
          - `returnables` string[], nullable
          - `searchables` string[], nullable
          - `globally_enabled` boolean, nullable
        - `hitl_options` AIAgentGraphItemHITLSettings
          - `title` string, nullable
          - `description` string, nullable
          - `recipients` string[], nullable
          - `hitl_type` 'slack'
          - `slack_app` string, nullable
          - `should_approve_with_current_user` boolean, nullable
          - `enabled` boolean, nullable
          - `approvers` ToolApprovalApprovers
            - `user_ids` string[], nullable
            - `group_ids` string[], nullable
            - `org_admins` boolean, nullable
          - `on_deny` 'continue' | 'stop'
          - `allowed_scopes` ToolApprovalScope[], nullable
          - `approve_once_per_run` boolean, nullable
          - `timeout_seconds` integer, nullable
          - `channels` string[], nullable
          - `tool_names` string[], nullable
          - `applies_to` 'all' | 'writes', nullable
        - `a2a_options` AIAgentGraphItemA2ASettings
          - `url` string, nullable
        - `coding_agent_settings` AIAgentGraphItemCodingAgentSettings
          - `type` 'codex', nullable
        - `mcp_settings` AIAgentGraphItemMCPSettings
          - `id` string, nullable
          - `type` 'local' | 'remote'
          - `name` string, nullable
          - `command` string, nullable
          - `url` string, nullable
          - `transport` 'stdio' | 'sse' | 'streamable-http'
          - `auth_type` 'api_key' | 'oauth2' | 'custom_headers' | 'sso_user' | 'none'
          - `api_key` string, nullable
          - `use_secrets_manager` boolean, nullable
          - `client_id` string, nullable
          - `client_secret` string, nullable
          - `additional_scopes` string[], nullable
          - `headers` object, nullable
          - `env_vars` object, nullable
          - `allowed_tools` string[], nullable
          - `share_user_token_across_other_agents` boolean, nullable
          - `share_connection_with_other_users` boolean, nullable
          - `sso_token` 'access' | 'id' | 'exchange': How an sso_user server receives the user's token; access and id are sent as-is, so only an org admin may pick them.
          - `sso_audience` string, nullable
          - `health_check_tool` string, nullable
          - `health_check_error_text` string, nullable
          - `connection_status` string, nullable
          - `tools_count` integer, nullable
          - `tools_verified` boolean, nullable
          - `last_checked_at` string, nullable
          - `last_error` string, nullable
        - `connector_settings` AIAgentGraphItemConnectorSettings
          - `background_user_id` string, nullable
          - `auth_mode` 'autonomous' | 'user_authentication': Vault-epic vocabulary; the binding-level clamp ranks these values directly.
          - `share_user_token_across_other_agents` boolean, nullable
          - `approval_policy` ConnectorApprovalPolicy: Connector-wide default, applied to its operations by read-vs-write verb.
            - `read_only` boolean, nullable
            - `mutating` boolean, nullable
          - `write_mode` 'allow' | 'ask' | 'block', nullable
        - `skills_settings` AIAgentGraphItemSkillsSettings
          - `enabled_skills` string[], nullable
        - `use_cache` boolean, nullable
        - `use_mock` boolean, nullable
      - `is_first` boolean, nullable
    - `status` 'DRAFT' | 'ACTIVE' | 'INACTIVE': Enumeration of possible agent statuses. Attributes: DRAFT: Agent is in a draft state. ACTIVE: Agent is active and operational. INACTIVE: Agent is inactive and not operational.
    - `version` integer, nullable
    - `model_provider` 'openai' | 'nim' | 'amazon_bedrock' | 'azure_ai_foundary' | 'huggingFace' | 'friendlyAI' | 'anthropic' | 'gemini' | 'fireworks' | 'google_ai_studio' | 'helicone' | 'bytedance' | 'tzafon_lightcone' | 'cerebras' | 'open_router' | 'nebius' | 'cloudflare_ai_gw' | 'z_ai'
    - `model_name` string, nullable
    - `framework` string, nullable
    - `agno_settings` AgnoSettings
      - `session_storage` boolean, nullable
      - `learning` boolean, nullable
      - `agent_memories` boolean, nullable
      - `agentic_culture` boolean, nullable
      - `user_memories` boolean, nullable
      - `agentic_memory` boolean, nullable
      - `session_summaries` boolean, nullable
      - `num_history_runs` integer, nullable
      - `max_tool_calls_from_history` integer, nullable
      - `tool_call_limit` integer, nullable
      - `coordinate_mode` boolean, nullable
      - `pii_detection_enabled` boolean, nullable
      - `pii_detection_mask` boolean, nullable
      - `prompt_injection_detection_enabled` boolean, nullable
      - `openai_moderation_enabled` boolean, nullable
      - `openai_moderation_categories` string[], nullable
      - `reasoning_tools_enabled` boolean, nullable
      - `max_plan_retries` integer, nullable
    - `harness_settings` HarnessSettingsOutput: Runtime settings for an agent whose framework is a CLI harness.
      - `permission_mode` 'full' | 'gated'
      - `max_concurrent_tasks` integer, nullable
      - `workdir_gc_days` integer, nullable
      - `image_tag` string, nullable
      - `approval_hold_hours` integer, nullable
      - `cli_auto_update` boolean, nullable
      - `default_cli` 'claude-code' | 'codex' | 'opencode' | 'xpander': A CLI the harness container can run; chosen per conversation, never per agent.
      - `models` object
      - `available_clis` HarnessCli[]
      - `runtime` 'fleet' | 'legacy': Where an agent's turns run: harness agents on the shared executor fleet; `legacy` is kept for wire compatibility and means not a fleet agent.
      - `resources` HarnessResources: Per-turn ceilings for a harness agent's sandbox on the fleet; every unset field keeps the runner default.
        - `memory_limit` string, nullable
        - `memory_high` string, nullable
        - `cpu` number, nullable
        - `pids` integer, nullable
        - `disk` string, nullable
      - `setup` HarnessSetup: What an imported agent brought along: CLI config files, a one-time setup script, and how project hooks are treated.
        - `files` HarnessSetupFile[]
          - `path` string, required
          - `content` string, required
        - `setup_script` string, nullable
        - `hooks_policy` 'project' | 'off'
      - `shared_work` HarnessSharedWork: How a resident harness agent treats irreversible actions on work other people own: `audit` logs the rule that would fire and lets the call run; `enforce` asks the person through the approval card.
        - `mode` 'audit' | 'enforce'
        - `gated` string[], nullable
        - `blast_radius` HarnessBlastRadius: Past these counts a process asks the person once before its first irreversible step.
          - `prs` integer
          - `files` integer
          - `repos` integer
      - `repos` string[], nullable
      - `browser` boolean, nullable
      - `builtin_tools` HarnessBuiltinTools: The CLI's own built-in tools (`harness`) and the platform's tools (`xpander`); a missing half stays on.
        - `harness` HarnessBuiltinToggle: One built-in tool set switched on or off; None leaves the decision to the next layer down.
          - `enabled` boolean, nullable
        - `xpander` HarnessBuiltinToggle: One built-in tool set switched on or off; None leaves the decision to the next layer down.
          - `enabled` boolean, nullable
    - `expected_output` string, nullable
    - `llm_reasoning_effort` 'low' | 'medium' | 'high' | 'xhigh'
    - `output_format` 'text' | 'markdown' | 'json' | 'voice'
    - `output_schema` object, nullable
    - `deployment_type` 'serverless' | 'container'
    - `custom_functions` CustomFunction[], required
      - `id` string, required
      - `name` string, required
      - `description` string, nullable
      - `input_schema` object, required
      - `technical_description` string, nullable
      - `status` 'draft' | 'analysing' | 'ready' | 'error', required
      - `limits` object, nullable
      - `source_code` string, required
      - `project_id` string, nullable: The project the item belongs to; unset means the org's Default project on create.
    - `connectors` ConnectedConnector[], required
      - `id` string, required
      - `name` string, nullable
      - `description` string, nullable
      - `open_api_spec_id` string, nullable
      - `general_params` GeneralParam[], nullable
        - `name` string, required
        - `description` string, required
        - `location` 'path' | 'query' | 'header' | 'cookie', required
        - `value` string, nullable
      - `operation_ids` string[], nullable
      - `operations_with_details` object[], nullable
      - `cc_id` string, nullable
      - `root_id` string, nullable
      - `code` string, nullable
      - `openapi_spec` string, nullable
      - `is_custom` boolean, nullable
      - `owner` string, nullable
      - `version` number, nullable
      - `total_operations` integer, nullable
      - `operations_map` object, nullable
      - `target_system_servers` unknown
    - `sub_agents` AgentDefinition[]
    - `knowledge_bases` ExportedKnowledgeBase[]
      - `name` string, required
      - `description` string, nullable
      - `documents` ExportedKnowledgeBaseDocument[], nullable
        - `name` string, nullable
        - `url` string, nullable
        - `content` string, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/xpander/apis/xpander-ai-api-service.md) - [All operations](https://skmtc.dev/xpander/apis/xpander-ai-api-service/llms.txt) - [OpenAPI document](https://skmtc.dev/xpander/apis/xpander-ai-api-service/revisions/725c0066d5df?raw)
