Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
get_schemavalidate_schemaupload_schemareplace_schemadrop_schemalist_schemaslist_extractors
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust 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
async fn upload_schema(&self, input: &SchemaUploadInput) -> Result<SchemaUploadResult, BrainHttpError>
Handshake credentialstable
async fn upload_schema(&self, request: &SchemaUploadRequest) -> Result<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

let check = brain.validate_schema(&SchemaValidateInput { schema_document: doc.clone() }).await?;
if !check.validation_errors.is_empty() {
    for e in &check.validation_errors {
        eprintln!("{}:{} {} {}", e.line, e.column, e.code, e.message);
    }
    return Ok(());
}

let up = brain.upload_schema(&SchemaUploadInput { schema_document: doc, ..Default::default() }).await?;
if !up.backward_compatible {
    eprintln!("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