Cancel Validation Job
Cancel an in-progress email validation job. This will stop the validation process immediately.
API Reference
Endpoint
PATCH https://api.cliova.com/v1/webhooks/email-validations/bulk-emails/{id}/cancel?apiKey=
List ID
The id
parameter is the identifier of the validation job you want to cancel (e.g., list_12345
or 11bb57b9-0901-4fb9-9664-6548cdcd3172
)
Parameters
Path Parameters
Parameter | Required | Type | Description |
---|---|---|---|
id | Yes | string | The unique identifier of the validation job |
Query Parameters
Parameter | Required | Type | Description |
---|---|---|---|
apiKey | Yes | string | Your API authentication key |
Code Examples
- JavaScript
- Python
- PHP
cancelValidationJob.js
async function cancelValidationJob(apiKey, listId) {
const baseUrl =
"https://api.cliova.com/v1/webhooks/email-validations/bulk-emails";
const url = `${baseUrl}/${listId}/cancel?apiKey=${apiKey}`;
try {
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error?.message || "Cancel operation failed");
}
const result = await response.json();
return result;
} catch (error) {
console.error("Error canceling validation job:", error);
throw error;
}
}
// ----- Usage Example -----
document.getElementById("cancelButton").addEventListener("click", async () => {
try {
await cancelValidationJob("your_api_key", "list_12345");
console.log("Validation job canceled successfully");
} catch (error) {
console.error("Failed to cancel validation job:", error);
}
});
cancel_validation_job.py
import requests
from typing import Dict
def cancel_validation_job(api_key: str, list_id: str) -> Dict:
"""
Cancel an in-progress validation job.
Args:
api_key (str): Your API authentication key
list_id (str): The ID of the validation job to cancel
Returns:
Dict: Response data from the server
Raises:
requests.exceptions.RequestException: If the cancel operation fails
"""
url = f'https://api.cliova.com/v1/webhooks/email-validations/bulk-emails/{list_id}/cancel'
params = {'apiKey': api_key}
response = requests.patch(url, params=params)
response.raise_for_status()
return response.json()
# Usage Example
if __name__ == '__main__':
try:
result = cancel_validation_job('your_api_key', 'list_12345')
print('Validation job canceled successfully:', result)
except requests.exceptions.RequestException as e:
print('Failed to cancel validation job:', e)
CancelValidationJob.php
<?php
function cancelValidationJob(string $apiKey, string $listId): array {
$baseUrl = 'https://api.cliova.com/v1/webhooks/email-validations/bulk-emails';
$url = sprintf('%s/%s/cancel?apiKey=%s', $baseUrl, urlencode($listId), urlencode($apiKey));
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
if ($response === false) {
$error = curl_error($curl);
curl_close($curl);
throw new RuntimeException("Cancel request failed: $error");
}
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($statusCode !== 200) {
throw new RuntimeException("Cancel failed with status code: $statusCode");
}
return json_decode($response, true);
}
// Usage Example
try {
$result = cancelValidationJob('your_api_key', 'list_12345');
echo "Validation job canceled successfully\n";
print_r($result);
} catch (Exception $e) {
echo "Cancel error: " . $e->getMessage() . "\n";
}
Response
A successful cancel operation returns a JSON response:
{
"success": true,
"message": "Validation job canceled successfully"
}
Best Practices
Cancellation Strategy
Safe Cancellation
Follow these guidelines for safe cancellation:
- Verify the job is actually in progress before canceling
- Keep track of canceled job IDs for audit purposes
- Implement proper error handling for failed cancellations
- Consider implementing a confirmation step in your UI
- Handle partial results appropriately after cancellation
Important Note
- Cancellation is immediate and stops all ongoing validations
- Partial results up to the cancellation point will be preserved
- The job status will be updated to "canceled"
- Cannot cancel jobs that are already completed or archived
Need Help?
Support Resources