メインコンテンツへスキップ
POST /v1/sessions/{session_id}/resources Session にリソースを追加します。ファイルと GitHub リポジトリの両方をサポートしています。追加後、Agent はメッセージ処理時にこれらのリソースにアクセスできるようになります。

パスパラメータ

パラメータ説明
session_idstringSession ID(sess_ プレフィックス)

ヘッダー

名称必須
AuthorizationはいBearer $QODER_PAT
Content-Typeはいapplication/json

リクエストボディ

フィールド必須説明
resourcesarrayはいリソースオブジェクトの配列。少なくとも 1 つのファイルまたは GitHub リポジトリリソースを含む必要があります。
resources[].typestringいいえ"file" または "github_repository"。省略時のデフォルトは "file" です。
type"file" の場合:
フィールド必須説明
file_idstringはいファイル ID(Files API でアップロード後に取得)。ファイルは ready ステータスである必要があります。
pathstringいいえマウントパス。デフォルトは /data/{file_id}。相対パスの場合、サーバーが /data/ プレフィックスを付与します。正規化されたパスは /data/ 配下かつ最大 512 文字である必要があります。
mount_pathstringいいえpath のエイリアス。pathmount_path の両方を指定する場合、値が一致している必要があります。レスポンスでは正規化された値が path として格納されます。
type"github_repository" の場合:
フィールド必須説明
urlstringはいリポジトリ URL
mount_pathstringいいえコンテナ内のクローン先パス
authorization_tokenstringいいえプライベートリポジトリアクセス用の認可トークン。指定した場合、Session リソースオブジェクトに格納されます。

リクエスト例

ファイルの追加

curl -X POST https://api.qoder.com/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/resources \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "resources": [
      {
        "type": "file",
        "file_id": "file_abc123def456",
        "path": "inputs/spec.md"
      }
    ]
  }'

GitHub リポジトリの追加

curl -X POST https://api.qoder.com/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/resources \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "resources": [
      {
        "type": "github_repository",
        "url": "https://github.com/your-org/your-repo"
      }
    ]
  }'

レスポンス例

HTTP 200 OK 更新後の resources リストを返します(完全な Session オブジェクトではありません)。
{
  "resources": [
    {
      "type": "file",
      "file_id": "file_abc123def456",
      "path": "/data/inputs/spec.md"
    },
    {
      "type": "github_repository",
      "url": "https://github.com/your-org/your-repo"
    }
  ]
}

レスポンスフィールド

フィールド説明
resourcesarray追加後の正規化された完全なリソースリスト
resources[].typestring"file" または "github_repository"
resources[].file_idstringファイルリソースに存在
resources[].pathstringファイルリソースに存在。/data/ 配下の正規化されたマウントパス
resources[].urlstringGitHub リポジトリリソースに存在
resources[].mount_pathstringGitHub リポジトリの任意のマウントパス
resources[].authorization_tokenstringGitHub リポジトリの任意のトークン(指定された場合のみ存在)

エラーレスポンス

HTTPtype説明
400invalid_request_errorリクエスト形式エラー、resources が空、type が無効、必須フィールドの欠落、無効なファイルパス、またはリクエスト内のリソース重複
401authentication_errorPAT が無効または期限切れ
404not_found_errorSession またはファイルが存在しない
409conflict_errorSession がアーカイブまたは終了済み、ファイルが ready でない、またはファイル ID/パス/リポジトリ URL がこの Session に既にアタッチ済み

エラー例

type が不正:
{
  "error": {
    "message": "resources[0]: field 'type' must be 'file' or 'github_repository'.",
    "type": "invalid_request_error"
  },
  "type": "error"
}
file_id が欠落:
{
  "error": {
    "message": "resources[0]: field 'file_id' must be a non-empty string.",
    "type": "invalid_request_error"
  },
  "type": "error"
}
ファイルが存在しない:
{
  "error": {
    "message": "File 'file_fake_test_id' was not found.",
    "type": "not_found_error"
  },
  "type": "error"
}

関連項目

Session の起動

Agent を環境で実行し、ステートフルな対話を行う。