CancelTranslationTask — Cancel a Translation Task
Only tasks in the PENDING or PROCESSING status can be cancelled. Completed or failed tasks cannot be cancelled.
Rate limit: 5 QPS per account, concurrency 5.
Credits refund is processed asynchronously. After cancellation, CostCredits may temporarily still show the previously frozen estimated amount. Poll GetTranslationTask and wait for CostCredits to reach 0 to confirm the refund has completed. EstimatedCostCredits is preserved as a historical estimate and does not change.
Request parameters
|
Parameter |
Type |
Required |
Description |
|
TaskId |
string |
Yes |
Required. ID of the translation task to cancel. |
Response parameters
|
Field |
Type |
Description |
|
TaskId |
string |
Task ID. |
|
Status |
string |
Task status after the operation, typically |
Example
CancelTranslationTaskRequest request = new CancelTranslationTaskRequest()
.setTaskId("your-task-id");
CancelTranslationTaskResponse response = client.cancelTranslationTask(request);
System.out.println("TaskId: " + response.getBody().getData().getTaskId());
System.out.println("Status: " + response.getBody().getData().getStatus());
from alibabacloud_realtranslationagent20260622.models import CancelTranslationTaskRequest
request = CancelTranslationTaskRequest(task_id="your-task-id")
response = client.cancel_translation_task(request)
print(f"TaskId: {response.body.data.task_id}")
print(f"Status: {response.body.data.status}")
import { CancelTranslationTaskRequest } from '@alicloud/realtranslationagent20260622';
const request = new CancelTranslationTaskRequest({ taskId: 'your-task-id' });
const response = await client.cancelTranslationTask(request);
console.log('TaskId:', response.body.data.taskId);
console.log('Status:', response.body.data.status);
Sample response
{
"Data": {
"TaskId": "f9c35b0453b",
"Status": "CANCELLED"
}
}
Error codes
|
Code |
Description |
|
|
Parameter validation failed |
|
|
Task does not exist or you have no access |
|
|
Task is in a state that cannot be modified (completed / failed / cancelled) |