Skip to main content
Environments

Environment の作成

Forward API リファレンス。

Description

Creates a runtime environment configuration for Agent Sessions.

パス

POST /api/v1/forward/environments

リクエストヘッダー

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

クエリパラメーター

ParameterTypeRequiredDescription
identity_idstringNoIdentity に属するリソースを操作する場合のみ使用する任意のパラメーターです。PAT では明示的に指定でき、省略時は管理者スコープになります。SAT では Identity スコープのトークンを発行し、このパラメーターを明示的に指定しないでください。指定すると HTTP 400 が返されます。Identity の帰属.

リクエストボディ

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.

リクエスト例

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"
    }
  }'

レスポンス例

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
}

レスポンスフィールド

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.

エラー

HTTPTypeTrigger
400invalid_request_errorname is missing or empty, the request body is not valid JSON, or config / metadata violates the constraints above. SAT が identity_id を明示的に指定した場合も返されます。
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_erroridentity_id を指定しない PAT または Admin SAT で Owner mismatch が発生したか、その他の権限が不足しています。
404not_found_erroridentity_id is invalid, disabled, or does not belong to the caller, or the target resource does not belong to the current Identity scope.
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.