Introducing Render Sandboxes: a computer for every agent.

Learn more

Creating a deploy-only Render API key for CI

Your CI system needs to start deploys on Render, and nothing more. A full-access API key gives it far more. This tutorial covers a narrower setup:

  • Create a scoped API key with the Deploys: Run permission.
  • Call the deploy endpoint with that key.
  • Wire the call into GitHub Actions.
  • Decide whether CI needs a key at all.

For background on scoped versus classic keys, see Replacing classic Render API keys with scoped API keys.

You need:

  • A Render service in the workspace that CI needs to deploy
  • GitHub Actions or another CI system that triggers your deploys

Create a Deploys: Run key

You create API keys from your Account Settings page in the Render Dashboard. The Render API docs walk through the key creation steps. For CI, the important choice is the permission you grant.

  1. Go to your Account Settings page and click Create API key. Give the key a name and select the workspace that contains the service CI deploys.
  2. Grant the key permissions, and select Run in the Deploys section. The Deploys section of the API keys docs lists what each permission covers. Leave every other permission unset. Your member role in the workspace determines which permissions you can grant.
  3. Click Generate API key. Render shows the key in full only once.
  4. Copy the key straight into your CI system's secret store.

Know what the key can do

Per the Deploys section of the API keys docs, a Deploys: Run key can also cancel deploys and trigger rollbacks. The Run level also covers viewing deploys, their status, and history. Anyone who can read the CI secret has that same control. Keep this in mind when you decide who can view or edit your repository secrets.

Don't commit the key to version control or share it outside your organization, and revoke it if you think it's been compromised.

Trigger a deploy with the API

This tutorial uses the POST /v1/services/{serviceId}/deploys call from the Render API, which triggers a deploy for the service with the provided ID. Replace {serviceId} with the ID of the service CI deploys. Pass that ID to CI as configuration, such as a secret or variable, instead of hardcoding it in the workflow. That way, you can point the same workflow at a different service without editing it.

Optional request body fields include clearCache, commitId, imageUrl, and deployMode. Check each field's allowed values in the Trigger deploy API reference. The examples set only commitId, to the Git commit SHA to deploy. Without commitId, Render deploys the latest commit on the service's connected branch, so setting it ties each deploy to the commit your workflow ran against.

A minimal request looks like this (replace <COMMIT_SHA> with the commit you want to deploy):

Turn off auto-deploy for the service

Before you add the workflow, turn off auto-deploy for the service. Render can automatically deploy your application each time you merge a change to your codebase. If you leave auto-deploy on, a push can start one deploy from Render and another from CI. Deploying a specific commit with the deploy endpoint doesn't disable auto-deploys for the service. Toggle auto-deploys in the Render Dashboard or with the Update service endpoint. If a Blueprint defines the service, set autoDeployTrigger: off in render.yaml instead.

Wire it into GitHub Actions

Store the scoped key as a repository secret named RENDER_API_KEY and the service ID as a repository variable named RENDER_SERVICE_ID. This workflow runs one curl step on every push to main:

The --fail-with-body flag makes the step fail on an error response and still print the response body. You can see why the API rejected the request without rerunning it.

Do you need a key at all?

Sometimes the narrowest option is no key.

Deploy only when checks pass

If a Blueprint defines your service, you control auto-deploys with the autoDeployTrigger field in render.yaml. Set autoDeployTrigger: checksPass and Render triggers a deploy only if the linked branch's CI checks pass. The autoDeployTrigger field has no effect for services that deploy a prebuilt Docker image. If a Blueprint doesn't define your service, you can get the same behavior from the service's Settings page: under Auto-Deploy, choose After CI Checks Pass. Render detects checks from GitHub Actions and from tools that integrate with the GitHub checks API. It doesn't trigger a deploy if it detects no checks for a new commit or if any check fails. Your workflow then only runs checks, so CI needs no key.

Use a deploy hook

Each service has a secret deploy hook URL, available from its Settings tab in the Render Dashboard. A GET or POST request to that URL triggers a deploy, with no special headers required. With a hook, CI needs no API key, but the URL itself is a credential. Share it only with trusted systems, and click Regenerate Hook if you think it's been compromised. To deploy a specific commit, append the ref query parameter with the commit SHA to the hook URL. Unlike the API, deploying a specific commit with a deploy hook turns off auto-deploys for the service.

The deploy hooks docs cover the full request format.

Pick an option

This table summarizes what each option does, so you can match it to what your CI needs:

Situation
Use
A Blueprint defines the service, and you want Render to deploy only if the linked branch's CI checks pass
autoDeployTrigger: checksPass
CI only needs to send a GET or POST request to start a deploy of the service, optionally of a specific commit with the ref query parameter
Deploy hook
CI needs the deploy API's body fields, such as clearCache or deployMode
Deploys: Run key

Troubleshooting

  • Deploys stack up after a push. Only one deploy can run at a time per service. If CI and auto-deploy both fire, disable one.
  • A deploy hook fails. A 404 means no service matches the URL's ID, or its key is invalid. This commonly happens when CI still uses an old hook URL after it was regenerated. Copy the hook URL again from the service's Settings tab. A 409 means the service is suspended or your workspace is otherwise unable to trigger deploys for it. Check the service's state in the Render Dashboard before you retry.
  • A key leaked into logs or a commit. Revoke it.
  • The request targets the wrong service. Check RENDER_SERVICE_ID in your repository variables.

Choose the narrowest option

Use the narrowest option that works:

  1. A checksPass trigger if Render should deploy only when the linked branch's CI checks pass.
  2. A deploy hook if CI only needs to send a GET or POST request to start a deploy, optionally of a specific commit with the ref query parameter.
  3. A Deploys: Run key if CI needs the deploy API's body fields, such as clearCache or deployMode.

Guard the key closely, because a Run key can also cancel deploys and trigger rollbacks.

Next, try these:

  • Pass a deploy ID to the Render API's Retrieve deploy endpoint to get more details about that deploy.
  • The Render CLI also reads an API key from the RENDER_API_KEY environment variable. Its deploys create command triggers deploys.

Frequently asked questions