Skip to main content
Environments

Create an Environment

Forward API reference.

Description

Creates a runtime environment configuration for Agent Sessions.

Path

POST /api/v1/forward/environments

Request headers

HeaderRequiredDescription
AuthorizationYesBearer <PAT or SAT>
Content-TypeYesapplication/json
Idempotency-KeyNoRecommended for create requests. The same key and request can be retried safely.

Request body

FieldTypeRequiredDescription
namestringYesEnvironment name. It must not be empty after trimming leading and trailing whitespace.
descriptionstringNoDescription.
configEnvironment configNoEnvironment runtime configuration. Defaults to {"type":"cloud"} when omitted. When provided explicitly, it must not be null or an empty object. See schemas for field details.
metadataobjectNoEnvironment metadata. Defaults to {} when omitted and must not be null when provided explicitly.
The Environment config schema defines the config subfields (type, packages, and setup_script) and their constraints. A self_hosted Environment accepts only type and an optional setup_script; a cloud Environment can also declare packages.

Example request

curl -sS --fail-with-body \
  -X POST "https://api.qoder.com/api/v1/forward/environments" \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "dev-env",
    "description": "Development environment",
    "config": {
      "type": "cloud"
    },
    "metadata": {
      "source": "console"
    }
  }'

Request with packages and a setup script

curl -sS --fail-with-body \
  -X POST "https://api.qoder.com/api/v1/forward/environments" \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "doc-test-env-with-setup",
    "config": {
      "type": "cloud",
      "packages": {
        "npm": ["pnpm@9"]
      },
      "setup_script": "set -euo pipefail\n[ -d /workspace/.git ] || git clone https://github.com/me/repo /workspace\ncd /workspace && pnpm install --frozen-lockfile"
    }
  }'

Example response

HTTP 201 Created
{
  "id": "env_xxx",
  "type": "environment",
  "name": "dev-env",
  "description": "Development environment",
  "config": {
    "type": "cloud",
    "packages": {
      "type": "packages",
      "apt": [],
      "cargo": [],
      "gem": [],
      "go": [],
      "npm": [],
      "pip": []
    }
  },
  "metadata": {
    "source": "console"
  },
  "archived_at": null,
  "created_at": "2026-07-23T10:00:00Z",
  "updated_at": "2026-07-23T10:00:00Z",
  "identity_id": null
}

Response fields

The response is an Environment object. config is normalized to its complete shape. For a cloud Environment, config.packages includes empty arrays for every reserved key in Environment packages.

Errors

HTTPTypeTrigger
400invalid_request_errorname is missing or empty, the request body is not valid JSON, or config / metadata violates the constraints above.
400invalid_request_errorIf the reserved key created_by is supplied, message is metadata key "created_by" is reserved, identifying the invalid field.
401authentication_errorThe authentication token is missing or invalid.
403permission_errorThe caller cannot access this resource.
409conflict_errorThe Idempotency-Key maps to a different request, or creation is in an intermediate state that requires manual recovery.
413invalid_request_errorThe request body exceeds the service limit.
429rate_limit_errorThe caller exceeded the API rate limit.
500/502/503api_errorForward or a dependent service failed.
Create an Environment - Qoder