arazzo: 1.0.1 info: title: Anthropic Cancel a Message Batch and Confirm summary: Create a batch, request cancellation, then poll until it leaves the canceling state. description: >- A batch cancellation lifecycle. The workflow creates a message batch, initiates cancellation which moves the batch into the canceling state, and then polls the batch until processing has ended — the system may finish any in-progress, non-interruptible requests before finalizing. Every step spells out its request inline — including the inline anthropic-version header the spec defines — so the flow can be read and executed without opening the underlying OpenAPI description. version: 1.0.0 sourceDescriptions: - name: messageBatchesApi url: ../openapi/anthropic-message-batches-api-openapi.yml type: openapi workflows: - workflowId: cancel-and-confirm-batch summary: Create a batch, cancel it, and poll until it finalizes. description: >- Submits a batch, calls Cancel Message Batch to move it into the canceling state, and then polls Retrieve Message Batch until the processing_status becomes ended. inputs: type: object required: - apiKey - requests properties: apiKey: type: string description: A valid Anthropic API key sent in the x-api-key header. requests: type: array description: >- The array of individual batch requests, each with a custom_id and a params object (model, max_tokens, messages). items: type: object steps: - stepId: createBatch description: >- Create a new message batch to demonstrate the cancellation lifecycle. operationId: createMessageBatch parameters: - name: x-api-key in: header value: $inputs.apiKey - name: anthropic-version in: header value: "2023-06-01" requestBody: contentType: application/json payload: requests: $inputs.requests successCriteria: - condition: $statusCode == 200 outputs: batchId: $response.body#/id - stepId: cancelBatch description: >- Initiate cancellation of the batch. The batch enters a canceling state while in-progress, non-interruptible requests are allowed to finish. operationId: cancelMessageBatch parameters: - name: x-api-key in: header value: $inputs.apiKey - name: anthropic-version in: header value: "2023-06-01" - name: message_batch_id in: path value: $steps.createBatch.outputs.batchId successCriteria: - condition: $statusCode == 200 outputs: processingStatus: $response.body#/processing_status cancelInitiatedAt: $response.body#/cancel_initiated_at - stepId: confirmCanceled description: >- Poll the batch status until it leaves the canceling state and reaches ended. Branch back to poll again while the batch is still canceling. operationId: retrieveMessageBatch parameters: - name: x-api-key in: header value: $inputs.apiKey - name: anthropic-version in: header value: "2023-06-01" - name: message_batch_id in: path value: $steps.createBatch.outputs.batchId successCriteria: - condition: $statusCode == 200 outputs: processingStatus: $response.body#/processing_status requestCounts: $response.body#/request_counts onSuccess: - name: stillCanceling type: goto stepId: confirmCanceled criteria: - context: $response.body condition: $.processing_status == 'canceling' type: jsonpath - name: finalized type: end criteria: - context: $response.body condition: $.processing_status == 'ended' type: jsonpath outputs: batchId: $steps.createBatch.outputs.batchId processingStatus: $steps.confirmCanceled.outputs.processingStatus requestCounts: $steps.confirmCanceled.outputs.requestCounts