# Submit a task project candidate

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Compile the current task's project snapshot to produce a candidate for user review. See [Shared information](objects.md) for objects, variables, and environment boundaries.

```text
POST https://api.moi.matrixorigin.cn/v5/workflow/v2/workflow-candidates/submit
```

## Before you call this API

Retain injected service URLs, credentials, Workspace, and short-lived authorization in the current generation task environment. Use complete original authorization header values. Install jq and set the example variables.

## Request body

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
jq -n --slurpfile files "$PROJECT_FILES_JSON" '{project_files:$files[0]}' > request.json
curl -X POST "${MOI_ENDPOINT%/}/workflow/v2/workflow-candidates/submit" \
  -H "X-API-Key: $MOI_API_KEY" \
  -H "X-Workspace-ID: $MOI_WORKSPACE_ID" \
  -H "X-MOI-Runtime-Authorization: $MOI_RUNTIME_AUTHORIZATION" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json
```

:::::
:::::{tab-item} Parameters

Supply only server-writable regular files under workflow/, operators/, and tests/. Do not upload platform evidence or use local absolute paths as server paths. source, summary, catalog_revision, intent, test_status, and test_result cannot be supplied simultaneously. Fully test the same snapshot first, then submit it. An ordinary PAT cannot use this project branch. After submission, wait for task completion and candidate artifact publication before user confirmation. The old source branch requires separate review; these parameters do not apply to it.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `project_files` | object | Required in this branch | Map from project-relative paths to Base64 file bytes, read from the current task working directory. |
| `scope` | object | No | Task scope for submission. When omitted, derived from the validated current task identity. |
| `scope.task_id` | string | No | When supplied, must match the current task. |
| `scope.context_id` | string | No | When supplied, must match the current generation conversation. |

:::::
::::::
:::::::

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "ok": false,
    "message": "项目未形成可用候选"
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | Response information. |
| `data` | object | Result of this operation. |
| `data.ok` | boolean | Whether a usable compiled candidate was obtained; not proof that all tests passed or that it was accepted. |
| `data.candidate_id` | string | Compiled candidate identifier. Read artifact_id for confirmation after task artifact publication. |
| `data.proposal_id` | string | Corresponding confirmation proposal when present. Save it with the candidate and its task. |
| `data.diagnostics` | object[] | Compilation or validation diagnostics. Troubleshoot using message, stage, path, line, and column. |
| `data.test_status` | string | Server-side test projection for the current snapshot. Clients must not claim it passed themselves. |
| `data.test_result` | object | Associated test evidence when present, corresponding to the current executable snapshot. |

:::::
::::::
:::::::

## Error responses

Handle HTTP status and business fields. Historical queries and recovery have dedicated error codes; see [Errors and environments](objects.md#错误与环境). Retain identity, source references, and operation identifiers first, then check state before acting. Do not automatically change Workspace, candidate, or confirmation keys.
