{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sandbase-ai/json-schema/sandbase-ai-session-create-request-schema.json",
  "title": "SessionCreateRequest",
  "description": "Send agent_id, agent, or both.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sandbase-ai-openapi.json#/components/schemas/SessionCreateRequest",
  "type": "object",
  "additionalProperties": false,
  "anyOf": [
    {
      "required": [
        "agent_id"
      ]
    },
    {
      "required": [
        "agent"
      ]
    }
  ],
  "properties": {
    "agent_id": {
      "type": "string",
      "description": "Saved Agent ID (`agt_` prefix)."
    },
    "version": {
      "type": "integer",
      "minimum": 1,
      "description": "Agent version. Defaults to the current version. Not allowed with an inline Agent."
    },
    "title": {
      "type": "string",
      "maxLength": 512
    },
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "description": "Agent configuration, validated as in Create Agent. Without agent_id it defines an inline Agent and model is required; inline Agents carry no Skills or MCP connections. With agent_id, each field sent replaces that field of the saved version for this Session only.",
      "properties": {
        "model": {
          "type": "string",
          "maxLength": 200
        },
        "instructions": {
          "type": [
            "string",
            "null"
          ]
        },
        "runtime_profile": {
          "type": "string",
          "enum": [
            "codex",
            "claude",
            "mcode"
          ],
          "description": "Defaults to codex for an inline Agent."
        },
        "service_tier": {
          "type": [
            "string",
            "null"
          ]
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "text": {
          "type": "object"
        },
        "reasoning": {
          "type": "object"
        },
        "multi_agent": {
          "type": "object"
        }
      }
    },
    "model": {
      "type": "string",
      "maxLength": 200,
      "description": "Model override for this Session. Must equal agent.model when both are sent."
    },
    "environment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "const": "openai_hosted"
        }
      },
      "description": "OpenAI SDK compatibility only. Sessions always run in the SandBase hosted cloud, so omit this field in direct HTTP calls. The OpenAI SDK requires it; {\"type\":\"openai_hosted\"} is accepted and any other value returns 400."
    },
    "input": {
      "description": "Optional first input: a string, or an array with exactly one message, e.g. [{\"role\":\"user\",\"content\":[{\"type\":\"input_text\",\"text\":\"...\"}]}]. A bare object returns 400.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "minItems": 1,
          "maxItems": 1,
          "items": {
            "type": "object",
            "required": [
              "role",
              "content"
            ],
            "properties": {
              "role": {
                "type": "string",
                "const": "user"
              },
              "content": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "type",
                    "text"
                  ],
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "input_text"
                    },
                    "text": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    "metadata": {
      "type": "object",
      "maxProperties": 16,
      "additionalProperties": {
        "type": "string",
        "maxLength": 512
      }
    },
    "stream": {
      "type": "boolean",
      "default": false,
      "description": "true requires a non-empty input and returns a 201 text/event-stream of the first turn."
    },
    "model_provider": {
      "$ref": "#/$defs/ModelProvider"
    },
    "github_workspace": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "required": [
        "repository_id"
      ],
      "description": "GitHub repository to clone into /workspace for this Session. Omitted or null uses the Agent's workspace repository, if any, and otherwise clones nothing. The repository must be within the Agent's GitHub connection scope.",
      "properties": {
        "repository_id": {
          "type": "string",
          "pattern": "^[0-9]+$",
          "description": "GitHub numeric repository ID as a decimal string."
        },
        "ref": {
          "type": "string",
          "maxLength": 200,
          "description": "Branch to check out. Defaults to the repository's default branch."
        },
        "connection_id": {
          "type": "string",
          "maxLength": 64,
          "description": "GitHub connection to use. Defaults to the assignment with a workspace repository, or the Agent's only GitHub connection."
        }
      }
    }
  },
  "$defs": {
    "ModelProvider": {
      "type": "object",
      "additionalProperties": false,
      "description": "Write-only model credential. Omit it to run with the calling SandBase API key. Never returned.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "sandbase",
            "custom"
          ],
          "default": "sandbase"
        },
        "base_url": {
          "type": "string",
          "format": "uri",
          "description": "Required for custom. HTTPS only, without credentials, query, or fragment. Not allowed for sandbase."
        },
        "api_key": {
          "type": "string",
          "description": "Required for custom. Optional for sandbase, where it defaults to the calling key."
        }
      }
    }
  }
}