Skip to main content

Create Session

POST /v1/sessions/session

Create a session, which execute, upload and VM calls attach to. No VM starts here unless prewarm is true: the first POST /execute, or POST /v1/vms with this session_id, starts one, and that VM is killed vm_lifetime_seconds after it starts (default 300, minimum 20, at most your plan's limit). Optional: memory_mb (128 to 8192, an even number), vcpu_count (1, 2, 4, 6 or 8; default 2), metadata for filtering, and env variables kept for every execution in the session. Leave prewarm false when you will pass the session to POST /v1/vms with a snapshot, another image or volumes. Authenticate with a Bearer token or X-API-Key; a body api_key is still accepted from older clients.

Authentication​

Requires authentication via: OAuth2PasswordBearer.

Parameters​

NameInTypeRequiredDescriptionConstraints
X-API-Keyheaderstring | nullNonullable

Request Body​

Required: Yes

application/json​

Resolved schema:

{
"properties": {
"api_key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Api Key"
},
"vm_lifetime_seconds": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Vm Lifetime Seconds"
},
"memory_mb": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Memory Mb"
},
"vcpu_count": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Vcpu Count"
},
"metadata": {
"anyOf": [
{
"type": "object"
},
{
"type": "null"
}
],
"title": "Metadata"
},
"env": {
"anyOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
],
"title": "Env"
},
"prewarm": {
"type": "boolean",
"title": "Prewarm",
"default": false
}
},
"type": "object",
"title": "CreateSessionRequest"
}

Field details:

FieldTypeRequiredDescriptionConstraints
api_keystring | nullNonullable
vm_lifetime_secondsinteger | nullNonullable
memory_mbinteger | nullNonullable
vcpu_countinteger | nullNonullable
metadataobject | nullNonullable
envobject<string, string> | nullNonullable
env.*stringNo
prewarmbooleanNodefault=false

Responses​

200​

Successful Response

application/json​

Resolved schema:

{
"properties": {
"session_id": {
"type": "string",
"format": "uuid",
"title": "Session Id"
}
},
"type": "object",
"required": [
"session_id"
],
"title": "CreateSessionResponse"
}

Field details:

FieldTypeRequiredDescriptionConstraints
session_idstringYesformat=uuid

400​

Invalid env, vm_lifetime_seconds, memory_mb or vcpu_count.

No response body.

401​

No credentials, or the Bearer token / X-API-Key is invalid; or no Authorization or X-API-Key header and no api_key in the body, or the body api_key is invalid.

No response body.

403​

The account is disabled, or a guest token was used; or your account may not start VMs yet (see detail.code), or the requested lifetime or CPU count exceeds your plan.

No response body.

404​

The account for the body api_key no longer exists.

No response body.

422​

Validation Error

application/json​

Resolved schema:

{
"properties": {
"detail": {
"items": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
}

Field details:

FieldTypeRequiredDescriptionConstraints
detailarray<object>No
detail[]objectNo
detail[].locarray<string | integer>No
detail[].loc[]string | integerNo
detail[].msgstringNo
detail[].typestringNo

429​

Your plan's per-minute request limit or concurrent VM limit is reached.

No response body.

503​

env could not be applied because no capacity is free when prewarm is true. Retry after the Retry-After interval.

No response body.