Skip to main content
POST
/
v2
/
deploy.createDeployment
Typescript (SDK)
import { Unkey } from "@unkey/api";

const unkey = new Unkey({
  rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
});

async function run() {
  const result = await unkey.internal.createDeployment({
    projectId: "proj_123abc",
    keyspaceId: "key_abc123",
    branch: "main",
    environmentSlug: "production",
    dockerImage: "ghcr.io/user/app:v1.0.0",
    gitCommit: {
      commitSha: "a1b2c3d4e5f6",
      commitMessage: "feat: add new feature",
      authorHandle: "johndoe",
      authorAvatarUrl: "https://avatars.githubusercontent.com/u/123456",
      timestamp: 1704067200000,
    },
  });

  console.log(result);
}

run();
{
  "meta": {
    "requestId": "req_123"
  },
  "data": {
    "deploymentId": "d_abc123xyz"
  }
}

Authorizations

Authorization
string
header
required

Unkey uses API keys (root keys) for authentication. These keys authorize access to management operations in the API. To authenticate, include your root key in the Authorization header of each request:

Authorization: Bearer unkey_123

Root keys have specific permissions attached to them, controlling what operations they can perform. Key permissions follow a hierarchical structure with patterns like resource.resource_id.action (e.g., apis.*.create_key, apis.*.read_api). Security best practices:

  • Keep root keys secure and never expose them in client-side code
  • Use different root keys for different environments
  • Rotate keys periodically, especially after team member departures
  • Create keys with minimal necessary permissions following least privilege principle
  • Monitor key usage with audit logs.

Body

application/json

Create a deployment from a pre-built Docker image

projectId
string
required

Unkey project ID

Minimum string length: 1
Example:

"proj_123abc"

branch
string
required

Git branch name

Minimum string length: 1
Example:

"main"

environmentSlug
string
required

Environment slug (e.g., "production", "staging")

Minimum string length: 1
Example:

"production"

dockerImage
string
required

Docker image reference to deploy

Minimum string length: 1
Example:

"ghcr.io/user/app:v1.0.0"

keyspaceId
string

Optional keyspace ID for authentication context

Example:

"key_abc123"

gitCommit
object

Optional git commit information

Response

Deployment created successfully

meta
object
required

Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The requestId is particularly important when troubleshooting issues with the Unkey support team.

data
object
required
Last modified on February 11, 2026