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.
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
}
}
'import requests
url = "https://api.unkey.com/v2/deploy.createDeployment"
payload = {
"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
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.unkey.com/v2/deploy.createDeployment"
payload := strings.NewReader("{\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}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}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 bearer tokens for authentication. Public integrations use root keys, while the dashboard proxy uses short-lived JWTs. To authenticate, include the token 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. Legacy permissions use tuple strings like api.*.create_key; resource permissions use Unkey Resource Names plus actions, like unkey:v1:ws_123:keyspaces/*#create_key.
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?
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
}
}
'import requests
url = "https://api.unkey.com/v2/deploy.createDeployment"
payload = {
"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
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.unkey.com/v2/deploy.createDeployment"
payload := strings.NewReader("{\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}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}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"
}
}