Request Cancellation of a Workspace Resource Task¶
POST /api/v1/workspace/resource/cancel
Overview¶
Requests cancellation of a resource processing task initiated by you in the current workspace.
Before Calling and Usage Steps¶
- Obtain
content.taskIdfrom the resource import/export response, and confirm the task and target workspace. - Use the same Key used when creating the task to place
taskIdin the JSON body and send the cancellation request. - After
content.status=cancelis returned, continue to query Resource Task Progress and verify the target resources; this response does not indicate that the task has been forcibly stopped or rolled back.
The current Key must have workspace.setManage. A task belongs only to the current workspace and the resource UUID of the initiating Key; another Key in the same workspace cannot read or cancel the task even if it has the same role. Rotating the same Key preserves the resource UUID; do not use taskId and the API Key value interchangeably.
Only the status in the task cache, if it still exists, is changed to cancel; the backend performs cooperative checks at resource module boundaries. This does not forcibly terminate an individual operation that is in progress, does not revoke committed resources or files that have already been written, and does not guarantee that all subsequent side effects are prevented. If the task cache does not exist at all, status=cancel is still returned, with no actual task hit count.
Completed tasks may also be marked cancel; the worker thread and cancellation may race, and the subsequent status may become ok/error. This response cannot be used to prove that the task has been canceled or rolled back. After calling, continue to use the same Key to query progress and verify the target resources, especially when a recover import has already partially saved data. This endpoint does not delete the original business data; whether an export file has been published must be read back and verified.
After cancellation or interruption, even if noJsonDataError or an empty success count is subsequently returned, previous modules may still have saved data; this localized message cannot prove that no write occurred.
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or enter: Obtain an OpenAPI Key with the permission for this operation from API Key management in the target workspace. |
Body Request Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| taskId | string | Y | Required non-empty task ID; must use the same workspace and same Key resource identity that created the task, not a file name. Allow null: False Example: resource_task_exampleHow to obtain or enter: Obtain it from content.taskId in the response of Export Resource Task or Import Resource Package. |
Additional Parameter Notes¶
1. API Purpose
Cancel an in-progress workspace resource import or export task.
2. Usage Instructions
You need to pass the taskId obtained from the import/export API.
After the cancellation request is submitted successfully, the API returns:
Notes:
- This response indicates that the task has been marked as canceled
- The final status of the specific task can be confirmed through the task status API
3. Precautions
- Tasks that have completed execution cannot be rolled back
- For an import task that has partially succeeded, data that has already been written is not automatically rolled back
- If you need to confirm whether the cancellation took effect, continue to poll the task status API
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/workspace/resource/cancel' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"taskId":"resource_task_example"}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content.status | string | Fixed value cancel; indicates only that the cancellation request has been processed and may not match any task. |
| content.declaration | object or null | Workspace common declaration attached to non-empty content; can be null or an empty object when not configured. |
{
"code": 200,
"content": {
"status": "cancel",
"declaration": {}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Responses¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | Request field is missing, or the field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | Request JSON syntax is invalid | Request JSON format error | Correct the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | JSON top level is not an object | Part of the JSON file has a format error | Submit an object containing taskId. |
| 403 | ft.Forbidden | The existing task does not belong to the current workspace or the current creating Key, or the Long Task rebuilt status cache lacks ownership information | You do not have permission to perform this operation | Use the original workspace and the original Key that created the task; do not cancel across identities. If it still returns 403 with the correct identity, retain taskId and ask the administrator to check the Long Task cache and logs. |
| 500 | ft.InternalServerError | Task cache/queue, file system, database, or unhandled task status/JSON processing failure | Internal error | First query the current state of the task and resources using the same workspace and same Key. Confirm whether it has been enqueued or partially saved before retrying; do not blindly repeat the import or overwrite data. |