Skip to content
Select themeSelect language

`PUT /api/code-lib/files` — insert or replace one file in the shared tree.

PUT
/api/code-lib/files
curl --request PUT \
--url https://example.com/api/code-lib/files \
--header 'Content-Type: application/json' \
--data '{ "content": "example", "content_b64": "example", "path": "example" }'
Media typeapplication/json

PUT /api/code-lib/files — insert or replace one shared file. Exactly one of content (UTF-8 text) / content_b64 (binary) must be present.

object
content
string | null
content_b64
string | null
path
required

Path relative to the lib root — e.g. mail_triage.ts. Materialised at /sc/lib/<path> and serialized to lib/<path> in the synced repo.

string
Examplegenerated
{
"content": "example",
"content_b64": "example",
"path": "example"
}
Media typeapplication/json

Wire-shape view of one shared-lib row. Binary rows expose content_b64; text rows expose content. The mutex matches the DB CHECK so a consumer can switch on is_binary without a second lookup.

container_path and import_hint are DERIVED, never stored: they are the two questions a reader of this file actually has (“where does it land?”, “how do I import it?”), and deriving them server-side keeps the answer identical across the web editor, the API and the docs.

object
container_path
required

Absolute path inside the code-node container — /sc/lib/<path>.

string
content
string | null
content_b64
string | null
id
required
string format: uuid
import_hint

The specifier a code node uses to reach this file, or None for a file with no import form (binary, data, or an extension neither runtime imports).

string | null
is_binary
required
boolean
path
required

Path relative to the lib root — e.g. mail_triage.ts.

string
size_bytes
required
integer
updated_at
required
string format: date-time
workspace_id
required
string format: uuid
Examplegenerated
{
"container_path": "example",
"content": "example",
"content_b64": "example",
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"import_hint": "example",
"is_binary": true,
"path": "example",
"size_bytes": 1,
"updated_at": "2026-04-15T12:00:00Z",
"workspace_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
}

Structured client error

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden license_required license_expired bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited too_many_requests quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}

Authentication required

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden license_required license_expired bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited too_many_requests quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}

Permission denied

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden license_required license_expired bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited too_many_requests quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}

Structured server error

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden license_required license_expired bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited too_many_requests quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}