SandboxesFiles

Write file content

Stream bytes to a temporary file, then replace the target.

  • An interrupted transfer keeps the old file.
  • With mode, the file gets those permission bits before it replaces the target, so it never appears without them. Without mode, a replaced file keeps its mode.

See Write files in the guide.

PUT
/v1/sandboxes/{sandboxId}/files/content
AuthorizationBearer <token>

API key starting with tektona_. Create one at app-dev.tektona.ai under API Keys.

In: header

Path Parameters

sandboxId*string

Query Parameters

path*string

Absolute, or relative to the sandbox working directory. A path that starts with ~ or ~/ names the home directory of the user that the operation runs as. ~name returns 422.

user?string
resume?boolean
mode?integer

Permission bits as a decimal integer (493 is 0o755)

Range0 <= value <= 4095

Header Parameters

If-Match?string
If-None-Match?"*"

Value in

  • "*"

Request Body

application/octet-stream

TypeScript Definitions

Use the request body type in TypeScript.

body*file
Formatbinary

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/v1/sandboxes/string/files/content?path=string" \  -H "Content-Type: application/octet-stream" \  -d 'string'
{  "entry": {    "gid": 0,    "group": "string",    "mode": 0,    "modified_at": "2019-08-24T14:15:22Z",    "name": "string",    "owner": "string",    "path": "string",    "size": 0,    "symlink_target": "string",    "type": "file",    "uid": 0  },  "etag": "string"}

Watch file changes GET

Upgrade to WebSocket and receive `SandboxFilesWatchFrame` JSON text frames. - Wait for `ready`. Then list or read what you need. Then apply the `changes` frames that arrived meanwhile, and the ones after. - `seq` counts the frames of this subscriber. A skipped `seq`, a frame that is not valid, or a close without `end` means lost changes: open a new watch and list again. - On `resync`, list again. `end` is the last frame. - Close code 4001 means the watch expired after 15 minutes. 1001 means the server shut down. - Needs read access. `user` needs write access. - Served at the access endpoint of the sandbox (`access_endpoint` of `GET /v1/sandboxes/{sandboxId}`). A browser offers the credential as the WebSocket protocol `Bearer-<token>`. See [Watch for changes](https://docs.tektona.ai/files#watch-for-changes) in the guide.

Add a git remote POST

Add a remote with an HTTPS `url` that holds no credentials. - An existing name returns 409 `already_exists`. - Local git writes on one work tree run one at a time. A write through the files endpoints does not wait for them. After a timeout, the outcome is unknown: the command can have run. - Runs in the sandbox as the image user. Needs write access to the sandbox, because git runs the repository's own config and filters. - Served at the access endpoint of the sandbox (`access_endpoint` of `GET /v1/sandboxes/{sandboxId}`), not at the API host. - A paused sandbox returns 409, unless `resume=true`. A sandbox that started before its files server existed returns 409 `sandbox_update_required` until it restarts. - A refused operation returns its code as the problem type. - A path that starts with `~` or `~/` names the home directory of the user that the operation runs as. `~name` returns 422.