Brain Docs

Reference

TypeScript SDKInstallationHTTP clientWire client
getSchemavalidateSchemauploadSchemareplaceSchemadropSchemalistSchemaslistExtractors
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
TypeScript SDKSchemauploadSchema

uploadSchema

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
uploadSchema(input: SchemaUploadInput): Promise<SchemaUploadResult>
Handshake credentialstable
uploadSchema(request: SchemaUploadRequest): Promise<SchemaUploadResponse>

Parameters

ParameterTypeRequired
schemaDocumentstringrequired

The document.

dryRunbooleanoptional

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

allowBreakingbooleanoptional

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

Returns

FieldTypePresence
namespace / schemaVersion—always

Where it landed.

backwardCompatiblebooleanalways

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

validationErrorsSchemaError[]always

Empty on success.

Example

const check = await brain.validateSchema({ schemaDocument: doc });
if (check.validationErrors.length > 0) {
  for (const e of check.validationErrors) {
    console.error(`${e.line}:${e.column} ${e.code} ${e.message}`);
  }
  return;
}

const up = await brain.uploadSchema({ schemaDocument: doc });
if (!up.backwardCompatible) console.warn("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
validateSchemareplaceSchema

Was this page helpful?

validateSchema

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

replaceSchema

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

On this page

ParametersReturnsExample
Suggest an editOpen in Playground