Skip to Content
Recodocs

Recobot jobs API

Console routes that plan, start, list, steer, and schedule Recobot background jobs without writing job state directly.

5 min read

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

MethodPathPermissionHandlerWhat it does
POST/api/recobot/jobs/routerecobot.jobsrecobot_job_routeRoutes 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}/declinerecobot.jobsrecobot_job_declineRecords decline outcome for a plan (declined or chat).
GET/api/recobot/job-proposals/statsrecobot.jobsrecobot_job_proposal_statsReturns proposal statistics from the database; also requires agents.manage in the handler.
POST/api/recobot/jobs/planrecobot.jobsrecobot_job_planCreates a job plan from request text and optional context; source is promotion when from_run_id is set, otherwise api.
POST/api/recobot/jobsrecobot.jobsrecobot_job_startStarts a job from an existing plan_id for the current owner.
GET/api/recobot/jobsrecobot.jobsrecobot_job_listLists 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.jobsrecobot_job_getLoads one job if visible to the viewer; adds a live field from recobot_jobs.live_status.
POST/api/recobot/jobs/{job_id}/steerrecobot.jobsrecobot_job_steerSends a steer signal with the steered text payload.
POST/api/recobot/jobs/{job_id}/answerrecobot.jobsrecobot_job_answerSends an answer signal with question id and choice.
POST/api/recobot/jobs/{job_id}/schedulerecobot.jobsrecobot_job_scheduleAttaches a schedule rule to a job for the current owner.
DELETE/api/recobot/jobs/schedules/{schedule_id}recobot.jobsrecobot_job_unscheduleRemoves a schedule by id for the current owner.
POST/api/recobot/jobs/schedules/{schedule_id}/runrecobot.jobsrecobot_job_schedule_runTriggers an immediate run for a schedule (trigger_now).
POST/api/recobot/jobs/{job_id}/{action}recobot.jobsrecobot_job_controlSends 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)

FieldTypeConstraints
requeststrmin_length=1, max_length=4000
pagestr | Nonedefault None, max_length=200
modestrdefault "auto"; pattern ^(auto|chat|job)$
from_run_idstr | Nonedefault None, max_length=120
record_keyslist[str] | Nonedefault None, max_length=20

DeclineRequest (POST decline)

FieldTypeConstraints
outcomestrpattern ^(declined|chat)$

PlanRequest (POST plan)

FieldTypeConstraints
requeststrmin_length=1, max_length=4000
job_typestrdefault "upwork_proposals", max_length=60
pagestr | Nonedefault None, max_length=200
record_keyslist[str] | Nonedefault None, max_length=20
from_run_idstr | Nonedefault None, max_length=120

StartRequest (POST /api/recobot/jobs)

FieldTypeConstraints
plan_idstrmin_length=1, max_length=60

SteerRequest

FieldTypeConstraints
textstrmin_length=1, max_length=2000

AnswerRequest

FieldTypeConstraints
question_idstrmin_length=1, max_length=120
choicestrmin_length=1, max_length=200

ScheduleRequest

FieldTypeConstraints
rulestrdefault "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 from recobot_jobs.get with an additional key live set by recobot_jobs.live_status(job).
  • recobot_job_proposal_stats: returns recobot_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:

CodeHTTP status
invalid422
not_found404
forbidden403
conflict409
unavailable503
(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: if action is not pause, resume, or stop, the handler raises fail(404, "not_found", "Unknown action") before calling the domain layer.
  • recobot_job_plan: passes source="promotion" when from_run_id is truthy, otherwise source="api".
  • Listing and reads: _viewer supplies viewer (principal) and see_all (whether agents.manage is authorized). List and get operations pass may_see_all=see_all into recobot_jobs so 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