# Rerun the task

Rerun the file specified in the export task.

```text
POST $CLOUDSIGMA_API_BASE/export/task/$TASK_ID/rerun
```

## 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 export files](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/export-tasks/list-export-task-files.html.md) to confirm the export tasks and failed files to be retried.

Set the operation-specific values used in the request:

- `$TASK_ID`: The export task ID to be retried, fill in the task ID position in the request address.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/export/task/$TASK_ID/rerun" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "files": [
      "export-file_01"
    ]
  }'
```

Retry all failed files:

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

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `task_id` | string | Yes | The ID of the export task to rerun. |

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `files` | string[] | No | Specifies the export record ID to be re-run; if no or an empty array is passed, all files with failed status in the task will be retried. |

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

## Successful response

Returns `200` on success. `data` is `null`, indicating that the rerun request has been accepted; please continue to query the task status and file status to confirm the actual processing results.

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

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` means the retry request has been successfully accepted. |
| `msg` | string | Success message with value `OK`. |
| `data` | null | The interface does not return new task or file results. |

## Error response

Business failure may be returned with HTTP `200` and `code` other than `OK`.

```json
{
  "code": "ErrServer",
  "msg": "Internal server error",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 24 36 28

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - —
  - The request body cannot be parsed; this compatibility path returns the `error` field instead of the standard envelope.
  - Make sure `files` is a string array.
* - `200`
  - `ErrServer`
  - The task or file record does not exist, a failed retry file was not found, or the dependent resource is unavailable.
  - Query the file status first; when `files` is not specified, it will only be called when there is a failed file in the task.
* - `403`
  - `ErrForbidden`
  - The current identity does not have retry permission.
  - Request permission to retry the export task.
* - `503`
  - `ErrCoreAuthorizeUnavailable`
  - Authorization service is temporarily unavailable.
  - Try again later.
```

## Follow-up operations

After retrying the acceptance, use the same task ID [query task status](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/export-tasks/get-export-task-state.html.md) to track the progress.
