Create Workplan Api V1 Workstreams Workplans Post
post
/api/v1/workstreams/workplansCreate workplan (writes job_definition)
Creates a new WorkPlan from a template or a domain, with its full definition,
and returns the saved job definition with its identifier.
Only ``name`` is required, and one of ``template_id``, ``domain`` or
``goal_template`` must be given. With ``template_id`` the WorkPlan runs that
template's steps; with a ``domain`` it runs that domain's goal. Tools,
deliverables, limits, input bindings, per-client overrides, default context,
trigger and target selector are all optional and default as ``POST /jobs``
does, except ``max_turns`` 40, ``max_cost_usd`` 10.0 and ``source_tracing``
false.
**Stage-5 convergence (2026-07-02):** this endpoint writes a
``job_definition`` row (the canonical WorkPlan model) instead of the
legacy ``blueprint`` table, through the same insert as ``POST /jobs``; the
response is ``JobDefinitionResponse``.
``client_ids`` (multi-client roster) maps to
``target_selector.type = 'client_list'``; ``client_id`` maps to
``target_selector.type = 'single_client'``; neither maps to
``target_selector.type = 'manual'``. ``client_id``, ``client_ids`` and an
explicit ``target_selector`` are mutually exclusive.
**Authentication Required:** JWT Bearer token
Request bodyapplication/json
| Field | Type | Description |
|---|---|---|
template_id | string (uuid) | null | Source template UUID (workstream_id). Optional: omit it to create the workplan from a domain instead. |
namerequired | string | Workplan name |
description | string | null | Workplan description |
domain | string | null | Domain knowledge key (e.g. 'vat_return'). Names the domain the workplan runs in when no template_id is given; defaults to 'general' with a template. |
goal_template | string | null | Goal template with {{variable}} placeholders. When omitted it is defaulted from the domain's DomainAgent persona. |
tools | string[] | null | Tool names the workplan may use |
deliverables | object[] | null | Deliverables the workplan produces |
max_turns | integer | null | Maximum agent turns per run (default 40) |
max_cost_usd | number | null | Maximum cost in US dollars per run (default 10.0) |
source_tracing | boolean | null | Whether runs trace the source of each figure (default false) |
input_bindings | object | null | Cross-cycle input bindings. |
per_client_overrides | object | null | Per-client overrides, keyed by client id |
default_context | object | null | Default context handed to every run |
trigger_type | "manual" | "schedule" | "webhook" | "email" | "api" | null | How the workplan runs: manual, schedule, webhook, email or api |
schedule_spec | object | null | Structured schedule specification (round-trip source for the editor) |
target_selector | object | null | Who to run for: an object with a 'type' (manual, all_active, client_list, tag, single) and its ids. Mutually exclusive with client_id and client_ids. |
client_id | string (uuid) | null | Client UUID (optional; references platform.clients) |
client_ids | string (uuid)[] | null | Client UUIDs for a multi-client roster β maps to target_selector.type='client_list'. Mutually exclusive with client_id. |
config_overrides | object | Configuration overridesshow nestedEmpty object. |
schedule | string | null | Cron schedule expression (folded into configuration; null = unscheduled) |
schedule_timezone | string | null | IANA timezone for the schedule (folded into configuration) |
skip_weekends | boolean | Shift a fire time landing on Sat/Sun to the next business day |
holiday_calendar | string | null | Shift a fire time landing on a holiday to the next business day: 'UK', 'US', or 'AU' |
max_duration_minutes | integer | null | Per-instance duration guardrail in minutes (folded into configuration) |
human_checkpoints | string[] | null | Sign-off gate checkpoints (folded into configuration); [] clears the gate |
run_mode | string | null | Run posture: propose|auto_run (folded into configuration) |
not_ready_policy | string | Fan-out ready-gating policy for a client whose inputs are not ready at a scheduled fire: 'hold_and_wait' (skip that client, retry next cycle), 'run_and_flag' (fire anyway, flag the cycle β legacy default), or 'skip_cycle' (write a terminal skipped-cycle tombstone). |
schedule_overrides | object | Per-client schedule override map (clientId -> {cron_expr, timezone, skip_weekends, holiday_calendar}). An entry REPLACES the plan-level schedule for that client at fan-out; absent clients use the plan schedule.show nestedEmpty object. |
Responses
201WorkPlan (job_definition) created successfully
| Field | Type | Description |
|---|---|---|
idrequired | string (uuid) | β |
permakey | string | null | Stable human-readable key for the batch/fan-out deep-link URL /workstreams/{ws}/cycles/{permakey}/β¦ (#173). Null on legacy rows. |
namerequired | string | β |
description | string | null | β |
domainrequired | string | β |
goal_templaterequired | string | β |
toolsrequired | string[] | β |
deliverablesrequired | object[] | βitem shapeEmpty object. |
max_turnsrequired | integer | β |
max_cost_usdrequired | number | β |
max_duration_minutesrequired | integer | β |
target_selectorrequired | object | βshow nestedEmpty object. |
per_client_overridesrequired | object | βshow nestedEmpty object. |
input_bindingsrequired | object | βshow nestedEmpty object. |
default_contextrequired | object | βshow nestedEmpty object. |
source_tracingrequired | boolean | β |
human_checkpointsrequired | string[] | β |
schedule | string | null | β |
schedule_timezonerequired | string | β |
skip_weekends | boolean | β |
holiday_calendar | string | null | β |
not_ready_policy | string | Fan-out ready-gating policy for a not-ready client at a scheduled fire. |
schedule_overrides | object | Per-client schedule override map (clientId -> override spec).show nestedEmpty object. |
trigger_type | string | Persisted 'How it runs' trigger choice (manual/schedule/webhook/email/api). |
schedule_spec | object | null | Structured ScheduleEditor spec (opaque JSONB round-trip; cron stays the execution shape). |
is_enabledrequired | boolean | β |
next_run_at | any | null | β |
last_run_at | any | null | β |
statusrequired | string | β |
created_byrequired | string | β |
created_by_name | string | null | Display name behind created_by, for the detail header's 'Created <date> by <who>'. Null when the id no longer resolves to a user β render the date alone rather than an id. |
created_atrequired | any | β |
updated_by | string | null | User id of whoever last edited this WorkPlan. Null for edits predating the column. |
updated_by_name | string | null | Display name behind updated_by, for 'Edited <date> by <who>'. |
updated_atrequired | any | β |
current_version | integer | null | The WorkPlan's own latest config version in job_definition_version; null if no history yet. Not a WorkStream version: see workstream_current_version. |
workstream_current_version | integer | null | Highest workstreams.workstream_version.version of the WorkPlan's WorkStream (default_context.source_workstream_id); null when the WorkPlan has no WorkStream or it has no saved version. |
pinned_workstream_version | integer | null | Pinned version of the WorkPlan's WorkStream: workstreams.workstream_version.version for default_context.source_workstream_id; null = follow the latest. |
upstream_update_available | boolean | True when pinned_workstream_version is set AND the WorkPlan's WorkStream has a version row with a higher number (workstream_current_version). |
cost_so_far_gbp | number | null | Sum of customer-facing GBP cost (hourly_rate_gbp x elapsed) across all cycles for this job definition. Null when no cycles exist. |
hourly_rate_gbp | number | This customer's WorkStream hourly rate in GBP (platform.organizations.workstream_hourly_rate_gbp). Their cost, our revenue β never our compute cost. Serialized because the client RENDERS the rate beside the total ('Β£X total Β· Β£Y avg / client Β· Β£Z/hr rate'); without it the frontend had to hardcode 19, which silently disagrees with a total computed at any other rate. |
total_runs | integer | Count of cycles launched from this job definition. When the list was filtered by workstream_id, this count is scoped to that workstream. |
active_runs | integer | Count of cycles currently in flight (see ACTIVE_CYCLE_STATUSES). Same scoping rule as total_runs. Exists so a caller that only needs 'how many are running' does not have to fetch every cycle of every job to count them client-side β the shell rail did exactly that, at one request per job on every authenticated page load. |
last_cycle_at | any | null | Start timestamp of the most recent cycle (scoped to the requested workstream if filtered). |
last_cycle_state | string | null | Status of the most recent cycle (scoped to the requested workstream if filtered). |
latest_cycle_launch_id | string (uuid) | null | The most recent cycle_launch (the product's Cycle - one launch of a plan) for this job_definition, so list consumers (the shell rail 'Running cycles', the @ 'cycle' picker, the TopicLivePage cycle mention) can link the plan's latest cycle directly. Card 'Every link the app emits uses the cycle's own address': emitting the plan's job id in the cycle slot redirected to the WorkPlan, not the cycle. Null when the plan has no cycle_launch yet. |
latest_cycle_launch_permakey | string | null | The permakey of the most recent cycle_launch - the canonical CYCLE address (/workstreams/{ws}/cycles/{permakey}). List consumers link THIS (not the plan's job permakey) for the cycle slot. Card 'Every link the app emits uses the cycle's own address'. |
latest_cycle_launch_workstream_id | string (uuid) | null | The workstream id of the most recent cycle_launch - the parent WorkStream for the nested cycle URL. Null when the launch has none (should not happen; cycle_launch.workstream_id is NOT NULL). |
latest_cycle_launch_workstream_permakey | string | null | The workstream permakey of the most recent cycle_launch - the canonical WorkStream segment for the nested cycle URL, so a list consumer can build /workstreams/{ws_permakey}/cycles/{launch_permakey} without a second fetch. |
run_mode | WorkplanRunMode | The WorkPlan's effective run posture (S2-READ Β§1a).
``effective`` resolves: plan-level ``configuration.run_mode`` β the
workstream default β ``propose``. ``source`` tells the FE whether the value
was set on this plan or inherited. ``locked`` is the firm-lock governance
flag β always ``False`` in S2.show nested |
autonomy_config | AutonomyConfig | null | Fine-grained autonomy controls from default_context.autonomy_config, or null if unset. |
cohort | WorkplanCohort | Structural facts about the WorkPlan's bound client set (S2-READ Β§1b).
Live exception/ready counts live on the roster's ``summary`` (one
authoritative source); this object carries only the cohort's size + shape.
With no multi-client cohort writer yet, ``total_clients`` resolves to 0/1
and ``selector_kind`` to ``single`` β the shape is frozen, the populating
data is S2-write BE work behind it.show nested |
400Workstream template not found
401Unauthorized
422Validation Error
| Field | Type | Description |
|---|---|---|
detail | ValidationError[] | βitem shape |
curl https://api.dev.arch.ie/api/v1/workstreams/workplans \
-X POST \
-H "Authorization: Bearer sk_..." \
-H "Content-Type: application/json" \
-d '{
"client_id": "b7a9c2d4-1e3f-4a5b-8c6d-7e9f0a1b2c3d",
"config_overrides": {
"currency": "GBP",
"materiality_threshold": 1000
},
"holiday_calendar": "UK",
"name": "Monthly bookkeeping close",
"schedule": "0 9 1 * *",
"schedule_timezone": "Europe/London",
"skip_weekends": true,
"template_id": "3c8e5a17-6d29-4f0b-8e4a-91b2c3d4e5f6"
}'