Skip to content
Skip to Content

Create a service

POST
/projects/{projectId}/services

A service runs from a Git repository or a Docker image, on the servers you choose. Public services get addresses on opnl.app and your domains; private ones an address in the organization's private network. Nothing runs until the first deployment.

Authorization

bearer
headerAuthorizationBearer <token>

An API key (opk_…) or a CLI token (opc_…).

Path parameters

projectId*string

The project's id.

Header parameters

Idempotency-Key?string

Any unique string up to 255 characters. Sending the same request again with it returns the first answer instead of creating twice.

Lengthlength <= 255

Request body

application/json
  1. body
name*string

A DNS label: up to 32 lowercase letters, digits and hyphens, starting with a letter. Other services in the project reach it by this name.

environmentId?string

Default the project's production environment.

Formatuuid
source*||

Where the service comes from: a Git repository, a Docker image, or a template.

build?||null
startCommand?|

Run by /bin/sh -c; empty keeps the image's own.

exposure?string

public: an opnl.app address and your domains; private: an address in the organization's private network; none: no address.

Value in"public""private""none"
balancer?boolean

The load balancer, for public services: spreads traffic over the replicas, on one or several servers.

replicas?integer

How many copies run. More than one needs the load balancer when public; a service with a volume always runs one.

Range1 <= value <= 100
ports?array<>
Itemsitems <= 20
healthCheck?||null
resources?

Limits per replica.

serverIds?array<>

The servers the service may run on.

Itemsitems <= 50
volumes?array<>
Itemsitems <= 10

Response body

Create a service

application/json
  1. response
id*string
Formatuuid
organizationId*string
projectId*string
Formatuuid
environmentId*string
Formatuuid
name*string
source*||
build*||null
startCommand*string|null
exposure*string
Value in"public""private""none"
balancer*boolean
replicas*integer
ports*array<>
healthCheck*||null
resources*
serverIds*array<>
volumes*array<>
deploymentId*|

The deployment that runs now.

createdBy*string|null
createdAt*string
Formatdate-time
updatedAt*string
Formatdate-time
Example request
curl -X POST "https://openpanel.sh/api/v1/projects/$PROJECT_ID/services" \  -H "Authorization: Bearer $OPENPANEL_TOKEN" \  -H "Content-Type: application/json" \  -d '{  "name": "string",  "source": {    "kind": "git",    "accountId": "3d07c219-0a88-45be-9cfc-91e9d095a1e9",    "repo": "string"  }}'
Example response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "organizationId": "string",  "projectId": "5a8591dd-4039-49df-9202-96385ba3eff8",  "environmentId": "19f5cc2e-7657-437a-9268-83cd3d563563",  "name": "string",  "source": {    "kind": "git",    "accountId": "3d07c219-0a88-45be-9cfc-91e9d095a1e9",    "repo": "string",    "branch": "string",    "path": "string"  },  "build": {    "kind": "auto"  },  "startCommand": "string",  "exposure": "public",  "balancer": true,  "replicas": 0,  "ports": [    {      "protocol": "http",      "port": 0,      "edgePort": 0,      "loopbackPort": 0    }  ],  "healthCheck": {    "kind": "http",    "port": 0,    "path": "string",    "intervalSeconds": 0,    "timeoutSeconds": 0,    "retries": 0  },  "resources": {    "cpus": 0,    "memoryMb": 0  },  "serverIds": [    "427b5970-96c1-461e-8828-5fc6e65bfadd"  ],  "volumes": [    {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "mountPath": "string",      "sizeGb": 0,      "serverId": "10d2345a-e43d-463d-830e-4f5b19b60d41"    }  ],  "deploymentId": "a73c85a1-d857-491e-a6b2-51dce05de7a2",  "createdBy": "string",  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}