> ## 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.

# バッチのキャンセル

> バッチのキューにあるアイテムの作業を停止します。すでに実行中のアイテムは完了する場合があります。

> [!NOTE]
>
> **送信した直後にタイプミスを見つけましたか？** 誰にでも起こることです。バッチをキャンセルすれば、正常に完了したアイテムに対してのみ料金が発生します。
>
> * **すでに完了:** 請求済み。これらの結果は完了しており、あなたを待っています。
> * **まだキューにある:** 実行されておらず、請求もされません。ここが節約ポイントです。
> * **現在実行中:** 通常通り、成功したアイテムに対してのみ料金が発生します。
>
> すでに消費されたクレジットは返金されませんが、バッチの残りは費用がかかりません。

> [!TIP]
>
> **キャンセル後:** 実行中のアイテムが完了するかタイムアウトするまで、バッチは `in_progress` と表示されることがあります。[Batch Info](https://docs.olostep.com/api-reference/batches/info.md) で進捗を確認してください。同じバッチに対して再度キャンセルを呼び出しても安全です。


## OpenAPI

````yaml ja/openapi/batches.json POST /v1/batches/{batch_id}/cancel
openapi: 3.0.3
info:
  title: バッチ API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/batches/{batch_id}/cancel:
    post:
      summary: バッチをキャンセルする
      description: >-
        バッチの**queued**アイテムをキャンセルします。すでに実行中のアイテムは完了する可能性があります。リクエストボディは必要ありません。同じバッチに対して再度キャンセルを呼び出しても安全です：すでにキャンセルされたアイテムは再度カウントされません。
      parameters:
        - name: batch_id
          in: path
          required: true
          schema:
            type: string
          description: キャンセルするバッチのID。
      responses:
        '200':
          description: バッチ全体のキャンセルサマリー。
          content:
            application/json:
              schema:
                type: object
                properties:
                  total_count:
                    type: integer
                    description: バッチ内の合計アイテム数。
                  done_count:
                    type: integer
                    description: この呼び出しの前にすでに完了またはキャンセルされたアイテム。
                  in_flight_count:
                    type: integer
                    description: すでに実行中のアイテム。これらはキャンセルされません。
                  canceled_count:
                    type: integer
                    description: この呼び出しによってキャンセルされたキューに入っているアイテム。
                required:
                  - total_count
                  - done_count
                  - in_flight_count
                  - canceled_count
              example:
                total_count: 100
                done_count: 12
                in_flight_count: 3
                canceled_count: 87
        '401':
          description: 認証資格情報が欠落しているか無効です。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: invalid_api_key
                type: https://docs.olostep.com/errors/invalid_api_key
                status: 401
                title: 無効または欠落しているAPIキー
                detail: The provided API key is invalid.
                created: 1704067200
                metadata: {}
        '404':
          description: 提供されたIDのバッチが見つからないか、別のチームに属しています。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: not_found
                type: https://docs.olostep.com/errors/not_found
                status: 404
                title: バッチが見つかりません
                detail: No batch with id 'YOUR_BATCH_ID' exists for your team.
                created: 1704067200
                metadata: {}
        '409':
          description: バッチの期限が過ぎたため、キャンセルはもう許可されていません。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: resource_conflict
                type: https://docs.olostep.com/errors/resource_conflict
                status: 409
                title: リソースの競合
                detail: The batch deadline has passed.
                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:
    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
    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)
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer認証ヘッダーの形式はBearer <token>で、<token>はあなたの認証トークンです。

````

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