---
id: w1/m15/t003
title: Surface plumbing — create accepts `type`; MCP `create_cron_job`; cron run trigger
worker: worker1
status: done
estimate: 40m
depends_on: [w1/m15/t001, w1/m15/t002]
---

## Objective

Plumb the two new types through bex-api's create surface: `POST /v1/services`, GraphQL `createService`, and MCP `create_web_service`/`deploy` accept `type` (mapping `background_worker`/`cron_job` onto the App spec), add the unmirrored Render MCP tool `create_cron_job`, and add the cron run trigger (Render `POST /cron-jobs/{cronJobId}/runs`).

## Context

- The create surface is `POST /v1/services` (an upsert that writes the App CR directly) — body shaped to Render's create schema with a top-level `type` (today `web_service` default / `private_service`); see `docs/ADR006-bex-api.md` §REST. The core verb is `Create`.
- One core, thin adapters: the apps feature lives in `lego/backend/internal/apps/` (`service.go` + `rest.go`, `graphql.go`, `mcp.go`), composed by `lego/backend/internal/api/server.go`. Add `type` handling in `Create` once; each adapter just passes it.
- GraphQL create is `createService(...)`; MCP create tools are `create_web_service`/`deploy` (per `docs/ADR006-bex-api.md` §MCP). `create_cron_job` is an unmirrored Render MCP tool (w1/009). For cron, the spec's `schedule` must be accepted on create.
- Render's cron run trigger is `POST /cron-jobs/{cronJobId}/runs` — a one-off run of the cron's command (bumps a run into the t002 status history).

## Steps

1. Extend `Create` in `lego/backend/internal/apps/service.go` to accept `type` (`background_worker`/`cron_job`) and, for cron, `schedule`, mapping onto the App spec from t001/t002.
2. Thread `type`/`schedule` through the three adapters: `rest.go` (`POST /v1/services` body), `graphql.go` (`createService`), `mcp.go` (`create_web_service`/`deploy`), and add the MCP `create_cron_job` tool.
3. Add the cron run trigger (`POST /cron-jobs/{cronJobId}/runs`) — a core verb that triggers a one-off run, wired at least over REST/MCP.

## Files

- `lego/backend/internal/apps/service.go`
- `lego/backend/internal/apps/{rest.go,graphql.go,mcp.go}`
- `lego/backend/internal/api/server.go` (route/tool wiring)
- `docs/ADR006-bex-api.md` (document the new `type`, `create_cron_job`, and the run trigger)

## Acceptance criteria

- [x] `POST /v1/services`, GraphQL `createService`, and MCP create accept `type` and create a worker or cron App; cron accepts `schedule`.
- [x] MCP `create_cron_job` exists and creates a cron App; `POST /cron-jobs/{cronJobId}/runs` triggers a run visible in status.
- [x] `cd lego/backend && go build ./... && go test ./...` passes.

## Out of scope

- The reconcile mechanisms (t001/t002, prerequisites).
- Dashboard type-awareness (t004).
