Create Environment
POST /v1/environments
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Machine-friendly name. Must match ^[a-z0-9_-]+$ (lowercase alphanumeric, hyphens, underscores) |
display_name | string | No | Human-friendly display name |
description | string | No | Description of the environment |
color | string | No | Hex color code for the UI (defaults to #6366f1) |
is_default | boolean | No | Whether this is the default environment (defaults to false) |
Response
Returns the created environment object.import { KnoxCall } from "@knoxcall/sdk";
const client = new KnoxCall(); // credentials from `knoxcall login` or KNOXCALL_CLIENT_ID / KNOXCALL_CLIENT_SECRET
const environment = await client.environments.create({
name: "staging",
display_name: "Staging",
description: "Pre-production testing",
color: "#f59e0b"
});
from knoxcall import KnoxCall
client = KnoxCall() # credentials from `knoxcall login` or KNOXCALL_CLIENT_ID / KNOXCALL_CLIENT_SECRET
environment = client.environments.create(
name="staging",
display_name="Staging",
description="Pre-production testing",
color="#f59e0b"
)
# Mint a 1-hour OAuth token (client_credentials) — see /api-reference/authentication
TOKEN=$(curl -s -X POST https://api.knoxcall.com/oauth/token \
-u "$KNOXCALL_CLIENT_ID:$KNOXCALL_CLIENT_SECRET" \
-d "grant_type=client_credentials" | jq -r .access_token)
curl -X POST https://api.knoxcall.com/v1/environments \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "staging",
"display_name": "Staging",
"description": "Pre-production testing",
"color": "#f59e0b"
}'
Errors
| Status | Type | Description |
|---|---|---|
| 400 | validation_error | Invalid name format or missing required field |
| 403 | plan_limit | Environments not available on your plan, or environment limit reached |
| 409 | conflict | An environment with this name already exists |