Environments API
Environments are isolated workspaces where you can deploy and manage applications, volumes, files, and other resources.
Available Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /environments | List all environments |
| GET | /environments/{id} | Get environment details |
| GET | /environments/{id}/resource-usage | Get resource usage statistics |
| GET | /environments/{id}/history | Get environment history |
| DELETE | /environments/{id} | Delete an environment |
| POST | /environments/{id}/restore | Restore a previous version |
Environment Object
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "production",
"companyIdRef": "770e8400-e29b-41d4-a716-446655440002",
"resourceQuota": {
"cpu": 10000,
"memory": 16384,
"storage": 102400
},
"resourceUsage": {
"cpu": 3000,
"memory": 4096,
"storage": 20480
},
"isDeleted": false,
"createdBy": "user-123",
"modifiedBy": "user-123",
"version": 1
}
Quick Examples
List Environments
curl -X GET "https://api.thevenin.cloud/environments" \
-H "Authorization: Bearer $API_TOKEN"
Get Environment Details
curl -X GET "https://api.thevenin.cloud/environments/$ENV_ID" \
-H "Authorization: Bearer $API_TOKEN"
Get Resource Usage
curl -X GET "https://api.thevenin.cloud/environments/$ENV_ID/resource-usage" \
-H "Authorization: Bearer $API_TOKEN"
Example response:
{
"environmentId": "660e8400-e29b-41d4-a716-446655440001",
"quota": {
"cpu": 10000,
"memory": 16384,
"storage": 102400
},
"used": {
"cpu": 3000,
"memory": 4096,
"storage": 20480
},
"available": {
"cpu": 7000,
"memory": 12288,
"storage": 81920
},
"utilizationPercent": {
"cpu": 30,
"memory": 25,
"storage": 20
}
}
Get Environment History
curl -X GET "https://api.thevenin.cloud/environments/$ENV_ID/history" \
-H "Authorization: Bearer $API_TOKEN"
Delete Environment
curl -X DELETE "https://api.thevenin.cloud/environments/$ENV_ID" \
-H "Authorization: Bearer $API_TOKEN"
⚠️ Warning: Deleting an environment will affect all applications, volumes, files, and other resources within it.
Resource Management
Understanding Resource Quotas
Each environment has resource quotas limiting:
- CPU: In millicores (1000 = 1 CPU core)
- Memory: In megabytes (MB)
- Storage: In megabytes (MB)
Checking Available Resources
Before creating or updating applications, check available resources:
import requests
API_TOKEN = "tvn_your_token_here"
ENV_ID = "your-env-id"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
# Get resource usage
response = requests.get(
f"https://api.thevenin.cloud/environments/{ENV_ID}/resource-usage",
headers=headers
)
usage = response.json()
available_cpu = usage['available']['cpu']
available_memory = usage['available']['memory']
print(f"Available CPU: {available_cpu} millicores")
print(f"Available Memory: {available_memory} MB")
# Check if we can create an app with 1000 CPU and 512 MB
if available_cpu >= 1000 and available_memory >= 512:
print("✓ Sufficient resources available")
else:
print("✗ Insufficient resources")
Common Use Cases
- Environment Isolation: Separate dev, staging, and production
- Resource Monitoring: Track resource usage and capacity
- Capacity Planning: Understand resource utilization trends
- Multi-tenant Applications: Isolate customer workloads
- Cost Management: Monitor resource allocation by environment
Notes
- Environments are scoped to your company
- Resources are allocated from your company's total quota
- Deleting an environment is a soft delete (can be restored)
- Environment history tracks all changes for auditing
- Resource quotas can be adjusted based on your plan