バッチをキャンセルする
curl --request POST \
--url https://api.olostep.com/v1/batches/{batch_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.olostep.com/v1/batches/{batch_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.olostep.com/v1/batches/{batch_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.olostep.com/v1/batches/{batch_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.olostep.com/v1/batches/{batch_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.olostep.com/v1/batches/{batch_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.olostep.com/v1/batches/{batch_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"total_count": 100,
"done_count": 12,
"in_flight_count": 3,
"canceled_count": 87
}{
"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": {}
}{
"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": {}
}{
"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": {}
}{
"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": {}
}バッチ
バッチのキャンセル
バッチのキューにあるアイテムの作業を停止します。すでに実行中のアイテムは完了する場合があります。
POST
/
v1
/
batches
/
{batch_id}
/
cancel
バッチをキャンセルする
curl --request POST \
--url https://api.olostep.com/v1/batches/{batch_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.olostep.com/v1/batches/{batch_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.olostep.com/v1/batches/{batch_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.olostep.com/v1/batches/{batch_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.olostep.com/v1/batches/{batch_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.olostep.com/v1/batches/{batch_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.olostep.com/v1/batches/{batch_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"total_count": 100,
"done_count": 12,
"in_flight_count": 3,
"canceled_count": 87
}{
"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": {}
}{
"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": {}
}{
"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": {}
}{
"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": {}
}送信した直後にタイプミスを見つけましたか? 誰にでも起こることです。バッチをキャンセルすれば、正常に完了したアイテムに対してのみ料金が発生します。
- すでに完了: 請求済み。これらの結果は完了しており、あなたを待っています。
- まだキューにある: 実行されておらず、請求もされません。ここが節約ポイントです。
- 現在実行中: 通常通り、成功したアイテムに対してのみ料金が発生します。
キャンセル後: 実行中のアイテムが完了するかタイムアウトするまで、バッチは
in_progress と表示されることがあります。Batch Info で進捗を確認してください。同じバッチに対して再度キャンセルを呼び出しても安全です。このページは役に立ちましたか?