POST
/
v1
/
projects
/
{project}
/
boxes
/
{name}
/
services
cURL
curl --request POST \
  --url https://api.example.com/v1/projects/{project}/boxes/{name}/services \
  --header 'Content-Type: application/json' \
  --data '
{
  "command": [
    "<string>"
  ],
  "name": "<string>",
  "cwd": "<string>",
  "env": {},
  "port": 1,
  "publish": {
    "name": "<string>",
    "public": true
  },
  "ready": {
    "http": "<string>",
    "port": 1,
    "status": 1,
    "tcp": 1,
    "timeout_secs": 1
  },
  "restart": "<string>",
  "secret_env": [
    "<string>"
  ],
  "stop": {
    "grace_secs": 1,
    "signal": "<string>"
  },
  "tags": {},
  "user": "<string>"
}
'
import requests

url = "https://api.example.com/v1/projects/{project}/boxes/{name}/services"

payload = {
"command": ["<string>"],
"name": "<string>",
"cwd": "<string>",
"env": {},
"port": 1,
"publish": {
"name": "<string>",
"public": True
},
"ready": {
"http": "<string>",
"port": 1,
"status": 1,
"tcp": 1,
"timeout_secs": 1
},
"restart": "<string>",
"secret_env": ["<string>"],
"stop": {
"grace_secs": 1,
"signal": "<string>"
},
"tags": {},
"user": "<string>"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
command: ['<string>'],
name: '<string>',
cwd: '<string>',
env: {},
port: 1,
publish: {name: '<string>', public: true},
ready: {http: '<string>', port: 1, status: 1, tcp: 1, timeout_secs: 1},
restart: '<string>',
secret_env: ['<string>'],
stop: {grace_secs: 1, signal: '<string>'},
tags: {},
user: '<string>'
})
};

fetch('https://api.example.com/v1/projects/{project}/boxes/{name}/services', 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.example.com/v1/projects/{project}/boxes/{name}/services",
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([
'command' => [
'<string>'
],
'name' => '<string>',
'cwd' => '<string>',
'env' => [

],
'port' => 1,
'publish' => [
'name' => '<string>',
'public' => true
],
'ready' => [
'http' => '<string>',
'port' => 1,
'status' => 1,
'tcp' => 1,
'timeout_secs' => 1
],
'restart' => '<string>',
'secret_env' => [
'<string>'
],
'stop' => [
'grace_secs' => 1,
'signal' => '<string>'
],
'tags' => [

],
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/v1/projects/{project}/boxes/{name}/services"

payload := strings.NewReader("{\n \"command\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"cwd\": \"<string>\",\n \"env\": {},\n \"port\": 1,\n \"publish\": {\n \"name\": \"<string>\",\n \"public\": true\n },\n \"ready\": {\n \"http\": \"<string>\",\n \"port\": 1,\n \"status\": 1,\n \"tcp\": 1,\n \"timeout_secs\": 1\n },\n \"restart\": \"<string>\",\n \"secret_env\": [\n \"<string>\"\n ],\n \"stop\": {\n \"grace_secs\": 1,\n \"signal\": \"<string>\"\n },\n \"tags\": {},\n \"user\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

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.example.com/v1/projects/{project}/boxes/{name}/services")
.header("Content-Type", "application/json")
.body("{\n \"command\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"cwd\": \"<string>\",\n \"env\": {},\n \"port\": 1,\n \"publish\": {\n \"name\": \"<string>\",\n \"public\": true\n },\n \"ready\": {\n \"http\": \"<string>\",\n \"port\": 1,\n \"status\": 1,\n \"tcp\": 1,\n \"timeout_secs\": 1\n },\n \"restart\": \"<string>\",\n \"secret_env\": [\n \"<string>\"\n ],\n \"stop\": {\n \"grace_secs\": 1,\n \"signal\": \"<string>\"\n },\n \"tags\": {},\n \"user\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/projects/{project}/boxes/{name}/services")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"command\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"cwd\": \"<string>\",\n \"env\": {},\n \"port\": 1,\n \"publish\": {\n \"name\": \"<string>\",\n \"public\": true\n },\n \"ready\": {\n \"http\": \"<string>\",\n \"port\": 1,\n \"status\": 1,\n \"tcp\": 1,\n \"timeout_secs\": 1\n },\n \"restart\": \"<string>\",\n \"secret_env\": [\n \"<string>\"\n ],\n \"stop\": {\n \"grace_secs\": 1,\n \"signal\": \"<string>\"\n },\n \"tags\": {},\n \"user\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "command": [
    "<string>"
  ],
  "commands": {
    "publish": "<string>",
    "start": "<string>",
    "unpublish": "<string>"
  },
  "name": "<string>",
  "restart": "<string>",
  "restarts": 1,
  "state": "<string>",
  "error": "<string>",
  "last_exit_code": 123,
  "pid": 123,
  "port": 1,
  "tags": {},
  "url": "<string>",
  "user": "<string>",
  "warning": "<string>"
}

Path Parameters

project
string
required
name
string
required

Body

application/json
command
string[]
required
name
string
required
cwd
string | null

Working directory the service is spawned in (absolute path inside the box). The spawn fails if it does not exist.

env
object | null

Environment exported to the child (wins over /etc/boxes-env).

port
integer<int32> | null

The port the service listens on. Optional: a worker service listens on nothing. Required when --publish is given.

Required range: x >= 0
publish
null | object

Optional sugar: also publish the service's port under this name.

ready
null | object

Readiness gate; start blocks until it passes or fails.

restart
string | null

Restart policy: always (default), on-failure, or never.

secret_env
string[] | null

Names of env keys whose values are secret. Their values are redacted in the reproducible commands.start hint; each must be a key of env.

stop
null | object

How the service is asked to stop before it is force-killed.

tags
object | null
user
string | null

Run the service as this box-local user (getpwnam + setuid).

Response

Service started

command
string[]
required
commands
object
required
name
string
required
restart
string
required
restarts
integer<int32>
required
Required range: x >= 0
state
string
required
error
string | null

Set only on a corrupt-spec tombstone: why the on-disk spec did not load.

last_exit_code
integer<int32> | null
pid
integer<int64> | null
port
integer<int32> | null
Required range: x >= 0
tags
object | null
url
string | null
user
string | null
warning
string | null

Present only when a --publish start fell back to public because no auth provider is configured (same warning as box/service publish).