Request icon

Retrieve all namespaces from a Kestra instance via REST API

Fetch all namespaces from a Kestra instance via the REST API. Automate namespace discovery and inventory for multi-tenant environments with typed outputs.

Categories
Core

Inventory every namespace registered on a Kestra instance with two simple HTTP calls against the Kestra REST API. This blueprint solves namespace discovery for multi-tenant and large platform deployments, where teams need a programmatic, repeatable way to enumerate namespaces for audits, governance reports, access reviews, or downstream automation instead of clicking through the UI.

How it works

The flow runs two sequential HTTP requests, each an io.kestra.plugin.core.http.Request task configured with method: GET and a bearer token header.

  1. get_nr_of_namespaces calls io.kestra.plugin.core.http.Request against /api/v1/namespaces/search?size=1 to read the total field from the response body, giving the full namespace count.
  2. get_all_namespaces reuses that count in /api/v1/namespaces/search?size={{ total }} so a single paginated request returns every namespace.
  3. Two outputs are produced: namespaces (an ARRAY of namespace IDs built from results) and total (an INT count), both ready to feed later tasks or flows.

What you get

  • A complete list of namespace IDs from the target instance.
  • An exact total count for reporting and validation.
  • Structured outputs (ARRAY and INT) consumable by downstream flows.
  • A token-authenticated, idempotent call pattern you can schedule.

Who it's for

  • Platform and DevOps teams running multi-tenant Kestra instances.
  • Administrators performing governance, audit, and access reviews.
  • Engineers building meta-flows that operate across many namespaces.

Why orchestrate this with Kestra

Kestra turns an ad hoc API call into a managed, observable process. You get event and schedule triggers, automatic retries on transient HTTP failures, full execution lineage and logs, and declarative YAML you can version control. A raw curl script or cron job cannot capture outputs as typed values, chain them into other flows, or give you the auditability and replay that orchestration provides.

Prerequisites

  • A reachable Kestra instance and its base URL (set in vars.kestra_local_uri).
  • Permission to call the /api/v1/namespaces/search endpoint.

Secrets

  • KESTRA_API_TOKEN: the bearer token sent in the Authorization header for both requests.

Quick start

  1. Add the KESTRA_API_TOKEN secret to your Kestra instance.
  2. Update vars.kestra_local_uri to point at your instance base URL.
  3. Execute the flow.
  4. Inspect the namespaces and total outputs in the execution view.

How to extend

  • Add a io.kestra.plugin.core.trigger.Schedule trigger to refresh the inventory daily.
  • Loop over outputs.namespaces with Loop to run per-namespace maintenance.
  • Push the list to a data store, Slack channel, or governance report.
  • Diff the count against a previous run to alert on namespace sprawl.

Links

Tasks
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.