> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bigmodel.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 归档会话线程

> 归档处于空闲状态的子线程，保留历史记录。

<Accordion title="使用说明">

仅 idle 子线程可归档；running/rescheduling/primary 返回 400，重复归档幂等。

</Accordion>



## OpenAPI

````yaml /openapi/openapi-managed-agents.json post /agent/managed/v1/sessions/{sessionId}/threads/{threadId}/archive
openapi: 3.0.1
info:
  title: 智谱 AI Managed Agents API
  version: 1.0.0
  description: Agent、Environment、Session、File、Memory、Vault、Skill、Deployment 接口。
  contact:
    name: Z.AI 开发者
    url: https://chat.z.ai/legal-agreement/privacy-policy
    email: user_feedback@z.ai
servers:
  - url: https://open.bigmodel.cn/api/
    description: 开放平台服务
security:
  - bearerAuth: []
tags:
  - name: Managed Agents - Agent
    description: Agent 与版本管理。
    x-group: Agent
  - name: Managed Agents - Environment
    description: 声明式执行环境管理。
    x-group: Environment
  - name: Managed Agents - Session
    description: Session、Resource 与事件流。
    x-group: Session
  - name: Managed Agents - File
    description: Managed Files 上传、读取与删除。
    x-group: File
  - name: Managed Agents - Memory
    description: Memory Store、Memory 与版本管理。
    x-group: Memory
  - name: Managed Agents - Vault
    description: Vault 与 Credential 管理。
    x-group: Vault
  - name: Managed Agents - Skill
    description: 自定义 Skill 与版本管理。
    x-group: Skill
  - name: Managed Agents - Deployment
    description: 定时或手动 Deployment 与运行记录。
    x-group: Deployment
  - name: Thread
    description: 会话线程
    x-group: Thread
paths:
  /agent/managed/v1/sessions/{sessionId}/threads/{threadId}/archive:
    servers:
      - url: https://agent-api.bigmodel.cn/api
    post:
      tags:
        - Thread
      summary: 归档会话线程
      description: |-
        归档处于空闲状态的子线程，保留历史记录。

        <Accordion title="使用说明">

        仅 idle 子线程可归档；running/rescheduling/primary 返回 400，重复归档幂等。

        </Accordion>
      operationId: managedPostsessionssessionIdthreadsthreadIdarchive
      parameters:
        - $ref: '#/components/parameters/ManagedZaiVersion'
        - $ref: '#/components/parameters/ManagedZaiBeta'
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
        - name: threadId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedThread'
        default:
          description: 错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsErrorResponse'
