Recobot jobs API
Console routes that plan, start, list, steer, and schedule Recobot background jobs without writing job state directly.
What this API area is for
A background job has a lifecycle that can outlast the conversation that requested it. The routes let an authorized person plan, start and steer that work while the domain and workflow own persistence and execution.
The Recobot jobs API plans, starts, and steers background jobs; the permission check applies to signed-in users. Handlers delegate persistence and execution to the recobot_jobs domain module and the job’s Temporal workflow; route code does not write job state itself. Visibility is scoped per principal: callers normally see only their own jobs, while holders of agents.manage can see every job when listing or reading details.
Typical flows include routing one request into chat or a recorded plan card, creating a plan, starting work from a plan, listing and inspecting jobs, sending steer or answer signals, controlling pause/resume/stop, and managing a job’s schedule rule, including removing it or calling trigger_now.
Routes
| Method | Path | Permission | Handler | What it does |
|---|---|---|---|---|
| POST | /api/recobot/jobs/route | recobot.jobs | recobot_job_route | Routes one request for chat or job; a job route records and returns a plan card, and nothing runs. |
| POST | /api/recobot/jobs/plan/{plan_id}/decline | recobot.jobs | recobot_job_decline | Records decline outcome for a plan (declined or chat). |
| GET | /api/recobot/job-proposals/stats | recobot.jobs | recobot_job_proposal_stats | Returns proposal statistics from the database; also requires agents.manage in the handler. |
| POST | /api/recobot/jobs/plan | recobot.jobs | recobot_job_plan | Creates a job plan from request text and optional context; source is promotion when from_run_id is set, otherwise api. |
| POST | /api/recobot/jobs | recobot.jobs | recobot_job_start | Starts a job from an existing plan_id for the current owner. |
| GET | /api/recobot/jobs | recobot.jobs | recobot_job_list | Lists jobs for the viewer, optionally filtered by query state; includes all jobs when the viewer has agents.manage. |
| GET | /api/recobot/jobs/{job_id} | recobot.jobs | recobot_job_get | Loads one job if visible to the viewer; adds a live field from recobot_jobs.live_status. |
| POST | /api/recobot/jobs/{job_id}/steer | recobot.jobs | recobot_job_steer | Sends a steer signal with the steered text payload. |
| POST | /api/recobot/jobs/{job_id}/answer | recobot.jobs | recobot_job_answer | Sends an answer signal with question id and choice. |
| POST | /api/recobot/jobs/{job_id}/schedule | recobot.jobs | recobot_job_schedule | Attaches a schedule rule to a job for the current owner. |
| DELETE | /api/recobot/jobs/schedules/{schedule_id} | recobot.jobs | recobot_job_unschedule | Removes a schedule by id for the current owner. |
| POST | /api/recobot/jobs/schedules/{schedule_id}/run | recobot.jobs | recobot_job_schedule_run | Triggers an immediate run for a schedule (trigger_now). |
| POST | /api/recobot/jobs/{job_id}/{action} | recobot.jobs | recobot_job_control | Sends pause, resume, or stop when action matches; otherwise responds as not found. |
Path parameters (plan_id, job_id, schedule_id, action) are plain strings taken from the URL. recobot_job_list accepts an optional query parameter state (str | None).
Request and response models
Request bodies (Pydantic)
All request models use extra="forbid" so unknown JSON fields are rejected.
RouteRequest (POST /api/recobot/jobs/route)
| Field | Type | Constraints |
|---|---|---|
request | str | min_length=1, max_length=4000 |
page | str | None | default None, max_length=200 |
mode | str | default "auto"; pattern ^(auto|chat|job)$ |
from_run_id | str | None | default None, max_length=120 |
record_keys | list[str] | None | default None, max_length=20 |
DeclineRequest (POST decline)
| Field | Type | Constraints |
|---|---|---|
outcome | str | pattern ^(declined|chat)$ |
PlanRequest (POST plan)
| Field | Type | Constraints |
|---|---|---|
request | str | min_length=1, max_length=4000 |
job_type | str | default "upwork_proposals", max_length=60 |
page | str | None | default None, max_length=200 |
record_keys | list[str] | None | default None, max_length=20 |
from_run_id | str | None | default None, max_length=120 |
StartRequest (POST /api/recobot/jobs)
| Field | Type | Constraints |
|---|---|---|
plan_id | str | min_length=1, max_length=60 |
SteerRequest
| Field | Type | Constraints |
|---|---|---|
text | str | min_length=1, max_length=2000 |
AnswerRequest
| Field | Type | Constraints |
|---|---|---|
question_id | str | min_length=1, max_length=120 |
choice | str | min_length=1, max_length=200 |
ScheduleRequest
| Field | Type | Constraints |
|---|---|---|
rule | str | default "weekdays 09:00", max_length=40 |
Responses
Handlers return the value produced by the corresponding recobot_jobs call unless noted below. The route module does not declare response schemas; shape and fields come from that domain layer.
Exceptions documented in the route module:
recobot_job_get: returns the job mapping fromrecobot_jobs.getwith an additional keyliveset byrecobot_jobs.live_status(job).recobot_job_proposal_stats: returnsrecobot_jobs.proposal_stats(_db())with no request body.
Successful JSON bodies for mutating routes are whatever recobot_jobs.route, decline, plan, start, signal, schedule, unschedule, and trigger_now return; consult the Recobot jobs domain specification for those structures.
Behaviour and errors
Validation
FastAPI and Pydantic validate request bodies against the models above. Extra properties are forbidden on every request model. String fields use the Field length and pattern constraints above; this file does not set an HTTP status for those validation failures.
Domain errors (JobError)
Most handlers wrap recobot_jobs calls in _call, which catches recobot_jobs.JobError and raises an HTTP error via fail with a status derived from error.code:
| Code | HTTP status |
|---|---|
invalid | 422 |
not_found | 404 |
forbidden | 403 |
conflict | 409 |
unavailable | 503 |
| (any other code) | 422 |
_call raises fail(status, error.code, str(error)), with status taken from the code map or 422.
Route-specific behaviour
recobot_job_control: ifactionis notpause,resume, orstop, the handler raisesfail(404, "not_found", "Unknown action")before calling the domain layer.recobot_job_plan: passessource="promotion"whenfrom_run_idis truthy, otherwisesource="api".- Listing and reads:
_viewersuppliesviewer(principal) andsee_all(whetheragents.manageis authorized). List and get operations passmay_see_all=see_allintorecobot_jobsso row visibility matches the permission model described in the module docstring. - Signals: steer passes
[body.text]; answer passes[body.question_id, body.choice]; control passes an empty argument list with the action name.
Write trust
POST and DELETE handlers (every route in the table except the three GET routes) call require_console_write_trust(request) before job logic. That check is separate from the route permission table and applies on mutating console calls.
Proposal stats
recobot_job_proposal_stats calls _viewer() (which already enforces recobot.jobs) and then require_role("agents.manage"), so the route permission recobot.jobs is necessary but not sufficient for this endpoint.
How the permission model applies
Console access is deny-by-default. Each handler is registered in the route permission map with a named permission; for this module every listed handler maps to recobot.jobs. At request time, the console gate dependency refuses signed-in users whose role does not hold that permission (HTTP 403 with a denied error). The table is a ceiling: capabilities, the document kernel, or the handler may narrow access further but never widen it beyond the mapped permission.
Handlers also call require_role("recobot.jobs") inside _viewer(), aligning runtime checks with the mapped permission. Holders of agents.manage gain cross-user visibility on list, get, steer, answer, and control via may_see_all; they do not replace recobot.jobs on the route map.
With sign-in off, the caller is Recohut's OS admin on this computer; a bearer-authenticated machine call carries its own grants.
Every handler in this module appears in the permission table; none are missing entries.
How is this page?
Last updated on