DorkOS
ApiFilesContent

Save a file

PUT
/api/files/content

Preview. This operation may change in any release.

Write new text to a file that already exists under cwd; it never creates one. With expectedHash (or expectedContent) the save is refused, unchanged, when the file changed since it was read, and the refusal carries the file as it is now. A chat canvas’s document save (documentSave) is the owner’s only. A person’s door: agents change files with their own tools.

Authorization

__Secure-better-auth.session_token<token>

The sign-in cookie a browser gets when a person signs in to DorkOS. An installed DorkOS on port 4242 names it __Secure-better-auth.session_token. On any other port the prefix carries a suffix for its data folder (better-auth-<hash>), and a development server leaves off __Secure-. From this computer, an operation that takes the sign-in cookie or a personal API key needs neither while "Ask for a password on this computer too" is off, which is how DorkOS installs (dorkos auth enable turns it on). A request from another device needs one, with one exception for now: a browser reaching a Docker container through its published port, while the container runs with DORKOS_ALLOW_INSECURE_BIND and has no owner account yet.

In: cookie

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X PUT "https://example.com/api/files/content" \  -H "Content-Type: application/json" \  -d '{    "cwd": "string",    "path": "string",    "content": "string"  }'
{  "ok": true,  "hash": "string",  "effect": "changed",  "documentReceipt": {    "documentId": "string",    "eventId": "string",    "incarnation": {      "v": 1,      "documentId": "string",      "physicalOpenedAt": "2019-08-24T14:15:22Z",      "channelCreatedAt": "2019-08-24T14:15:22Z",      "generation": "string"    },    "docSeq": 1,    "fileHash": "string",    "status": "accepted"  }}