components:
  parameters:
    ManagedZaiVersion:
      name: zai-version
      in: header
      required: true
      description: >-
        Managed Agents API 入口要求的基础协议标识，当前只接受 2026-05-26；响应兼容形态由 zai-beta
        选择。两个头均需携带。
      schema:
        type: string
        enum:
          - '2026-05-26'
        default: '2026-05-26'
        example: '2026-05-26'
    ManagedZaiBeta:
      name: zai-beta
      in: header
      required: true
      description: >-
        声明 Managed Agents Beta 协议并选择响应字段与兼容行为。新接入使用
        managed-agents-2026-09-22；旧客户端仍可使用 managed-agents-2026-05-26。必须同时携带
        zai-version: 2026-05-26。字段差异见 /cn/managed-agents/protocol-versions。
      schema:
        type: string
        default: managed-agents-2026-09-22
        example: managed-agents-2026-09-22
  schemas:
    ManagedThread:
      type: object
      properties:
        id:
          type: string
          pattern: ^sthr_
        type:
          type: string
          enum:
            - session_thread
        session_id:
          type: string
        parent_thread_id:
          type: string
          nullable: true
        agent:
          oneOf:
            - $ref: '#/components/schemas/ManagedThreadAgent'
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - advisor
                model:
                  type: string
              required:
                - type
                - model
              additionalProperties: false
              title: 顾问线程
        status:
          type: string
          enum:
            - running
            - idle
            - rescheduling
            - terminated
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        archived_at:
          type: string
          format: date-time
          nullable: true
        workflow_run_id:
          type: string
          nullable: true
          description: 新协议恒 null；旧协议省略，当前无 Workflow Run。
        stats:
          type: object
          properties:
            startup_seconds:
              type: number
            active_seconds:
              type: number
            duration_seconds:
              type: number
          required:
            - startup_seconds
            - active_seconds
            - duration_seconds
          additionalProperties: false
          nullable: true
        usage:
          type: object
          properties:
            input_tokens:
              type: integer
            output_tokens:
              type: integer
            cache_read_input_tokens:
              type: integer
            active_seconds:
              type: number
          required:
            - input_tokens
            - output_tokens
            - cache_read_input_tokens
            - active_seconds
          additionalProperties: false
          nullable: true
      required:
        - id
        - type
        - session_id
        - parent_thread_id
        - agent
        - status
        - created_at
        - updated_at
        - archived_at
        - stats
        - usage
      additionalProperties: false
    ManagedAgentsErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - error
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request_error
                - authentication_error
                - permission_error
                - not_found_error
                - request_too_large
                - rate_limit_error
                - api_error
                - timeout_error
                - overloaded_error
                - memory_path_conflict_error
                - memory_precondition_failed_error
                - conflict_error
            message:
              type: string
            details:
              type: object
              additionalProperties: true
          required:
            - type
            - message
          additionalProperties: false
        request_id:
          type: string
          example: req_01J...
      required:
        - type
        - error
        - request_id
      additionalProperties: false
    ManagedThreadAgent:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - agent
        name:
          type: string
        model:
          $ref: '#/components/schemas/ManagedModelResponse'
        system:
          type: string
          nullable: true
          description: 解析后的系统提示词。
        description:
          type: string
          nullable: true
          description: Agent 描述。
        tools:
          type: array
          items:
            $ref: '#/components/schemas/ManagedAgentToolsetResponse'
        skills:
          type: array
          items:
            $ref: '#/components/schemas/ManagedSkillReference'
        mcp_servers:
          type: array
          items:
            $ref: '#/components/schemas/ManagedMcpServer'
        version:
          type: integer
          minimum: 0
      required:
        - id
        - type
        - name
        - model
        - system
        - description
        - tools
        - skills
        - mcp_servers
        - version
      additionalProperties: false
    ManagedModelResponse:
      type: object
      properties:
        id:
          type: string
          example: glm-5.3
        effort:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - low
                    - high
                    - max
              required:
                - type
              additionalProperties: false
            - type: string
              enum:
                - low
                - high
                - max
          description: 新协议返回 {type:档位}，旧协议返回字符串。
        speed:
          type: string
          enum:
            - standard
          example: standard
      required:
        - id
        - speed
      additionalProperties: false
    ManagedAgentToolsetResponse:
      oneOf:
        - title: agent_toolset_20260601
          type: object
          properties:
            type:
              type: string
              enum:
                - agent_toolset_20260601
            default_config:
              $ref: '#/components/schemas/ManagedToolDefaultConfigResponse'
            configs:
              type: array
              items:
                $ref: '#/components/schemas/ManagedBuiltinToolConfigResponse'
          required:
            - type
            - default_config
            - configs
          additionalProperties: false
        - title: mcp_toolset
          type: object
          properties:
            type:
              type: string
              enum:
                - mcp_toolset
            mcp_server_name:
              type: string
            default_config:
              $ref: '#/components/schemas/ManagedToolDefaultConfigResponse'
            configs:
              type: array
              items:
                $ref: '#/components/schemas/ManagedMcpToolConfigResponse'
          required:
            - type
            - mcp_server_name
            - default_config
            - configs
          additionalProperties: false
        - title: custom
          type: object
          properties:
            type:
              type: string
              enum:
                - custom
            name:
              type: string
            description:
              type: string
            input_schema:
              $ref: '#/components/schemas/ManagedCustomToolInputSchema'
          required:
            - type
            - name
            - description
            - input_schema
          additionalProperties: false
    ManagedSkillReference:
      type: object
      properties:
        type:
          type: string
          enum:
            - custom
            - zai
          description: custom 表示当前所有者创建的 Skill；zai 表示平台内置 Skill。
        skill_id:
          type: string
          minLength: 1
          description: Skill ID；必须存在且当前身份可访问。
        version:
          type: string
          minLength: 1
          description: >-
            可省略/null/latest。新协议在 Session 创建/Deployment 触发时固定，旧协议每次沙箱启动解析；具体 ID
            固定对应版本。
          nullable: true
          example: latest
      required:
        - type
        - skill_id
      additionalProperties: false
    ManagedMcpServer:
      type: object
      description: >-
        远程 MCP Server。name 在同一配置内必须唯一，并且必须与 tools 中恰好一个
        mcp_toolset.mcp_server_name 相同。
      properties:
        type:
          type: string
          enum:
            - url
          description: 当前只支持 url。
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Server 名称，长度 1–255；同一 mcp_servers 数组内不得重复。
        url:
          type: string
          format: uri
          pattern: ^https://
          maxLength: 2048
          description: 公开 HTTPS Streamable HTTP URL；不得包含凭据、fragment、空 query 或旧式 SSE 路径。
      required:
        - type
        - name
        - url
      additionalProperties: false
      example:
        type: url
        name: knowledge-base
        url: https://mcp.example.com/mcp
    ManagedToolDefaultConfigResponse:
      type: object
      properties:
        enabled:
          type: boolean
        permission_policy:
          $ref: '#/components/schemas/ManagedPermissionPolicy'
      required:
        - enabled
        - permission_policy
      additionalProperties: false
    ManagedBuiltinToolConfigResponse:
      oneOf:
        - type: object
          properties:
            name:
              type: string
              enum:
                - read
                - write
                - edit
                - bash
                - grep
                - find
                - ls
            enabled:
              type: boolean
            permission_policy:
              $ref: '#/components/schemas/ManagedPermissionPolicy'
            type:
              type: string
              enum:
                - read
                - write
                - edit
                - bash
                - grep
                - find
                - ls
          required:
            - name
            - enabled
            - permission_policy
            - type
          additionalProperties: false
          title: 沙箱工具
          description: type/name 若同时提供必须相等。
        - type: object
          properties:
            name:
              type: string
              enum:
                - web_search
            enabled:
              type: boolean
            permission_policy:
              $ref: '#/components/schemas/ManagedPermissionPolicy'
            type:
              type: string
              enum:
                - web_search
            user_location:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - approximate
                city:
                  type: string
                  maxLength: 255
                region:
                  type: string
                  maxLength: 255
                country:
                  type: string
                  pattern: ^[A-Z]{2}$
                timezone:
                  type: string
              required:
                - type
              additionalProperties: false
              nullable: true
          required:
            - name
            - enabled
            - permission_policy
            - type
          additionalProperties: false
          title: web_search
          description: allowed_domains/blocked_domains 暂不接受：配置时 400，不是静默失效。
        - type: object
          properties:
            name:
              type: string
              enum:
                - web_fetch
            enabled:
              type: boolean
            permission_policy:
              $ref: '#/components/schemas/ManagedPermissionPolicy'
            type:
              type: string
              enum:
                - web_fetch
            max_content_tokens:
              type: integer
              minimum: 1
              nullable: true
            url_sources:
              type: object
              nullable: true
              enum:
                - null
              description: 新协议恒为 null；目前不接受对应输入配置。
          required:
            - name
            - enabled
            - permission_policy
            - type
          additionalProperties: false
          title: web_fetch
          description: allowed_domains/blocked_domains 暂不接受：配置时 400，不是静默失效。
    ManagedMcpToolConfigResponse:
      type: object
      properties:
        name:
          type: string
        enabled:
          type: boolean
        permission_policy:
          $ref: '#/components/schemas/ManagedPermissionPolicy'
      required:
        - name
        - enabled
        - permission_policy
      additionalProperties: false
    ManagedCustomToolInputSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - object
          description: 固定为 object。
        properties:
          type: object
          additionalProperties: true
          description: 工具输入字段的 JSON Schema；省略时表示未声明属性。
        required:
          type: array
          items:
            type: string
          description: 必填输入字段名；省略时无必填字段。
      required:
        - type
      additionalProperties: true
    ManagedPermissionPolicy:
      type: object
      properties:
        type:
          type: string
          enum:
            - always_allow
            - always_ask
          description: 工具调用权限策略。always_allow 表示无需确认；always_ask 表示每次调用前请求确认。
      required:
        - type
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        标准的 HTTP Bearer 认证方式，在 [API
        Keys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) 页面获取密钥。

````

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