Automation response reference
JSON envelopes, streams, exit codes and conditional result fields for the SubFT CLI.
Versioned envelopes
With --json, an ordinary command invocation emits one schema_version 1 document on stdout. Help/version output is Click output, so do not parse those invocations as command envelopes. Prompts and diagnostics use stderr; progress is suppressed. --json can still prompt. The complete unattended script also supplies --yes and explicit nondeterministic choices.
Success has schema_version (integer), ok (true), command (string) and result (object). Failure has schema_version, ok (false), command and error; error contains code (machine-readable string), message (technical text) and details (object). Unknown codes need generic translated feedback in a public interface. Automation branches on code/details and exit status, not message wording. This envelope is independent of SRT/VTT/ASS subtitle serialization.
{
"schema_version": 1,
"ok": true,
"command": "project.bindings",
"result": {
"bindings": []
}
}{
"schema_version": 1,
"ok": false,
"command": "operation.start",
"error": {
"code": "input_required",
"message": "",
"details": {}
}
}The empty message above intentionally omits technical diagnostic wording; it is a shape example. Successful commands may be cancelled with exit 0 and result.cancelled=true. Error details are command/branch-specific.
Envelope field inventory
Fields are required in their stated success/failure branch. result and error.details are command-specific open objects; error.message is technical diagnostic text. The schema version in both examples is checked against the serializer.
| Branch | Field | Meaning |
|---|---|---|
success | schema_version | Required envelope field; see the typed explanation above. |
success | ok | Required envelope field; see the typed explanation above. |
success | command | Required envelope field; see the typed explanation above. |
success | result | Required envelope field; see the typed explanation above. |
failure | schema_version | Required envelope field; see the typed explanation above. |
failure | ok | Required envelope field; see the typed explanation above. |
failure | command | Required envelope field; see the typed explanation above. |
failure | error | Required envelope field; see the typed explanation above. |
failure | error.code | Required envelope field; see the typed explanation above. |
failure | error.message | Required envelope field; see the typed explanation above. |
failure | error.details | Required envelope field; see the typed explanation above. |
Exit codes
Use the process status for broad handling and the stable error code for scoped recovery. Nonzero does not imply that no operation was committed or no file was written.
| Exit | Constant | Meaning |
|---|---|---|
0 | SUCCESS | Success or interactive cancellation; inspect result.cancelled before using an operation ID. |
1 | EXIT_INTERNAL | internal_failure or command_failed: inspect internal diagnostics, do not assume accepted work was undone. |
2 | EXIT_USAGE | invalid_usage: fix command/flag syntax; no automatic retry. |
3 | EXIT_AUTH | authentication_failed: check effective token, gateway and protected configuration. |
4 | EXIT_INPUT_REQUIRED | input_required: provide the missing choice or approval; --yes cannot invent a selection. |
5 | EXIT_LOCAL | local_failure: inspect local files, FFmpeg availability or advisory lock. |
6 | EXIT_GATEWAY | gateway_failure: transport or gateway protocol failed; reconcile any possibly accepted commit before retry. |
7 | EXIT_REMOTE | remote_rejection: stale state or remote action required. preparation_incomplete identifies recoverable source supply. |
8 | EXIT_OPERATION | operation_failed: failed/aborted terminal work, including explicitly applied successful partial output. |
130 | EXIT_INTERRUPTED | interrupted: the caller detached; accepted server work continues unless separately aborted. |
Stable error mappings
These machine codes map to the process exits above. Handle unknown codes with a translated generic error; details may retain accepted operation IDs or written partial results.
| Code | Exit | Meaning |
|---|---|---|
authentication_failed | 3 | authentication_failed: check effective token, gateway and protected configuration. |
command_failed | 1 | internal_failure or command_failed: inspect internal diagnostics, do not assume accepted work was undone. |
gateway_failure | 6 | gateway_failure: transport or gateway protocol failed; reconcile any possibly accepted commit before retry. |
input_required | 4 | input_required: provide the missing choice or approval; --yes cannot invent a selection. |
internal_failure | 1 | internal_failure or command_failed: inspect internal diagnostics, do not assume accepted work was undone. |
interrupted | 130 | interrupted: the caller detached; accepted server work continues unless separately aborted. |
invalid_usage | 2 | invalid_usage: fix command/flag syntax; no automatic retry. |
local_failure | 5 | local_failure: inspect local files, FFmpeg availability or advisory lock. |
operation_failed | 8 | operation_failed: failed/aborted terminal work, including explicitly applied successful partial output. |
remote_rejection | 7 | remote_rejection: stale state or remote action required. preparation_incomplete identifies recoverable source supply. |
Command result fields
These inventories are unions of actual result branches, not a list of fields required on every response. Types describe the documented serialized values; dictionaries remain open where source declares Any. The default successful final stage is used for export unless explicit artifact selectors change it.
login
Verify and store an API token for its gateway. Use the hidden prompt or protected environment.
| Field | Serialized type | Meaning |
|---|---|---|
api_url | string | Verified gateway/account or credential origin; no token secret is returned. |
credential_source | string | Verified gateway/account or credential origin; no token secret is returned. |
user_id | string | Verified gateway/account or credential origin; no token secret is returned. |
logout
Remove only the locally stored token. Environment authentication remains active; server revocation is separate.
| Field | Serialized type | Meaning |
|---|---|---|
api_url | string | Verified gateway/account or credential origin; no token secret is returned. |
environment_authentication_active | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
stored_token_removed | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
operation.apply
Wait if needed, select saved successful artifacts, and write/register local outputs. Failed inputs are unavailable; partial export needs explicit approval.
| Field | Serialized type | Meaning |
|---|---|---|
allowed_actions | array<string> | Actions allowed by the current canonical operation state. |
cancelled | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
content_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
display_status | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
event_sequence | integer | Monotonic event sequence or canonical state revision. |
execution_state | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
finished_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
operation_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
outcome | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
output_target | string | Subtitle output selector, never the --json envelope format. |
outputs | array<string> | Local output paths; on partial failure inspect error.details.result.outputs. |
partial | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
path | string | Normalized local path for this binding/synchronization. |
phase_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
preparation_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
project_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
selected_artifact_ids | array<string> | Immutable successful stage IDs selected for this export. |
started_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
state_version | integer | Monotonic event sequence or canonical state revision. |
unchanged_outputs | integer | Accepted supplies, identical unchanged outputs or newly written outputs; retain counts after partial failure. |
updated_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
written_outputs | integer | Accepted supplies, identical unchanged outputs or newly written outputs; retain counts after partial failure. |
operation.start
Preflight synchronized media, prepare selected sources, estimate, confirm charges, commit and supply. Wait or detach after acceptance; export is separate.
| Field | Serialized type | Meaning |
|---|---|---|
allowed_actions | array<string> | Actions allowed by the current canonical operation state. |
available_credits | integer | Account balance or quoted charge before commit; compare with approval, not processing duration. |
cancelled | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
content_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
detached | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
display_status | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
event_sequence | integer | Monotonic event sequence or canonical state revision. |
execution_state | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
finished_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
operation_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
outcome | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
path | string | Normalized local path for this binding/synchronization. |
phase_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
preparation_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
preparation_failures | array<object> | Source failures with media_path, content_id and failure_code; resupply only eligible preparations. |
preparation_incomplete | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
project_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
required_credits | integer | Account balance or quoted charge before commit; compare with approval, not processing duration. |
sources_accepted | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
started_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
state_version | integer | Monotonic event sequence or canonical state revision. |
updated_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
operation.supply
Resume eligible awaiting_client/awaiting_retry sources on the existing committed operation. Terminal processing recovery starts a new operation instead.
| Field | Serialized type | Meaning |
|---|---|---|
allowed_actions | array<string> | Actions allowed by the current canonical operation state. |
content_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
display_status | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
event_sequence | integer | Monotonic event sequence or canonical state revision. |
execution_state | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
finished_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
operation_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
outcome | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
phase_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
preparation_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
preparation_failures | array<object> | Source failures with media_path, content_id and failure_code; resupply only eligible preparations. |
preparation_incomplete | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
project_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
sources_supplied | integer | Accepted supplies, identical unchanged outputs or newly written outputs; retain counts after partial failure. |
started_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
state_version | integer | Monotonic event sequence or canonical state revision. |
updated_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
The following checked inventory lists fields inside object/array branches. It is an inventory, not a response envelope. Array items use []. Cancellation may omit the entire object. Types and meanings follow the field descriptions above; counters use the nested lifecycle schemas.
{
"preparation_failures[]": [
"content_id",
"failure_code",
"path"
]
}operation.watch
Reattach to canonical operation state with realtime hints and HTTP polling. Ctrl-C detaches without aborting accepted work.
| Field | Serialized type | Meaning |
|---|---|---|
allowed_actions | array<string> | Actions allowed by the current canonical operation state. |
content_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
display_status | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
event_sequence | integer | Monotonic event sequence or canonical state revision. |
execution_state | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
failures | array<object> | Unavailable contents with media_path, content_id and technical reason; do not export failed inputs. |
finished_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
operation_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
outcome | string | null | Canonical execution/display/terminal outcome; terminal outcome may be absent while active. |
phase_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
preparation_counts | object | Named canonical counters for content, phases or preparation. Counts are not independent lifecycle statuses. |
project_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
started_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
state_version | integer | Monotonic event sequence or canonical state revision. |
updated_at | string | null | Canonical timestamps; null means no recorded timestamp for that event. |
The following checked inventory lists fields inside object/array branches. It is an inventory, not a response envelope. Array items use []. Cancellation may omit the entire object. Types and meanings follow the field descriptions above; counters use the nested lifecycle schemas.
{
"failures[]": [
"content_id",
"media_path",
"reason"
]
}project.bind
Bind a local file or directory to a matching durable project. Bindings are a disposable cache, not inventory synchronization.
| Field | Serialized type | Meaning |
|---|---|---|
binding | object | Selected association: api_url, user_id, path, path_kind, project_id, project_name and project_mode. The bindings-list branch additionally includes bound_at and validated_at. |
cancelled | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
path | string | Normalized local path for this binding/synchronization. |
The following checked inventory lists fields inside object/array branches. It is an inventory, not a response envelope. Array items use []. Cancellation may omit the entire object. Types and meanings follow the field descriptions above; counters use the nested lifecycle schemas.
{
"binding": [
"api_url",
"path",
"path_kind",
"project_id",
"project_mode",
"project_name",
"user_id"
]
}project.bindings
Read cached associations without backend validation or authentication. Optional PATH filters the local list.
| Field | Serialized type | Meaning |
|---|---|---|
bindings | array<object> | Cached associations read/removed in this local scope; removing them changes no backend project. |
The following checked inventory lists fields inside object/array branches. It is an inventory, not a response envelope. Array items use []. Cancellation may omit the entire object. Types and meanings follow the field descriptions above; counters use the nested lifecycle schemas.
{
"bindings[]": [
"api_url",
"bound_at",
"path",
"path_kind",
"project_id",
"project_mode",
"project_name",
"user_id",
"validated_at"
]
}project.forget
Remove local associations scoped to gateway/account; accept missing paths and never archive/delete backend projects.
| Field | Serialized type | Meaning |
|---|---|---|
cancelled | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
path | string | Normalized local path for this binding/synchronization. |
removed | array<object> | Cached associations read/removed in this local scope; removing them changes no backend project. |
The following checked inventory lists fields inside object/array branches. It is an inventory, not a response envelope. Array items use []. Cancellation may omit the entire object. Types and meanings follow the field descriptions above; counters use the nested lifecycle schemas.
{
"removed[]": [
"api_url",
"project_id",
"project_name",
"user_id"
]
}project.sync
Inspect the entire local input and reconcile project inventory. Local scan/probe failures prevent partial submission; stale apply needs a fresh preview.
| Field | Serialized type | Meaning |
|---|---|---|
action | string | File-sync action such as add, replace or up_to_date. |
applied | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
auto_apply_safe | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
binding | object | Selected association: api_url, user_id, path, path_kind, project_id, project_name and project_mode. The bindings-list branch additionally includes bound_at and validated_at. |
cancelled | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
confirmed_moves | array<object> | Reviewed from/to media-path mappings; preserve the preview’s IDs and evidence. |
media | object | Synchronized media summary with id, path and status; present on applicable file-sync branches. |
media_id | string | null | Resource ID supplied by this branch. Save the operation ID before resuming preparation or watching. |
mode | string | file or directory project mode selected from the local input. |
path | string | Normalized local path for this binding/synchronization. |
preview | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
summary | object | Directory-change counts and preview summary; inspect reviewed changes before approving. |
up_to_date | boolean | Branch-specific decision/status flag; absence does not mean False. Cancellation can succeed without creating work. |
The following checked inventory lists fields inside object/array branches. It is an inventory, not a response envelope. Array items use []. Cancellation may omit the entire object. Types and meanings follow the field descriptions above; counters use the nested lifecycle schemas.
{
"binding": [
"api_url",
"path",
"path_kind",
"project_id",
"project_mode",
"project_name",
"user_id"
],
"confirmed_moves[]": [
"new_path",
"old_path"
],
"media": [
"id",
"path",
"status"
],
"media[]": [
"id",
"path",
"status"
]
}status
Verify the effective credential and gateway; environment overrides are not persisted.
| Field | Serialized type | Meaning |
|---|---|---|
api_url | string | Verified gateway/account or credential origin; no token secret is returned. |
credential_source | string | Verified gateway/account or credential origin; no token secret is returned. |
user_id | string | Verified gateway/account or credential origin; no token secret is returned. |
Preparation and partial-output branches
Incomplete start/supply uses exit 7, error.code=remote_rejection and error.details with operation_id, preparation_incomplete=true and preparation_failures. Each preparation failure names path, content_id and failure_code; watch failures instead use media_path, content_id and reason. Keep that operation ID and use eligible source preparation recovery.
Watch failures use exit 8 and details.operation_id, status and failures. Partial apply can write successful files and still return exit 8; details.result retains outputs, written_outputs, unchanged_outputs and selected_artifact_ids plus lifecycle fields. Preserve that nested result before reporting failure. Failed source items themselves cannot be exported. --yes --allow-partial explicitly approves this branch; --allow-partial alone does not grant unattended approval.
Terminal failed work requires a new independently estimated operation. Do not replay operation start as a generic response to every nonzero exit.