STACKS API Guide
STACKS API Guide
Overview
The STACKS API lets you manage your containers programmatically. Use it to automate deployments, integrate with CI/CD pipelines, or give your AI agents access to infrastructure — all with built-in spending controls.
Base URL: https://api.stackshosting.cloud/api/v1
Authentication
All API requests require an API key passed in the Authorization header:
Authorization: Bearer sk_stacks_your_key_here
Creating an API Key
- Log in to your STACKS dashboard
- Go to Account Settings → API Keys
- Click Create New Key
- Enter a descriptive name (e.g., “CI/CD Pipeline”, “Agent Key”)
- Select the permissions (scopes) your key needs
- Optionally set a monthly spending cap
- Click Create API Key
Important: Your API key is shown only once at creation. Copy it immediately and store it securely. You will not be able to view it again.
API Key Format
STACKS API keys follow this format:
sk_stacks_{64_character_hex_string}
Security Best Practices
- Never commit API keys to version control
- Never share API keys in chat, email, or public channels
- Use the minimum scopes required for your use case
- Set spending caps on keys used by automated systems
- Rotate keys regularly and revoke unused keys immediately
- Use separate keys for different applications or environments
Permissions (Scopes)
Each API key has specific permissions that control what it can access:
| Scope | Description |
|---|---|
containers:read |
List containers, view status, logs, credentials, and metrics |
containers:create |
Create new containers (subject to spending cap) |
containers:manage |
Start, stop, restart containers and manage connections |
containers:delete |
Permanently delete containers |
A key with only containers:read cannot create, modify, or delete containers. Attempting to use an endpoint that requires a scope your key doesn’t have will return a 403 Forbidden error.
What API Keys Cannot Access
API keys are restricted to container-related operations. The following endpoints require dashboard access (JWT authentication) and cannot be accessed via API key:
- Billing and payment management
- User account settings
- API key management (create/revoke keys from the dashboard only)
- Database browser
- File manager
- IP restriction management
- External access settings
Spending Caps
When creating an API key, you can set a monthly spending cap. This limits the total cost of containers created through that key in a given calendar month.
- If a create request would exceed the spending cap, the API returns
403 Forbiddenwith a clear error message - Spending caps are per-key, not per-account — different keys can have different limits
- Spending resets at the beginning of each calendar month
- Setting no spending cap allows unlimited creation (subject to account limits)
Recommended: Always set a spending cap on keys given to automated systems or AI agents.
Rate Limiting
Each API key has a configurable rate limit (default: 60 requests per minute).
When rate limited, the API returns 429 Too Many Requests. Back off and retry after a short delay.
Endpoints
List Containers
Retrieve all containers associated with your account.
GET /containers
Required scope: containers:read
Example:
curl -H "Authorization: Bearer sk_stacks_YOUR_KEY" \
https://api.stackshosting.cloud/api/v1/containers
PowerShell:
$headers = @{"Authorization"="Bearer sk_stacks_YOUR_KEY"}
Invoke-RestMethod -Uri "https://api.stackshosting.cloud/api/v1/containers" -Headers $headers
Response:
{
"success": true,
"count": 3,
"data": [
{
"id": "usr-abc12345-myapp",
"name": "myapp",
"type": "nodejs",
"plan": "basic",
"status": "running",
"cpu_allocated": 1,
"memory_allocated": 1024,
"storage_allocated": 10240,
"ip_address": "10.52.0.5",
"created_at": "2026-02-25T10:30:00.000Z"
}
]
}
Get Container Status
Get detailed status for a specific container.
GET /containers/status/{container_id}
Required scope: containers:read
Example:
curl -H "Authorization: Bearer sk_stacks_YOUR_KEY" \
https://api.stackshosting.cloud/api/v1/containers/status/usr-abc12345-myapp
Response includes: status, resource allocation, storage details, IP address, version info, and more.
Get Container Credentials
Retrieve connection credentials for a container.
GET /containers/{container_id}/credentials
Required scope: containers:read
Example:
curl -H "Authorization: Bearer sk_stacks_YOUR_KEY" \
https://api.stackshosting.cloud/api/v1/containers/usr-abc12345-mydb/credentials
Note: Returns SSH credentials for compute containers and web UI credentials for managed services (PostgreSQL, Redis, MongoDB, etc.).
Get Container Logs
Retrieve recent logs from a container.
GET /containers/{container_id}/logs?lines=100
Required scope: containers:read
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
lines |
integer | 100 | Number of log lines to return (max: 500) |
Get Container Metrics
Retrieve CPU, memory, disk, and network metrics.
GET /containers/{container_id}/metrics
Required scope: containers:read
Create Container
Create a new container.
POST /containers
Required scope: containers:create
Request body:
{
"name": "my-api-server",
"template": "nodejs",
"plan": "basic"
}
| Field | Required | Description |
|---|---|---|
name |
Yes | Container name (lowercase, alphanumeric, hyphens) |
template |
Yes | Container template (see Available Templates below) |
plan |
No | micro, basic, or standard (default: basic) |
discount_code |
No | Promotional discount code |
Example:
curl -X POST \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"my-api","template":"nodejs","plan":"basic"}' \
https://api.stackshosting.cloud/api/v1/containers
PowerShell:
$headers = @{
"Authorization" = "Bearer sk_stacks_YOUR_KEY"
"Content-Type" = "application/json"
}
$body = '{"name":"my-api","template":"nodejs","plan":"basic"}'
Invoke-RestMethod -Method Post -Uri "https://api.stackshosting.cloud/api/v1/containers" -Headers $headers -Body $body
Response: Returns the created container details including ID, assigned port, SSH credentials (if applicable), and VPC network info.
Start / Stop / Restart Container
Update a container’s running state.
PUT /containers/{container_id}/status
Required scope: containers:manage
Request body:
{
"status": "running"
}
| Value | Action |
|---|---|
running |
Start the container |
stopped |
Stop the container |
restart |
Restart the container |
Example:
curl -X PUT \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"status":"restart"}' \
https://api.stackshosting.cloud/api/v1/containers/usr-abc12345-myapp/status
Delete Container
Permanently delete a container and all its data.
DELETE /containers/{container_id}
Required scope: containers:delete
Warning: This action is irreversible. All container data, volumes, and backups will be permanently removed.
Example:
curl -X DELETE \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
https://api.stackshosting.cloud/api/v1/containers/usr-abc12345-myapp
Download SSH Certificate
Download the SSH private key for a container.
GET /containers/{container_id}/certificate
Required scope: containers:read
Note: Only available for compute containers (Ubuntu, Node.js, Python, etc.), not managed services.
Regenerate SSH Certificate
Generate a new SSH keypair for a container.
POST /containers/{container_id}/certificate/regenerate
Required scope: containers:manage
List Available Templates
Get all container templates.
GET /containers/templates
Required scope: containers:read
Container Connections
Connect containers within your VPC network.
List available targets:
GET /containers/{container_id}/available-targets
Create a connection:
POST /containers/{source_id}/connect/{target_id}
List connections:
GET /containers/{container_id}/connections
Delete a connection:
DELETE /connections/{connection_id}
Required scopes: containers:read for listing, containers:manage for creating/deleting.
Available Templates
| Template | Type | Description |
|---|---|---|
ubuntu |
System | Ubuntu 22.04 LTS with SSH access |
nodejs |
Runtime | Node.js 20 LTS with PM2 process manager |
python |
Runtime | Python 3.12 with Flask, Django, FastAPI |
postgresql |
Database | PostgreSQL 16 with pgAdmin web UI |
mongodb |
Database | MongoDB 7.0 with Mongo Express web UI |
redis |
Database | Redis 7.2 with Redis Commander web UI |
wordpress |
Application | WordPress with PHP 8.1 |
php-apache |
Application | PHP 8.1 with Apache |
nginx |
Web Server | High-performance web server |
haproxy |
Infrastructure | Load balancer with stats page |
Container Plans
| Plan | CPU | RAM | Storage | Price |
|---|---|---|---|---|
micro |
0.1 vCPU | 512 MB | 5 GB | $1/month |
basic |
1 vCPU | 1 GB | 10 GB | $4/month |
standard |
1 vCPU | 2 GB | 20 GB | $5/month |
All plans include VPC network isolation, per-minute billing (capped at monthly rate), and 3x data replication.
Error Codes
| Status | Meaning |
|---|---|
400 |
Bad request — check your request body and parameters |
401 |
Unauthorized — invalid or missing API key |
402 |
Payment required — add a payment method to your account |
403 |
Forbidden — insufficient scope, spending cap reached, or endpoint not available to API keys |
404 |
Not found — container doesn’t exist or doesn’t belong to your account |
429 |
Rate limited — slow down and retry |
500 |
Server error — contact support |
503 |
No capacity — you’ve been added to the waitlist |
Common Error Responses
Invalid API key:
{
"error": "Invalid API key"
}
Revoked API key:
{
"error": "API key has been revoked"
}
Insufficient scope:
{
"error": "Insufficient API key scope",
"required": "containers:delete",
"hint": "This key does not have the required scope. Create a new key with 'containers:delete' permission."
}
Spending cap exceeded:
{
"error": "Spending cap exceeded",
"spending_cap": 10,
"monthly_spent": 9.50,
"hint": "This API key's monthly spending limit has been reached."
}
Endpoint blocked for API keys:
{
"error": "This endpoint requires dashboard access (JWT authentication)",
"hint": "API keys can only access container, deployment, and monitoring endpoints.",
"docs": "https://docs.stackshosting.cloud/api"
}
Common Workflows
Deploy an Application via API
# 1. Create a Node.js container
curl -X POST \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"my-app","template":"nodejs","plan":"basic"}' \
https://api.stackshosting.cloud/api/v1/containers
# 2. Check status (wait for "running")
curl -H "Authorization: Bearer sk_stacks_YOUR_KEY" \
https://api.stackshosting.cloud/api/v1/containers/status/usr-YOUR_ID-my-app
# 3. Get SSH credentials
curl -H "Authorization: Bearer sk_stacks_YOUR_KEY" \
https://api.stackshosting.cloud/api/v1/containers/usr-YOUR_ID-my-app/credentials
# 4. Deploy your code via SSH using the returned credentials
Connect App to Database
# 1. Create a PostgreSQL database
curl -X POST \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"my-db","template":"postgresql","plan":"basic"}' \
https://api.stackshosting.cloud/api/v1/containers
# 2. Connect your app container to the database
curl -X POST \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{}' \
https://api.stackshosting.cloud/api/v1/containers/usr-YOUR_ID-my-app/connect/usr-YOUR_ID-my-db
# 3. Restart your app to pick up the connection environment variables
curl -X PUT \
-H "Authorization: Bearer sk_stacks_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"status":"restart"}' \
https://api.stackshosting.cloud/api/v1/containers/usr-YOUR_ID-my-app/status
AI Agent Workflow
Give your AI agent an API key with a spending cap:
- Create an API key with
containers:read,containers:create,containers:managescopes and a $10/month spending cap - Pass the key to your agent
- The agent can create containers, deploy code, and manage infrastructure
- If the spending cap is reached, the API rejects further container creation — your agent can’t run up the bill
- You get billed monthly as usual through your payment method
Revoking an API Key
- Go to Account Settings → API Keys
- Find the key you want to revoke
- Click the revoke button (X icon)
- Confirm the revocation
Revocation is immediate and permanent. Any system using the revoked key will instantly lose access. There is no way to un-revoke a key — create a new one instead.
Need Help?
- Support: support@stackshosting.cloud
- Documentation: https://docs.stackshosting.cloud
- Status Page: https://status.stackshosting.cloud