> ## Documentation Index
> Fetch the complete documentation index at: https://www.unkey.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Unkey is two separate products. Compute builds, deploys, and runs apps behind a gateway. API Management issues API keys, enforces rate limits, manages identities and permissions, and reports usage. Say which product a page belongs to; a reader can use either without the other.
> Every Unkey API endpoint is an HTTP POST to https://api.unkey.com/v2/{service}.{procedure} with a root key in the Authorization: Bearer header. Root keys are workspace scoped.
> Error codes have the form err:{system}:{category}:{specific} and each has a page at /errors/{system}/{category}/{specific}.
> The word environment means production or preview in Compute. Rate limiting has four meanings on this site; the glossary lists them.

# Deploy from GitHub

> Connect a repository and get your first deployment live on an unkey.app domain.

Connect a GitHub repository to an app (A Compute app: a deployable service inside a project. Not 'your application' in general.) and Unkey builds and deploys it on every push. By the end of this guide you have a project (A group of apps, usually one per codebase or product.), an app connected to the repository, and a production deployment (One built and running version of an app in one environment.) live on a `unkey.app` domain.

To deploy an image you built yourself instead, see [Deploy a container image](https://www.unkey.com/docs/compute/get-started/deploy-an-image.md).

> [!NOTE]
>
> You need a Compute plan before you can deploy. If you don't have one yet, the dashboard asks you to pick one the first time you try (the dialog is titled **Choose a Compute plan**). Only a workspace admin can do that. See [Compute plans](https://www.unkey.com/docs/compute/get-started/plans.md) for what each plan includes.

### 1. Create a project

Open **Projects** in the dashboard and choose **Create project**. Enter a **Project Name**, and Unkey fills in a **Slug** from it. You'll use the slug to refer to the project in the API and the CLI. You can change it, as long as it's unique in your workspace and isn't `default`.

![Create New Project dialog with a project name and the slug generated from it](https://mintcdn.com/unkeyed/UyhrrEiqAqYbNnEX/images/dashboard/compute--get-started-deploy-from-github--create-project.png?fit=max\&auto=format\&n=UyhrrEiqAqYbNnEX\&q=85\&s=c8d256797613dd053797bc0d1c0bd883)

The dashboard then opens the new-app flow. To add an app to a project later, open the project and choose **Create app**.

### 2. Pick the repository

On **Deploy a new app**, pick **GitHub repository**.

![Deploy a new app card offering GitHub repository or Container image, next to the steps Select a source, Choose your app, and Configure and deploy](https://mintcdn.com/unkeyed/704AMOAjXKe6wrR1/images/dashboard/compute--get-started-deploy-from-github--source.png?fit=max\&auto=format\&n=704AMOAjXKe6wrR1\&q=85\&s=ca4c401f01c9127ecde6635d77c47f9c)

If GitHub isn't connected to your workspace yet, choose **Connect GitHub** instead. It sends you to GitHub to install the Unkey GitHub App on an account or organization and choose repositories, then brings you back. The installation belongs to the workspace, so you only do this once.

Click a repository to create the app, named after the repository (with `-2`, `-3`, and so on if the project already has an app by that name). The account menu above the list switches between GitHub accounts and organizations, and **Add GitHub account** at the bottom adds another. If a repository is missing from a listed account, choose **Can't find it? Add repositories on GitHub**.

![Import a GitHub repository card with an account filter, a search field, and a list of repositories](https://mintcdn.com/unkeyed/704AMOAjXKe6wrR1/images/dashboard/compute--get-started-deploy-from-github--select-repository.png?fit=max\&auto=format\&n=704AMOAjXKe6wrR1\&q=85\&s=efd875aa21e49ff41de1c554a020f1a8)

### 3. Check app configuration

The default configuration is enough to build and run most repositories without changes:

* **Branch**: the repository's default branch.
* **Build**: with no Dockerfile set, Unkey detects your language and toolchain and builds the image. See [Build settings](https://www.unkey.com/docs/compute/configure/build-settings.md).
* **Scaling**: 0.25 vCPU, 256 MiB of memory, and one instance in `us-east-1`. See [Runtime settings](https://www.unkey.com/docs/compute/configure/runtime-settings.md).
* **Environment variables**: mark secrets as sensitive to make them write-only. See [Environment variables](https://www.unkey.com/docs/compute/configure/environment-variables.md).

Build and scaling settings you save here apply to both the production and preview environments (A production or preview environment of a Compute app, not the dashboard label on a key.), and auto deploy is enabled for both by default. Your container must listen on the port in the `PORT` environment variable, which is 8080 by default. The port can be changed for each environment individually later by navigating to **App settings** > **Environments**, selecting the environment, and clicking **Configure** on the **Runtime** card.

If you go back and pick a different repository, Unkey connects it to the same app. Leaving before you deploy asks you to discard the app.

### 4. Deploy

Choose **Deploy**. The dashboard deploys the head of the branch to production and opens the deployment page, where the build log streams. The deployment moves through `pending`, `starting`, `building`, `deploying`, `network` (shown as **Assigning Domains**), and `finalizing` to `ready`. If another deployment in the workspace is running, it waits its turn.

![Deployment page for a ready production deployment showing its commit, resources, instances, domains, and network](https://mintcdn.com/unkeyed/cAzvwLdjySjPnSdQ/images/dashboard/compute--get-started-deploy-from-github--deployment.png?fit=max\&auto=format\&n=cAzvwLdjySjPnSdQ\&q=85\&s=77daf8bffdf6c3c323cb5a98851b4167)

At `ready` the app is live. For project `payments`, app `api`, and workspace `acme`, production answers on `payments-api-acme.unkey.app` (or `payments-acme.unkey.app` if the app slug is `default`). The deployment page also lists domains for the environment, the branch, and the exact commit.

If the deployment ends `failed`, the page shows the failed step and an error code. [Deployments](https://www.unkey.com/docs/compute/concepts/deployments.md) lists the codes and how to fix them.

### 5. Push again

From now on GitHub tells Unkey about every push.

* A push to the default branch creates a production deployment. When it reaches `ready`, it becomes the live deployment and the production domains move to it.
* A push to any other branch creates a preview deployment with its own branch domain, so every branch has a URL you can share.
* A pull request from a fork waits in `awaiting_approval` until a project member approves it, because it runs code from outside your repository.

Your auto deploy settings and watch paths determine which pushes get built, and a push that isn't built is recorded as `skipped` with the reason.

The same flow through the API, with a root key in `Authorization: Bearer`. Each call is an HTTP `POST` to `https://api.unkey.com/v2/...` with a JSON body. Required permissions: `project.*.create_project`, `workspace.*.install_github`, `project.*.create_app`, `app.*.connect_repository` (only when `createApp` carries a `git.repository`), `environment.*.create_deployment`, and `unkey:v1:<workspace_id>:projects/*/apps/*/environments/*/deployments/*#read`.

```bash Create the project theme={"system"}
curl -X POST https://api.unkey.com/v2/projects.createProject \
  -H "Authorization: Bearer $UNKEY_ROOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Payments","slug":"payments"}'
```

```bash Install the GitHub App theme={"system"}
# Returns a GitHub URL to open in a browser; installation is workspace wide.
curl -X POST https://api.unkey.com/v2/github.installApp \
  -H "Authorization: Bearer $UNKEY_ROOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```bash Create the app with its repository theme={"system"}
curl -X POST https://api.unkey.com/v2/apps.createApp \
  -H "Authorization: Bearer $UNKEY_ROOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project":"payments","name":"Payments API","slug":"api","git":{"repository":"acme/payments"}}'
```

```bash Deploy the default branch to production theme={"system"}
curl -X POST https://api.unkey.com/v2/deployments.createDeployment \
  -H "Authorization: Bearer $UNKEY_ROOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project":"payments","app":"api","environment":"production","git":{}}'
```

```bash Poll until ready theme={"system"}
curl -X POST https://api.unkey.com/v2/deployments.getDeployment \
  -H "Authorization: Bearer $UNKEY_ROOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"deploymentId":"d_..."}'
```

`getDeployment` returns `status`, `domains`, `availableActions`, and, when the status is `failed`, an `error` with a `code`. Poll until the status is one of `ready`, `failed`, `skipped`, `superseded`, `stopped`, or `cancelled`.

## Next steps

> [card] [Production and preview](https://www.unkey.com/docs/compute/concepts/production-and-preview.md)
>
> Promote, roll back, and what happens to older deployments.

> [card] [Deployments](https://www.unkey.com/docs/compute/concepts/deployments.md)
>
> Every status, the build queue, and the failure codes.

> [card] [Instances and autoscaling](https://www.unkey.com/docs/compute/concepts/instances-and-autoscaling.md)
>
> Change CPU, memory, replicas, and health checks.

> [card] [GitHub integration](https://www.unkey.com/docs/compute/build/github.md)
>
> Fork approval, watch paths, and what Unkey writes back to GitHub.

> [card] [Add API key authentication later](https://www.unkey.com/docs/compute/gateway/api-key-auth.md)
>
> When you want the gateway in front of this app to check API keys before requests reach it, create a keyspace and keys in API Management, then attach a key-auth policy to the environment. Nothing in this guide depends on it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.