Start a coding session
Send codebaseId and message to start on a codebase; the message’s first line is the title until Mode names the session, a moment later. Send signalId alone to fix a signal: the session opens with its write-up, Mode’s findings and what customers said, in the codebase Mode confirmed it in, and a session already open on the signal comes back instead. Send toolSuggestionId alone to build a suggested tool: the session opens with the suggestion’s build prompt, in the codebase used last, and a session already open on the suggestion comes back instead. Only admins and owners, and only while the suggestion is pending. Attachments are ids from POST /uploads; with them, message may be empty. Needs Pro and credits.
POST
/mode/sessionsAuthorization
AuthorizationBearer token · headerrequired`MEDIAN_KEY` from Settings under API, or an MCP OAuth access token. A key acts as the organization; a token acts as the person who approved it.
Request body
requiredapplication/jsoncodebaseIdstringFrom `GET /v1/codebases`.
messagestringWhat to work on, up to 20,000 characters.
attachmentsobject[]Up to 6 files, 25 MB each. Sent with `codebaseId` and `message`.
Show propertiesHide properties
Array of
objectidstringrequirednamestringrequiredsignalIdstringA signal to fix. Sent without `codebaseId` and `message`.
toolSuggestionIdstringA tool suggestion to build, from `GET /v1/tool-suggestions`. Sent without `codebaseId` and `message`.
Responses
200The session.
idstringurlstringThe session's page in Median.
400The request is malformed, and the message names the field.
errorobjectShow propertiesHide properties
codestringmessagestring401The bearer token is missing, revoked, or expired.
errorobjectShow propertiesHide properties
codestringmessagestring403The token's person does not hold the role this needs.
errorobjectShow propertiesHide properties
codestringmessagestring404Not one of yours, or not there at all.
errorobjectShow propertiesHide properties
codestringmessagestring409It already exists, or it was already settled.
errorobjectShow propertiesHide properties
codestringmessagestring429Too many requests. Wait the seconds in `Retry-After`. Limits depend on the plan. See [rate limits](/api/errors-and-limits#rate-limits).
errorobjectShow propertiesHide properties
codestringmessagestringRequest
curl -X POST "https://api.median.sh/v1/mode/sessions" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"codebaseId": "jd7f3k...",
"message": "Fix the export button on Safari\n\nIt does nothing when pressed."
}'const response = await fetch("https://api.median.sh/v1/mode/sessions", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"codebaseId": "jd7f3k...",
"message": "Fix the export button on Safari\n\nIt does nothing when pressed."
})
});Response
{
"id": "k57d2v...",
"url": "https://median.sh/mode/k57d2v..."
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}