Skip to main content
POST
/
deployments
JavaScript
import fs from 'fs';
import Kernel from '@onkernel/sdk';

const client = new Kernel({
  apiKey: process.env['KERNEL_API_KEY'], // This is the default and can be omitted
});

const deployment = await client.deployments.create({
  entrypoint_rel_path: 'src/app.py',
  env_vars: { FOO: 'bar' },
  file: fs.createReadStream('path/to/file'),
  region: 'aws.us-east-1a',
  version: '1.0.0',
});

console.log(deployment.id);
import os
from kernel import Kernel

client = Kernel(
api_key=os.environ.get("KERNEL_API_KEY"), # This is the default and can be omitted
)
deployment = client.deployments.create(
entrypoint_rel_path="src/app.py",
env_vars={
"FOO": "bar"
},
file=b"<binary>",
force=False,
region="aws.us-east-1a",
version="1.0.0",
)
print(deployment.id)
package main

import (
"bytes"
"context"
"fmt"
"io"

"github.com/kernel/kernel-go-sdk"
"github.com/kernel/kernel-go-sdk/option"
)

func main() {
client := kernel.NewClient(
option.WithAPIKey("My API Key"),
)
deployment, err := client.Deployments.New(context.TODO(), kernel.DeploymentNewParams{
EntrypointRelPath: kernel.String("src/app.py"),
EnvVars: map[string]string{
"FOO": "bar",
},
File: io.Reader(bytes.NewBuffer([]byte("<binary>"))),
Region: kernel.DeploymentNewParamsRegionAwsUsEast1a,
Version: kernel.String("1.0.0"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", deployment.ID)
}
curl --request POST \
--url https://api.onkernel.com/deployments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form version=1.0.0 \
--form 'file=<binary>' \
--form entrypoint_rel_path=src/app.py \
--form region=aws.us-east-1a \
--form force=false \
--form 'env_vars={
"FOO": "bar"
}' \
--form 0.file='@example-file' \
--form 1.file='@example-file'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onkernel.com/deployments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version\"\r\n\r\n1.0.0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<binary>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entrypoint_rel_path\"\r\n\r\nsrc/app.py\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"region\"\r\n\r\naws.us-east-1a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"force\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"env_vars\"\r\n\r\n{\r\n \"FOO\": \"bar\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);

$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.onkernel.com/deployments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version\"\r\n\r\n1.0.0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<binary>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entrypoint_rel_path\"\r\n\r\nsrc/app.py\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"region\"\r\n\r\naws.us-east-1a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"force\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"env_vars\"\r\n\r\n{\r\n \"FOO\": \"bar\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.onkernel.com/deployments")

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"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version\"\r\n\r\n1.0.0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<binary>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entrypoint_rel_path\"\r\n\r\nsrc/app.py\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"region\"\r\n\r\naws.us-east-1a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"force\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"env_vars\"\r\n\r\n{\r\n \"FOO\": \"bar\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "id": "rr33xuugxj9h0bkf1rdt2bet",
  "status": "queued",
  "region": "aws.us-east-1a",
  "created_at": "2023-11-07T05:31:56Z",
  "status_reason": "Deployment in progress",
  "entrypoint_rel_path": "src/app.py",
  "env_vars": {},
  "updated_at": "2023-11-07T05:31:56Z"
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data

App deployment data

App deployment request. Provide either file+entrypoint_rel_path or source.

file
file
required

ZIP file containing the application source directory

entrypoint_rel_path
string
required

Relative path to the entrypoint of the application

Example:

"src/app.py"

version
string
default:latest

Version of the application. Can be any string.

Example:

"1.0.0"

source
object

Source from which to fetch application code.

region
string
default:aws.us-east-1a

Region for deployment. Currently we only support "aws.us-east-1a"

Allowed value: "aws.us-east-1a"
Example:

"aws.us-east-1a"

force
boolean
default:false

Allow overwriting an existing app version

Example:

false

env_vars
object

Map of environment variables to set for the deployed application. Each key-value pair represents an environment variable.

Response

Deployment created successfully

Deployment record information.

id
string
required

Unique identifier for the deployment

Example:

"rr33xuugxj9h0bkf1rdt2bet"

status
enum<string>
required

Current status of the deployment

Available options:
queued,
in_progress,
running,
failed,
stopped
Example:

"queued"

region
string
required

Deployment region code

Allowed value: "aws.us-east-1a"
Example:

"aws.us-east-1a"

created_at
string<date-time>
required

Timestamp when the deployment was created

status_reason
string

Status reason

Example:

"Deployment in progress"

entrypoint_rel_path
string

Relative path to the application entrypoint

Example:

"src/app.py"

env_vars
object

Environment variables configured for this deployment

updated_at
string<date-time> | null

Timestamp when the deployment was last updated