Brain Docs

Reference

Python SDKInstallationHTTP clientWire clientSync vs async
get_schemavalidate_schemaupload_schemareplace_schemadrop_schemalist_schemaslist_extractors
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Python SDKSchemaupload_schema

upload_schema

Publish a new schema version, with a dry run and an explicit opt-in for breaking changes.

PURPOSE

Publish a new schema version. Uploads are checked for backward compatibility before they take effect; a breaking change is refused unless you say otherwise.

POST/v1/schemaBearer API keystable
upload_schema(schema_document: str, dry_run=None, allow_breaking=None) -> SchemaUpload
Handshake credentialstable
upload_schema(request: SchemaUploadRequest) -> SchemaUploadResponse

Parameters

ParameterTypeRequired
schema_documentstringrequired

The document.

dry_runbooleanoptional

Run the whole upload path, including the compatibility check, and store nothing.

allow_breakingbooleanoptional

Accept a document that is not backward compatible. Without it, a breaking change is refused.

Returns

FieldTypePresence
namespace / schema_version—always

Where it landed.

backward_compatiblebooleanalways

Whether the new version can read what the old one wrote. false here with breaking changes allowed means you took the break deliberately.

validation_errorsSchemaError[]always

Empty on success.

Example

check = brain.validate_schema(doc)
if check.validation_errors:
    for e in check.validation_errors:
        print(f"{e.line}:{e.column} {e.code} {e.message}")
    return

up = brain.upload_schema(schema_document=doc)
if not up.backward_compatible:
    print("breaking change accepted")
Validation failures are not exceptions

This verb resolves with a populated validationErrors array rather than throwing. Code that only wraps the call in a try/catch treats an invalid schema as a successful one. Check the array.

Uploading a schema needs the SchemaUpload grant when the request carries an act_as selector. See act_as.

See also
validate_schemareplace_schema

Was this page helpful?

validate_schema

Check a schema document without storing it — with line, column and span for each error.

replace_schema

Replace the schema wholesale — and read the count of live rows it destroyed.

On this page

ParametersReturnsExample
Suggest an editOpen in Playground