---
title: "Create an exec session."
method: POST
path: "/v1/machines/{id}/sessions"
tags: ["machines"]
---

# Create an exec session.

`POST /v1/machines/{id}/sessions`

## Request

- Base URL: `https://api.smolmachines.com`
- URL: `https://api.smolmachines.com/v1/machines/{id}/sessions`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/smolmachines/apis/smolfleet-api/docs/v1/machines/:id/sessions/post.ts> (a function with typed inputs; its response is checked against the schema)

Opens a persistent exec session whose working directory and environment survive between commands. Requires the `machine:exec` scope.

## Path parameters

- `id` string, required

## Request body

- CreateMachineSessionRequest
  - `cwd` string, nullable
  - `env` object
  - `id` string, nullable

## Response `200`

Session created

- MachineSessionInfo
  - `createdAt` string, required
  - `cwd` string, nullable
  - `env` object, required
  - `id` string, required
  - `lastExecAt` string, nullable
  - `machineId` string, required
  - `status` string, required

## Other responses

- `401`: Missing or invalid API key
- `403`: Key lacks the required scope
- `404`: Not found
- `429`: Rate limited; retry after the Retry-After header
- `500`: Internal error

## Changes

- **2026-10-16** `bc31fc04a568`: 6 info
  - the endpoint scheme security `ApiKeyAuth` was added to the API
  - added the non-success response with the status `401`
  - added the non-success response with the status `403`
  - added the non-success response with the status `404`
  - …2 more

[Operation history](https://skmtc.dev/smolmachines/apis/smolfleet-api/changes/v1/machines/:id/sessions/post.md)

---

[API](https://skmtc.dev/smolmachines/apis/smolfleet-api.md) - [All operations](https://skmtc.dev/smolmachines/apis/smolfleet-api/llms.txt) - [OpenAPI document](https://skmtc.dev/smolmachines/apis/smolfleet-api/revisions/bc31fc04a568?raw)
