Skip to content

Automate with the API

Everything you can do in the Nautobot Cloud Console is also available through the Nautobot Cloud REST API. That means you can drive your Nautobot Cloud deployments from a CI/CD pipeline or a script — build a custom App on every merge and deploy it to a development instance, roll settings and Secrets out with the code that needs them, and promote a validated image to Production behind an approval gate.

Task Guide
Build a custom App in CI and deploy it to an instance Deploy a Custom App from CI
Set instance settings and Secrets as part of a deployment Manage Settings & Secrets
Update, upgrade, promote, and snapshot instances Update, Upgrade & Promote
A complete, ready-to-use GitHub Actions workflow Example: GitHub Actions

How a Deployment Works

Deploying through the API follows the same model as the Console — see How It Works under Customize an Instance:

  1. Stage the change on the instance — a new image, installed Apps and their configuration, or instance settings. Staging marks the instance Pending Update; nothing changes on the running instance yet.
  2. Update the instance to apply everything that is staged. If the change needs a new image, the Update builds it first and then deploys it.
  3. Wait for the instance to return to Healthy and confirm it is running the new image. Fail the pipeline if it doesn't.
sequenceDiagram
    participant CI as Your pipeline
    participant API as Nautobot Cloud API
    participant Inst as Instance
    CI->>API: Upload App package
    CI->>API: Stage image, App config, settings
    Note over API,Inst: Instance is Pending Update
    CI->>API: Update (rollout)
    API->>Inst: Build image, then deploy
    loop until Healthy
        CI->>API: Read instance state
    end
    API-->>CI: Healthy, running the new image

Before You Start

  • An API token. Follow Authenticating to the API to get your token and note your Organization ID and Private Cloud ID from the same page. Store the token as a secret in your CI system, never in the repository.
  • A Project ID. Instances are created in a Project. You can find a Project's ID in its URL in the Console, or by listing projects with the API.
  • An instance on Nautobot 3.2.0 or higher if you plan to deploy custom Apps, pip dependencies, or static files. See the requirements.

Automate the lower environments, gate Production

Let your pipeline deploy to a Development instance on every merge, and require a passing test suite or a manual approval before it touches Production. Environments & Promotion describes the recommended lifecycle.

Working with the API

A few conventions apply across every endpoint:

  • Base URL. All endpoints live under https://nautobot.cloud/api/. Browse them interactively at the API reference (sign in first), or download the OpenAPI schema from https://nautobot.cloud/api/swagger.yaml to generate a client in your language of choice.
  • Authentication. Send your token in the Authorization: Token <token> header on every request.
  • JSON everywhere. Request bodies and responses are JSON. Every object is identified by a UUID id.
  • Pagination. List endpoints are paginated with limit and offset query parameters and return count, next, previous, and results. Follow next until it is null.
  • Nested objects. By default related objects are returned as IDs. Add ?depth=2 to expand them inline — for example, to read an instance's image together with the Apps that image contains.
  • Label your automation. Set an App-Id header (for example App-Id: ci-deploy) and the changes your pipeline makes are attributed to that name in the instance's Event History.

For example, this lists the instances in your Organization with their IDs and current state. The API calls instances resources, so instance endpoints live under /api/resource/:

export NAUTOBOT_CLOUD_TOKEN="<your-token>"
export ORG_ID="<your-organization-id>"

curl -s -H "Authorization: Token $NAUTOBOT_CLOUD_TOKEN" \
     "https://nautobot.cloud/api/resource/?org_id=$ORG_ID&limit=50" | jq '.results[] | {id, name, state}'

Cloud API vs. Nautobot Core API

The Nautobot Cloud API manages your instances — creating, configuring, updating, and backing them up. To automate the data inside an instance (devices, IP addresses, Jobs), use that instance's own Nautobot REST API.