with one click
modifying-http-endpoints
Adding or modifying HTTP REST API endpoints in Golem services. Use when creating new endpoints, changing existing API routes, or updating request/response types for the Golem REST API.
Menu
Adding or modifying HTTP REST API endpoints in Golem services. Use when creating new endpoints, changing existing API routes, or updating request/response types for the Golem REST API.
Developing, testing, and running Golem skill tests with the skill test harness. Use when creating new skills, writing scenario YAML files, running skill tests locally, or debugging skill test failures.
Cutting a new docs version, promoting next to a release, and managing versioned documentation content under docs/src/content/. Use when releasing a new Golem version, backporting docs fixes to an older release, renaming a docs version, or adding/removing a version from the version selector.
Final checks before submitting a pull request. Use when preparing to create a PR, to ensure formatting, linting, and the correct tests have been run.
Adding a new component or agent templates to an existing Golem application. Use when adding a second component, adding agent templates like human-in-the-loop or snapshotting to an existing component, or converting a single-component app to multi-component.
Defining environment variables for Golem agents in `golem.yaml` (`env`, `envDefaults`, `secretDefaults`) or via CLI. Use when adding, setting, or overriding env vars on a component, agent, template, preset, or environment, or when wiring template substitution and merge modes.
Adding initial files to Golem agent filesystems via the `files:` section in `golem.yaml`. Use when provisioning local or remote files into an agent's virtual filesystem, setting read-only / read-write permissions, or configuring file mounts at the component, agent, template, or preset level.
| name | modifying-http-endpoints |
| description | Adding or modifying HTTP REST API endpoints in Golem services. Use when creating new endpoints, changing existing API routes, or updating request/response types for the Golem REST API. |
Golem uses Poem with poem-openapi for REST API endpoints. Endpoints are defined as methods on API structs annotated with #[OpenApi] and #[oai].
golem-worker-service/src/api/ — worker lifecycle, invocation, oploggolem-registry-service/src/api/ — components, environments, deployments, plugins, accountsEach service has an api/mod.rs that defines an Apis type tuple and a make_open_api_service function combining all API structs.
Add a method to the appropriate API struct (e.g., WorkerApi, ComponentsApi):
#[oai(
path = "/:component_id/workers/:worker_name/my-action",
method = "post",
operation_id = "my_action"
)]
async fn my_action(
&self,
component_id: Path<ComponentId>,
worker_name: Path<String>,
request: Json<MyRequest>,
token: GolemSecurityScheme,
) -> Result<Json<MyResponse>> {
// ...
}
api/ directory#[OpenApi(prefix_path = "/v1/...", tag = ApiTags::...)]Apis type tuple in api/mod.rsmake_open_api_servicegolem-common/src/model/ with poem_openapi::Object derivegolem-client/build.rsAfter any endpoint change, you must regenerate and rebuild:
cargo make generate-openapi
This builds the services, dumps their OpenAPI YAML, merges them, stores the result in openapi/, and regenerates the public REST API reference under docs/src/content/rest-api/*.mdx (used by the learn.golem.cloud site). Commit both the updated openapi/*.yaml and the updated docs/src/content/rest-api/*.mdx — CI's check-openapi task will fail otherwise.
If the in-tree YAML is already up to date and you just need to refresh the docs (e.g., after editing docs/openapi/gen-openapi.ts itself), use cargo make generate-docs-openapi to skip the service rebuild.
The golem-client crate auto-generates its code from the OpenAPI spec at build time via build.rs. After regenerating the specs:
cargo clean -p golem-client
cargo build -p golem-client
The clean step is necessary because the build script uses rerun-if-changed on the YAML file, but cargo may cache stale generated code.
Add type mappings in golem-client/build.rs to the gen() call's type replacement list. This maps OpenAPI schema names to existing Rust types from golem-common or golem-wasm.
cargo make build
Then run the appropriate tests:
cargo make api-tests-httpcargo make api-tests-grpc#[oai] annotationapi/mod.rs Apis tuple and make_open_api_service (if applicable)golem-common with poem_openapi::Objectgolem-client/build.rs (if applicable)cargo make generate-openapi run — staged changes include both openapi/*.yaml and docs/src/content/rest-api/*.mdxcargo clean -p golem-client && cargo build -p golem-client runcargo make build succeedscargo make fix run before PR