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

# 更新批次

> 更新特定批次的元数据。批次创建后只能更新元数据。

<Tip>
  **合并语义：** 元数据更新遵循Stripe的方法——新键会被添加，现有键会被更新，设置为空字符串 `""` 的键会被删除。
</Tip>


## OpenAPI

````yaml zh/openapi/batches.json PATCH /v1/batches/{batch_id}
openapi: 3.0.3
info:
  title: 批处理 API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/batches/{batch_id}:
    patch:
      summary: 更新批次元数据
      description: 更新特定批次的元数据。只有 `metadata` 字段可以更新。遵循Stripe的合并语义：新键被添加，现有键被更新，设置为空字符串的键被删除。
      parameters:
        - name: batch_id
          in: path
          required: true
          schema:
            type: string
          description: 要更新的批次ID。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                metadata:
                  $ref: '#/components/schemas/Metadata'
              required:
                - metadata
            example:
              metadata:
                status: reviewed
                reviewer: jane@example.com
      responses:
        '200':
          description: 批次元数据更新成功。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 批处理 ID
                  object:
                    type: string
                    description: 对象的类型。此端点为 "batch"。
                  status:
                    type: string
                    description: '`in_progress` 或 `completed`'
                  created:
                    type: number
                    description: 创建的纪元时间
                  total_urls:
                    type: number
                    description: 批处理中 URL 的数量
                  completed_urls:
                    type: number
                    description: 已完成的 URL 数量
                  metadata:
                    $ref: '#/components/schemas/Metadata'
              example:
                id: batch_abc123def456
                object: batch
                status: completed
                created: 1704067200
                total_urls: 10
                completed_urls: 10
                metadata:
                  batch_name: Q1 Product Sync
                  status: reviewed
                  reviewer: jane@example.com
        '400':
          description: 错误请求 - 缺少或无效的元数据。详情请参见 [错误请求](/api-reference/errors/bad_request)。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: invalid_metadata
                type: https://docs.olostep.com/api-reference/errors/bad_request
                status: 400
                title: 错误请求
                detail: No metadata field provided. Only metadata can be updated.
                created: 1704067200
                metadata: {}
        '401':
          description: >-
            身份验证凭据缺失或无效。详情请参阅
            [Unauthorized](/api-reference/errors/unauthorized)。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: invalid_api_key
                type: https://docs.olostep.com/api-reference/errors/unauthorized
                status: 401
                title: 未授权
                detail: Your API key is invalid
                created: 1704067200
                metadata: {}
        '404':
          description: 提供的ID未找到批次。详情请参见 [未找到](/api-reference/errors/not_found)。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: batch_not_found
                type: https://docs.olostep.com/api-reference/errors/not_found
                status: 404
                title: 未找到
                detail: Batch not found
                created: 1704067200
                metadata: {}
        '500':
          description: >-
            内部服务器错误。详情请参阅 [Internal
            Error](/api-reference/errors/internal_error)。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: internal_server_error
                type: https://docs.olostep.com/api-reference/errors/internal_error
                status: 500
                title: 内部服务器错误
                detail: An unexpected error occurred
                created: 1704067200
                metadata: {}
      security:
        - Authorization: []
components:
  schemas:
    Metadata:
      type: object
      description: >-
        用于存储对象附加信息的键值对集合。遵循Stripe的验证规则：最多50个键，键最多40个字符（不含方括号），值最多500个字符，所有值以字符串形式存储。
      additionalProperties:
        type: string
        maxLength: 500
        description: 元数据值（最多500个字符）。数字和布尔值会自动转换为字符串。
      maxProperties: 50
      example:
        order_id: '12345'
        customer_name: John Doe
        priority: high
        processed: 'true'
      x-validation-rules:
        max_keys: 50
        key_max_length: 40
        key_forbidden_chars:
          - '['
          - ']'
        value_max_length: 500
        value_types:
          - string
          - number (coerced)
          - boolean (coerced)
    Error:
      type: object
      description: RFC 7807 问题详情错误响应
      properties:
        id:
          type: string
          description: 唯一错误标识符
        object:
          type: string
          enum:
            - error
          description: 始终为 'error'
        code:
          type: string
          description: 机器可读的错误代码
        type:
          type: string
          format: uri
          description: 标识问题类型的URI引用
        status:
          type: integer
          description: HTTP状态码
        title:
          type: string
          description: 简短的、可读的摘要
        detail:
          type: string
          description: 可读的解释
        created:
          type: integer
          description: Unix时间戳
        metadata:
          $ref: '#/components/schemas/Metadata'
        errors:
          type: array
          description: 可选的附加错误详情数组
          items: {}
      required:
        - id
        - object
        - code
        - type
        - status
        - title
        - detail
        - created
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer认证头格式为Bearer <token>，其中<token>是你的认证令牌。

````