Delete a batch
Deletes the batch with all its conversions right away.
DELETE
https://api.switchfile.io/v1/batches/{id}Example
Request
curl -X DELETE "https://api.switchfile.io/v1/batches/5c0f1d7a-6a54-4a49-b3c5-0c7d6a1e2f90" \
-H "Authorization: Bearer $SWITCHFILE_API_KEY"const res = await fetch("https://api.switchfile.io/v1/batches/5c0f1d7a-6a54-4a49-b3c5-0c7d6a1e2f90", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
},
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(res.status);<?php
$ch = curl_init('https://api.switchfile.io/v1/batches/5c0f1d7a-6a54-4a49-b3c5-0c7d6a1e2f90');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWITCHFILE_API_KEY'),
],
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException("HTTP $status: $response");
}
echo $status, PHP_EOL;import os
import requests
res = requests.delete(
"https://api.switchfile.io/v1/batches/5c0f1d7a-6a54-4a49-b3c5-0c7d6a1e2f90",
headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)Parameters
Path parameters
idstring (uuid)requiredID of the batch
Headers
X-End-UserstringService keys only: an ID for the visitor you act for (1 to 128 characters: letters, digits and . _ : @ -). Quotas and rate limits then count per visitor.
X-End-User-IpstringRequired with X-End-User: the IP address of the visitor.
Responses
- 204Deleted with all its conversions
401The API key is missing or not valid
UNAUTHENTICATED401 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-unauthenticated", "title": "Unauthenticated", "status": 401, "code": "UNAUTHENTICATED", "detail": "Missing or invalid API key." }403Not allowed: a signed URL is wrong or expired, or X-End-User was sent without a service key
END_USER_NOT_ALLOWED403 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-end-user-not-allowed", "title": "End user not allowed", "status": 403, "code": "END_USER_NOT_ALLOWED", "detail": "The X-End-User header is only allowed with a service key." }404Does not exist for this account
NOT_FOUND404 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-not-found", "title": "Not found", "status": 404, "code": "NOT_FOUND", "detail": "Batch not found." }422Invalid data. errors names the fields
INVALID_DATA422 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-invalid-data", "title": "Invalid data", "status": 422, "code": "INVALID_DATA", "detail": "The request contains invalid data.", "errors": { "to": [ "Expected string" ] } }429Too many requests or a daily quota is used up. See Retry-After
RATE_LIMIT_EXCEEDED429 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded", "title": "Rate limit exceeded", "status": 429, "code": "RATE_LIMIT_EXCEEDED", "detail": "Too many requests. Try again in 12 seconds." }