Skip to content
OpenCode
Esc
navigateopen⌘Jpreview

Fork session

Create a child session by copying projected history from the parent. When messageID is supplied, copy messages before that boundary.

POST/api/session/{sessionID}/fork
Path parameters
sessionIDobjectrequired
Request body
requiredapplication/json
messageIDobject | any
Show properties
Any of:
object
object
any
any
Responses
200Success
dataSession.Inforequired
Show properties
idobjectrequired
Show properties
object
parentIDobject
Show properties
object
forkobject
Show properties
sessionIDobjectrequired
Show properties
object
messageIDobject
Show properties
object
projectIDstringrequired
agentstring
modelModel.Ref
Show properties
idstringrequired
providerIDstringrequired
variantstring
costMoney.USDrequired
tokensTokenUsage.Inforequired
Show properties
inputnumberrequired
outputnumberrequired
reasoningnumberrequired
cacheobjectrequired
Show properties
readnumberrequired
writenumberrequired
timeobjectrequired
Show properties
creatednumberrequired
updatednumberrequired
archivednumber
titlestringrequired
locationLocation.Refrequired
Show properties
directorystringrequired
workspaceIDobject
Show properties
object
subpathstring
revertSession.Revert
Show properties
messageIDobjectrequired
Show properties
object
partIDstring
snapshotstring
filesFileDiff.Info[]
Show properties
Array of FileDiff.Info
filestringrequired
patchstringrequired
additionsobjectrequired
Show properties
object
deletionsobjectrequired
Show properties
object
statusstringrequired
Allowed:addeddeletedmodified
400InvalidRequestError
_tagstringrequired
Allowed:InvalidRequestError
messagestringrequired
kindstring | any
Show properties
Any of:
string
string
any
any
fieldstring | any
Show properties
Any of:
string
string
any
any
401UnauthorizedError
_tagstringrequired
Allowed:UnauthorizedError
messagestringrequired
404SessionNotFoundError | MessageNotFoundError
Any of:
MessageNotFoundError
_tagstringrequired
Allowed:MessageNotFoundError
sessionIDstringrequired
messageIDstringrequired
messagestringrequired
SessionNotFoundError
_tagstringrequired
Allowed:SessionNotFoundError
sessionIDstringrequired
messagestringrequired
SessionNotFoundError
_tagstringrequired
Allowed:SessionNotFoundError
sessionIDstringrequired
messagestringrequired
Request
curl -X POST "/api/session/%5Bobject%20Object%5D/fork" \
  -H "Content-Type: application/json" \
  -d '{
  "messageID": {}
}'
Response
{
  "data": {
    "id": {},
    "parentID": {},
    "fork": {
      "sessionID": {},
      "messageID": {}
    },
    "projectID": "string",
    "agent": "string",
    "model": {
      "id": "string",
      "providerID": "string",
      "variant": "string"
    },
    "cost": 0,
    "tokens": {
      "input": 0,
      "output": 0,
      "reasoning": 0,
      "cache": {
        "read": 0,
        "write": 0
      }
    },
    "time": {
      "created": 0,
      "updated": 0,
      "archived": 0
    },
    "title": "string",
    "location": {
      "directory": "string",
      "workspaceID": {}
    },
    "subpath": "string",
    "revert": {
      "messageID": {},
      "partID": "string",
      "snapshot": "string",
      "files": [
        {
          "file": "string",
          "patch": "string",
          "additions": {},
          "deletions": {},
          "status": "added"
        }
      ]
    }
  }
}