Skip to main content

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.
x-qoder-beta条件付きconfig.storage.buckets が空でない場合は必須。値は oss-bucket-2026-09-23。

クエリパラメーター

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.
Environment config スキーマで config の子フィールド(type / packages / setup_script / startup_script / storage)とそれぞれの制約を定義しています。self_hosted Environment で使用できるのは type と任意の setup_script、startup_script のみです。cloud Environment ではさらに packages と storage を指定できます。 config.storage.buckets には自分の OSS bucket を最大 7 個指定でき、Session の /mnt/buckets/<name> にマウントされます。フィールド、認証情報、認可、権限ポリシーについては Environment storage を参照してください。

リクエスト例

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.
400invalid_request_errorconfig.storage.buckets が不正(7 個を超える場合を含む)、x-qoder-beta ヘッダーがない、または保存時の試験マウントが拒否されました。
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.
503feature_not_availableアカウントが oss_bucket Beta の利用資格を満たしていません。
503api_error保存時に OSS / STS が一時的に利用できません。再試行できます。
500/502/503api_errorForward or a dependent service failed.