# Retry failed files

Retry the failed file specified in the import task. A successful response will not return the running record. Please query the file and running record again to confirm the result.

```text
POST $CLOUDSIGMA_API_BASE/task/retry
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

First [Query task files](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/import-tasks/list-import-task-files.html.md), select only failed files; the task must be in completed or failed state.

Set the operation-specific values used in the request:

- `$TASK_ID`: Import task ID.
- `$FILE_ID`: ID of the failed file.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/task/retry" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{\"task_id\":\"$TASK_ID\",\"ids\":[\"$FILE_ID\"]}"
```

Retry all failed files:

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/task/retry" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{\"task_id\":\"$TASK_ID\"}"
```

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `task_id` | string | yes | Import task ID. |
| `ids` | string[] | No | List of failed file IDs to retry; omitting or passing an empty array will retry the task on all failed files. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Successful response

Returns `200` on success and `data` is `null`. A successful submission does not mean that the file has been processed.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": null
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | null | This interface does not return retry run records. |

## Error response

```json
{
  "code": "ErrForbidden",
  "msg": "permission denied",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 25 30 33

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - The request body is invalid, or the task is not in a completed or failed state.
  - Fix `task_id` and file `ids`, and try again after confirming the task status.
* - `403`
  - `ErrForbidden`
  - The caller does not have permission to operate the task.
  - Check workspace and object authorization.
* - `503`
  - `ErrCoreAuthorizeUnavailable`
  - The service is temporarily unable to complete the authorization check.
  - Try again later.
* - `200`
  - `ErrServer`
  - Service failed to submit retry.
  - Check both HTTP status and `code`.
```

## Follow-up operations

After retrying the acceptance, [Query task files](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/import-tasks/list-import-task-files.html.md) and [Query run records](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/import-tasks/list-import-task-runs.html.md) again to confirm whether the number of failed items has been reduced.
