INTERNAL - This endpoint is internal and may change without notice. Not recommended for production use.
Creates a new deployment for a project using either a pre-built Docker image or build context.
Authentication: Requires a valid root key with appropriate permissions.
package main
import(
"context"
"os"
unkey "github.com/unkeyed/sdks/api/go/v2"
"github.com/unkeyed/sdks/api/go/v2/models/components"
"log"
)
func main() {
ctx := context.Background()
s := unkey.New(
unkey.WithSecurity(os.Getenv("UNKEY_ROOT_KEY")),
)
res, err := s.Internal.CreateDeployment(ctx, components.V2DeployCreateDeploymentRequestBody{
Project: "my-project",
App: "default",
KeyspaceID: unkey.Pointer("key_abc123"),
Branch: "main",
EnvironmentSlug: "production",
DockerImage: "ghcr.io/user/app:v1.0.0",
GitCommit: &components.V2DeployGitCommit{
CommitSha: unkey.Pointer("a1b2c3d4e5f6"),
CommitMessage: unkey.Pointer("feat: add new feature"),
AuthorHandle: unkey.Pointer("johndoe"),
AuthorAvatarURL: unkey.Pointer("https://avatars.githubusercontent.com/u/123456"),
Timestamp: unkey.Pointer[int64](1704067200000),
},
})
if err != nil {
log.Fatal(err)
}
if res.V2DeployCreateDeploymentResponseBody != nil {
// handle response
}
}from unkey.py import Unkey
with Unkey(
root_key="<YOUR_BEARER_TOKEN_HERE>",
) as unkey:
res = unkey.internal.create_deployment(project="my-project", app="default", branch="main", environment_slug="production", docker_image="ghcr.io/user/app:v1.0.0", keyspace_id="key_abc123", git_commit={
"commit_sha": "a1b2c3d4e5f6",
"commit_message": "feat: add new feature",
"author_handle": "johndoe",
"author_avatar_url": "https://avatars.githubusercontent.com/u/123456",
"timestamp": 1704067200000,
})
# Handle response
print(res)import { Unkey } from "@unkey/api";
const unkey = new Unkey({
rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
});
async function run() {
const result = await unkey.internal.createDeployment({
project: "my-project",
app: "default",
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();curl --request POST \
--url https://api.unkey.com/v2/deploy.createDeployment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"project": "my-project",
"app": "default",
"branch": "main",
"environmentSlug": "production",
"dockerImage": "ghcr.io/user/app:v1.0.0",
"keyspaceId": "key_abc123",
"gitCommit": {
"commitSha": "a1b2c3d4e5f6",
"commitMessage": "feat: add new feature",
"authorHandle": "johndoe",
"authorAvatarUrl": "https://avatars.githubusercontent.com/u/123456",
"timestamp": 1704067200000
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
project: 'my-project',
app: 'default',
branch: 'main',
environmentSlug: 'production',
dockerImage: 'ghcr.io/user/app:v1.0.0',
keyspaceId: 'key_abc123',
gitCommit: {
commitSha: 'a1b2c3d4e5f6',
commitMessage: 'feat: add new feature',
authorHandle: 'johndoe',
authorAvatarUrl: 'https://avatars.githubusercontent.com/u/123456',
timestamp: 1704067200000
}
})
};
fetch('https://api.unkey.com/v2/deploy.createDeployment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.unkey.com/v2/deploy.createDeployment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'project' => 'my-project',
'app' => 'default',
'branch' => 'main',
'environmentSlug' => 'production',
'dockerImage' => 'ghcr.io/user/app:v1.0.0',
'keyspaceId' => 'key_abc123',
'gitCommit' => [
'commitSha' => 'a1b2c3d4e5f6',
'commitMessage' => 'feat: add new feature',
'authorHandle' => 'johndoe',
'authorAvatarUrl' => 'https://avatars.githubusercontent.com/u/123456',
'timestamp' => 1704067200000
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.unkey.com/v2/deploy.createDeployment")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"project\": \"my-project\",\n \"app\": \"default\",\n \"branch\": \"main\",\n \"environmentSlug\": \"production\",\n \"dockerImage\": \"ghcr.io/user/app:v1.0.0\",\n \"keyspaceId\": \"key_abc123\",\n \"gitCommit\": {\n \"commitSha\": \"a1b2c3d4e5f6\",\n \"commitMessage\": \"feat: add new feature\",\n \"authorHandle\": \"johndoe\",\n \"authorAvatarUrl\": \"https://avatars.githubusercontent.com/u/123456\",\n \"timestamp\": 1704067200000\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.unkey.com/v2/deploy.createDeployment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"project\": \"my-project\",\n \"app\": \"default\",\n \"branch\": \"main\",\n \"environmentSlug\": \"production\",\n \"dockerImage\": \"ghcr.io/user/app:v1.0.0\",\n \"keyspaceId\": \"key_abc123\",\n \"gitCommit\": {\n \"commitSha\": \"a1b2c3d4e5f6\",\n \"commitMessage\": \"feat: add new feature\",\n \"authorHandle\": \"johndoe\",\n \"authorAvatarUrl\": \"https://avatars.githubusercontent.com/u/123456\",\n \"timestamp\": 1704067200000\n }\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"requestId": "req_123"
},
"data": {
"deploymentId": "d_abc123xyz"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found",
"errors": [
{
"location": "body.permissions[0].name",
"message": "Must be at least 3 characters long",
"fix": "Ensure the name uses only alphanumeric characters, underscores, and hyphens"
}
]
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}Authorizations
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
Create a deployment from a pre-built Docker image
Project slug
1"my-project"
App slug within the project
1"default"
Git branch name
1"main"
Environment slug (e.g., "production", "staging")
1"production"
Docker image reference to deploy
1"ghcr.io/user/app:v1.0.0"
Optional keyspace ID for authentication context
"key_abc123"
Optional git commit information
Show child attributes
Show child attributes
Response
Deployment created successfully
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.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
package main
import(
"context"
"os"
unkey "github.com/unkeyed/sdks/api/go/v2"
"github.com/unkeyed/sdks/api/go/v2/models/components"
"log"
)
func main() {
ctx := context.Background()
s := unkey.New(
unkey.WithSecurity(os.Getenv("UNKEY_ROOT_KEY")),
)
res, err := s.Internal.CreateDeployment(ctx, components.V2DeployCreateDeploymentRequestBody{
Project: "my-project",
App: "default",
KeyspaceID: unkey.Pointer("key_abc123"),
Branch: "main",
EnvironmentSlug: "production",
DockerImage: "ghcr.io/user/app:v1.0.0",
GitCommit: &components.V2DeployGitCommit{
CommitSha: unkey.Pointer("a1b2c3d4e5f6"),
CommitMessage: unkey.Pointer("feat: add new feature"),
AuthorHandle: unkey.Pointer("johndoe"),
AuthorAvatarURL: unkey.Pointer("https://avatars.githubusercontent.com/u/123456"),
Timestamp: unkey.Pointer[int64](1704067200000),
},
})
if err != nil {
log.Fatal(err)
}
if res.V2DeployCreateDeploymentResponseBody != nil {
// handle response
}
}from unkey.py import Unkey
with Unkey(
root_key="<YOUR_BEARER_TOKEN_HERE>",
) as unkey:
res = unkey.internal.create_deployment(project="my-project", app="default", branch="main", environment_slug="production", docker_image="ghcr.io/user/app:v1.0.0", keyspace_id="key_abc123", git_commit={
"commit_sha": "a1b2c3d4e5f6",
"commit_message": "feat: add new feature",
"author_handle": "johndoe",
"author_avatar_url": "https://avatars.githubusercontent.com/u/123456",
"timestamp": 1704067200000,
})
# Handle response
print(res)import { Unkey } from "@unkey/api";
const unkey = new Unkey({
rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
});
async function run() {
const result = await unkey.internal.createDeployment({
project: "my-project",
app: "default",
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();curl --request POST \
--url https://api.unkey.com/v2/deploy.createDeployment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"project": "my-project",
"app": "default",
"branch": "main",
"environmentSlug": "production",
"dockerImage": "ghcr.io/user/app:v1.0.0",
"keyspaceId": "key_abc123",
"gitCommit": {
"commitSha": "a1b2c3d4e5f6",
"commitMessage": "feat: add new feature",
"authorHandle": "johndoe",
"authorAvatarUrl": "https://avatars.githubusercontent.com/u/123456",
"timestamp": 1704067200000
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
project: 'my-project',
app: 'default',
branch: 'main',
environmentSlug: 'production',
dockerImage: 'ghcr.io/user/app:v1.0.0',
keyspaceId: 'key_abc123',
gitCommit: {
commitSha: 'a1b2c3d4e5f6',
commitMessage: 'feat: add new feature',
authorHandle: 'johndoe',
authorAvatarUrl: 'https://avatars.githubusercontent.com/u/123456',
timestamp: 1704067200000
}
})
};
fetch('https://api.unkey.com/v2/deploy.createDeployment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.unkey.com/v2/deploy.createDeployment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'project' => 'my-project',
'app' => 'default',
'branch' => 'main',
'environmentSlug' => 'production',
'dockerImage' => 'ghcr.io/user/app:v1.0.0',
'keyspaceId' => 'key_abc123',
'gitCommit' => [
'commitSha' => 'a1b2c3d4e5f6',
'commitMessage' => 'feat: add new feature',
'authorHandle' => 'johndoe',
'authorAvatarUrl' => 'https://avatars.githubusercontent.com/u/123456',
'timestamp' => 1704067200000
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.unkey.com/v2/deploy.createDeployment")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"project\": \"my-project\",\n \"app\": \"default\",\n \"branch\": \"main\",\n \"environmentSlug\": \"production\",\n \"dockerImage\": \"ghcr.io/user/app:v1.0.0\",\n \"keyspaceId\": \"key_abc123\",\n \"gitCommit\": {\n \"commitSha\": \"a1b2c3d4e5f6\",\n \"commitMessage\": \"feat: add new feature\",\n \"authorHandle\": \"johndoe\",\n \"authorAvatarUrl\": \"https://avatars.githubusercontent.com/u/123456\",\n \"timestamp\": 1704067200000\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.unkey.com/v2/deploy.createDeployment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"project\": \"my-project\",\n \"app\": \"default\",\n \"branch\": \"main\",\n \"environmentSlug\": \"production\",\n \"dockerImage\": \"ghcr.io/user/app:v1.0.0\",\n \"keyspaceId\": \"key_abc123\",\n \"gitCommit\": {\n \"commitSha\": \"a1b2c3d4e5f6\",\n \"commitMessage\": \"feat: add new feature\",\n \"authorHandle\": \"johndoe\",\n \"authorAvatarUrl\": \"https://avatars.githubusercontent.com/u/123456\",\n \"timestamp\": 1704067200000\n }\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"requestId": "req_123"
},
"data": {
"deploymentId": "d_abc123xyz"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found",
"errors": [
{
"location": "body.permissions[0].name",
"message": "Must be at least 3 characters long",
"fix": "Ensure the name uses only alphanumeric characters, underscores, and hyphens"
}
]
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}{
"meta": {
"requestId": "req_123"
},
"error": {
"detail": "Property foo is required but is missing.",
"status": 404,
"title": "Not Found",
"type": "https://unkey.com/docs/errors/unkey/resource/not_found"
}
}
