Skip to main content

Create Application

Create a new application (service) in an environment using the Thevenin API.

Endpoint

POST {envId}/app

Authentication

Requires a valid API token with Bearer authentication. See Authentication for details.

Path Parameters

ParameterTypeRequiredDescription
envIdstringYesThe UUID of the environment where the application will be created

Request Body

The request body must be a JSON object with the following structure:

Required Fields

FieldTypeDescription
namestringApplication name (unique within the environment)
sourceobjectSource configuration (see below)
resourceRequestsobjectResource requirements (see below)

Source Object

Specify the container image to deploy:

{
"source": {
"image": {
"name": "nginx",
"tag": "latest"
}
}
}
FieldTypeRequiredDescription
source.image.namestringYesDocker image name (e.g., "nginx", "postgres")
source.image.tagstringYesImage tag (e.g., "latest", "1.21", "alpine")

Resource Requests Object

{
"resourceRequests": {
"cpu": "100m",
"memory": "128Mi",
"filesystemStorage": "1Gi"
}
}
FieldTypeRequiredDescription
cpustringYesCPU request in millicores (e.g., "100m" = 0.1 core, "1000m" = 1 core)
memorystringYesMemory request (e.g., "128Mi", "1Gi")
filesystemStoragestringNoEphemeral storage (e.g., "1Gi", "5Gi")

Optional Fields

Ports

Expose container ports:

{
"ports": [
{
"name": "http",
"number": 80,
"protocol": "TCP"
}
]
}
FieldTypeDescription
namestringPort name for identification
numberintegerPort number (1-65535)
protocolstringProtocol: "TCP" or "UDP" (default: "TCP")

Public Endpoint

Expose the application to the internet:

{
"publicEndpoint": {
"externalPort": 443,
"appPort": 80
}
}
FieldTypeDescription
externalPortintegerExternal port (usually 443 for HTTPS)
appPortintegerInternal application port to route to

Command and Arguments

Override the default container entrypoint:

{
"command": "/bin/sh",
"args": "-c 'echo Hello World'"
}

Volume Mounts

Attach persistent volumes:

{
"volumeMounts": [
{
"volNameRef": "my-data-volume",
"volIdRef": "vol-123",
"path": "/data"
}
]
}

Environment Variables (Variable Sets)

Inject environment variables:

{
"variableSetMounts": [
{
"varSetNameRef": "app-config",
"varSetIdRef": "var-123"
}
]
}

File Mounts

Mount configuration files:

{
"fileMounts": [
{
"fileNameRef": "nginx.conf",
"fileIdRef": "file-123",
"mountPath": "/etc/nginx/nginx.conf",
"fileOwner": "nginx"
}
]
}

Response

Success Response (201 Created)

Returns the created application object:

{
"id": "app-abc123",
"companyIdRef": "company-xyz",
"envIdRef": "env-789",
"name": "nginx-demo",
"version": "1",
"source": {
"image": {
"name": "nginx",
"tag": "latest"
}
},
"ports": [
{
"name": "http",
"number": 80,
"protocol": "TCP",
"hostname": "nginx-demo.thevenin.app"
}
],
"publicEndpoint": {
"externalPort": 443,
"appPort": 80,
"hostname": "nginx-demo.thevenin.app"
},
"resourceRequests": {
"cpu": "100m",
"memory": "128Mi",
"filesystemStorage": "1Gi"
},
"isActive": true,
"isDeleted": false,
"createdBy": "user-456",
"createdAt": "2025-10-31T12:00:00Z"
}

Error Responses

400 Bad Request - Invalid Payload

{
"code": "VALIDATION_FAILED",
"message": "Invalid request body",
"details": "Application name is required"
}

401 Unauthorized - Invalid Token

{
"code": "UNAUTHORIZED",
"message": "Invalid or missing authentication token"
}

403 Forbidden - 2FA Required

{
"error": "2fa_required",
"message": "Two-factor authentication setup is required to access this resource",
"current_aal": "aal1",
"required_aal": "aal2"
}

404 Not Found - Environment Not Found

{
"code": "NOT_FOUND",
"message": "Environment not found"
}

409 Conflict - Name Already Exists

{
"code": "CONFLICT",
"message": "Application with this name already exists in the environment"
}

Example

curl -X POST https://api.thevenin.com/api/v1/{envId}/app \
-H "Authorization: Bearer tvn_your_token_here" \
-H "Content-Type: application/json" \
-d '{
"name": "nginx-demo",
"source": {
"image": {
"name": "nginx",
"tag": "latest"
}
},
"resourceRequests": {
"cpu": "100m",
"memory": "128Mi"
},
"ports": [
{
"name": "http",
"number": 80,
"protocol": "TCP"
}
],
"publicEndpoint": {
"externalPort": 443,
"appPort": 80
},
"isActive": true
}'