# Query data processing tasks

Query the processing tasks and status of knowledge base sources.

```text
GET https://moi.matrixorigin.cn/newmoi/semantic-models/{model_id}/source-jobs
```

## Preparation before calling

First [query the knowledge base list](list-knowledge-bases.md) to obtain the knowledge base ID. Prepare a personal access token and target workspace ID that has access to the target workspace.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through `X-Workspace-ID` Header.
- `$MODEL_ID`: ID of the knowledge base to be queried.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/semantic-models/$MODEL_ID/source-jobs" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Description |
| --- | --- | --- |
| `model_id` | integer | Knowledge base ID. |

## Successful response

Returns `200` on success. Use `job_status`, `error`, and `reconcile_required` to determine whether a task completed, failed, or requires coordination.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "items": [
      {
        "job_id": "job_01",
        "source_id": "src_01",
        "job_status": "pending",
        "updated_at": 1735632000,
        "reconcile_required": false
      }
    ],
    "total": 1,
    "reconcile_required": false
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.items` | object[] | Source processing task list. |
| `data.items[].job_id` | string | Task ID. |
| `data.items[].source_id` | string | The source ID associated with the task. |
| `data.items[].job_status` | string | Current processing status. |
| `data.items[].source_file_id` | string | Source file ID; may be omitted if not applicable. |
| `data.items[].source_table_id` | integer | Source table ID; may be omitted if not applicable. |
| `data.items[].error` | string | Reason for failure; may be omitted if there is no error. |
| `data.items[].updated_at` | integer | Unix timestamp; may be omitted if no value. |
| `data.items[].reconcile_required` | boolean | Whether the task requires state convergence. |
| `data.total` | integer | Total number of tasks. |
| `data.reconcile_required` | boolean | Whether there are tasks that require convergence in the current knowledge base. |

In field paths, `[]` means each item in an array. For example, `data.items[].job_id` is the `job_id` field of each item in `data.items`.

## Error response

```json
{
  "code": "ErrNotFound",
  "msg": "resource not found",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - `model_id` is invalid.
  - Use the knowledge base ID from the response.
* - `401`
  - `ErrUnauthorized`
  - The API Key is invalid or has expired.
  - Check API Key.
* - `403`
  - `ErrForbidden`
  - The caller does not have permission to read the source task.
  - Check workspace and object authorization.
* - `404`
  - `ErrNotFound`
  - The knowledge base does not exist or is not visible.
  - Reconfirm `model_id`.
* - `500`
  - `ErrServer`
  - The service failed to query the task.
  - Keep the desensitized response information and try again.
```

## Follow-up operations

[Reconcile-data-processing-jobs.md] convergence status when any task or knowledge base returns `reconcile_required` to `true`.
