Skip to main content
Sessions

Add a session resource

Add a file resource to an existing Forward session.

POST /api/v1/forward/sessions/{session_id}/resources Mounts an additional file resource in the sandbox runtime of an existing session. Use this endpoint when you need to upload a file while a session is in progress. The file must first be uploaded through the Files API. This endpoint accepts only type: "file".

Headers

HeaderRequiredDescription
AuthorizationYesBearer <PAT or SAT>
Content-TypeYesapplication/json

Path parameters

ParameterTypeRequiredDescription
session_idstringYesSession ID.

Request body

ParameterTypeRequiredDescription
typestringYesResource type. Must be file.
file_idstringYesFile ID returned by the Files API. The file must have finished uploading.
mount_pathstringNoMount path in the Agent container. If omitted, Forward generates a path from the file name. The default is /data/workspace/<file-name>.

Example request

curl -s -X POST 'https://api.qoder.com.cn/api/v1/forward/sessions/sess_xxx/resources' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "file",
  "file_id": "file_019e6a18dc09abcd",
  "mount_path": "/data/workspace/spec.md"
}'

Example response

HTTP 200 OK
{
  "id": "sesr_0e4323e8f47ba34853f5409e",
  "type": "file",
  "file_id": "file_019e6a18dc09abcd",
  "mount_path": "/data/workspace/spec.md",
  "created_at": "2026-06-23T05:53:19Z",
  "updated_at": "2026-06-23T05:53:38Z"
}

Response fields

FieldTypeDescription
idstringSession resource ID, prefixed with sesr_.
typestringResource type. Always file.
file_idstringMounted File ID.
mount_pathstringActual mount path in the Agent container.
created_atstringResource creation time in RFC 3339 format.
updated_atstringResource update time in RFC 3339 format.

Notify the Agent about the file

After mounting the file, the Agent does not detect it automatically. Send a user.message through Send session events and include the returned file path:
curl -s -X POST 'https://api.qoder.com.cn/api/v1/forward/sessions/sess_xxx/events' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "events": [{
    "type": "user.message",
    "content": [
      {"type": "text", "text": "Analyze the file"},
      {"type": "text", "text": "File path: /data/workspace/spec.md"}
    ]
  }]
}'
Use the mount_path returned when the resource was added.

Errors

HTTPTypeCodeTrigger
400invalid_request_errorinvalid_request_bodyThe request body is not valid JSON.
400invalid_request_errorinvalid_resourcetype is not file, file_id is missing, or a field contains control characters.
404not_found_errorsession_not_foundThe session does not exist.
404not_found_errorfile_not_foundThe file does not exist or has been deleted.
409conflict_errorsession_archivedThe session is archived.
409conflict_errorresource_conflictThe mount path conflicts with an existing session resource, or the file is already mounted in the session.
401authentication_errorauthentication_requiredThe PAT or SAT is invalid or expired.

Notes

  • The file must first be uploaded successfully through the Files API. After it is mounted, the Agent can read it from the container, but you must still send an Event to tell the Agent the file path; see Notify the Agent about the file.
  • If mount_path is omitted, Forward generates /data/workspace/<file-name>. Explicitly specify mount_path when mounting files with the same name to avoid overwriting.
  • This endpoint supports only adding file resources. Other resource types are rejected.
  • You cannot add resources to an archived session. Create a new session to continue.
  • Added resources are returned in the resources field of the get-session and list-sessions responses; the value is an empty array when no resources are mounted.