> ## Documentation Index
> Fetch the complete documentation index at: https://synthbrew.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate Schema Config

> Validates a canonical Synthbrew schemaVersionConfig v1 without creating resources.

This endpoint validates the frozen public schema config contract, `schemaConfigVersion: "v1"`.

The schema payload itself must use `formatVersion: 1`. Synthbrew may add optional fields, enum values, generation settings, and metadata fields to v1 without a new version. Synthbrew will not remove fields, rename fields, change existing meanings, or make optional fields required without introducing a new contract version.


## OpenAPI

````yaml POST /public/v1/schema-config/validate
openapi: 3.1.0
info:
  title: Synthbrew API
  description: Runtime CRUD and public v1 management endpoints for Synthbrew resources.
  version: 1.0.0
servers:
  - url: https://api.synthbrew.com/api
    description: Production
security:
  - sourceApiKey: []
tags:
  - name: Runtime
    description: Public runtime CRUD operations authenticated with source API keys
  - name: Public v1 Projects
    description: Team-scoped project management endpoints authenticated with team API keys
  - name: Public v1 Schemas
    description: Schema management endpoints scoped to projects accessible by the API key
  - name: Public v1 Sources
    description: >-
      Source management and generation endpoints scoped to projects accessible
      by the API key
paths:
  /public/v1/schema-config/validate:
    post:
      tags:
        - Public v1 Schemas
      summary: Validate a schema config
      description: >-
        Validates a canonical Synthbrew schemaVersionConfig v1 without creating
        resources.
      operationId: publicV1ValidateSchemaConfig
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateSchemaConfigRequest'
      responses:
        '200':
          description: Validation result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidateSchemaConfigResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/PublicUnauthorized'
        '403':
          $ref: '#/components/responses/PublicForbidden'
        '404':
          $ref: '#/components/responses/PublicNotFound'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - teamApiKey: []
components:
  schemas:
    ValidateSchemaConfigRequest:
      type: object
      properties:
        schemaConfigVersion:
          type: string
          enum:
            - v1
          default: v1
          description: Frozen public schema config contract version.
        schema:
          $ref: '#/components/schemas/SchemaVersionConfig'
      required:
        - schema
    ValidateSchemaConfigResponse:
      type: object
      properties:
        schemaConfigVersion:
          type: string
          enum:
            - v1
        valid:
          type: boolean
        errors:
          type: array
          items:
            $ref: '#/components/schemas/SchemaValidationError'
        suggestions:
          type: array
          items:
            type: string
        schema:
          $ref: '#/components/schemas/SchemaVersionConfig'
      required:
        - schemaConfigVersion
        - valid
        - errors
        - suggestions
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error summary.
    SchemaVersionConfig:
      type: object
      required:
        - formatVersion
        - entities
      description: >-
        Declarative schema config used by schema versions. This is the v1 public
        contract when paired with schemaConfigVersion="v1" and formatVersion=1.
      properties:
        formatVersion:
          type: integer
          enum:
            - 1
          description: Schema config format version.
        metadata:
          type: object
          additionalProperties: true
          properties:
            name:
              type: string
            description:
              type: string
            tags:
              type: array
              items:
                type: string
        generationDefaults:
          $ref: '#/components/schemas/EntityGenerationConfig'
        entities:
          type: array
          items:
            $ref: '#/components/schemas/SchemaEntityConfig'
      additionalProperties: false
    SchemaValidationError:
      type: object
      properties:
        path:
          type: string
          example: entities.0.primaryKey.0
        message:
          type: string
          example: Unknown field "missing_id" in entity "orders" primaryKey
      required:
        - path
        - message
    EntityGenerationConfig:
      type: object
      description: Generation defaults or per-entity generation settings.
      properties:
        rowCount:
          oneOf:
            - type: integer
              minimum: 0
            - $ref: '#/components/schemas/RowCountRange'
        locale:
          type: string
        timezone:
          type: string
        seed:
          oneOf:
            - type: string
            - type: integer
      additionalProperties: false
    SchemaEntityConfig:
      type: object
      required:
        - id
        - fields
      description: Entity/table definition in a Synthbrew schema config.
      properties:
        id:
          type: string
          description: >-
            Stable entity identifier. Must start with a letter and use letters,
            numbers, or underscores.
        label:
          type: string
        description:
          type: string
        fields:
          type: array
          items:
            $ref: '#/components/schemas/SchemaFieldConfig'
        primaryKey:
          type: array
          items:
            type: string
          description: Field IDs that form the primary key.
        uniqueKeys:
          type: array
          items:
            type: array
            items:
              type: string
          description: Field ID groups that should be unique at row level.
        indexes:
          type: array
          items:
            $ref: '#/components/schemas/SchemaEntityIndexConfig'
        generation:
          $ref: '#/components/schemas/EntityGenerationConfig'
      additionalProperties: false
    RowCountRange:
      type: object
      required:
        - min
        - max
      properties:
        min:
          type: integer
          minimum: 0
        max:
          type: integer
          minimum: 0
      additionalProperties: false
    SchemaFieldConfig:
      type: object
      required:
        - id
        - type
      description: >-
        Field definition in a Synthbrew schema config. Type-specific properties
        are accepted based on the selected type.
      properties:
        id:
          type: string
          description: >-
            Stable field identifier. Must start with a letter and use letters,
            numbers, or underscores.
        label:
          type: string
        description:
          type: string
        type:
          type: string
          enum:
            - string
            - text
            - integer
            - number
            - boolean
            - date
            - datetime
            - time
            - uuid
            - json
            - enum
        nullable:
          type: boolean
          default: false
        references:
          $ref: '#/components/schemas/SchemaFieldReferenceConfig'
        generation:
          $ref: '#/components/schemas/FieldGenerationConfig'
        format:
          type: string
          enum:
            - plain
            - email
            - url
            - slug
            - phone
          description: String field format.
        minLength:
          type: integer
          minimum: 0
        maxLength:
          type: integer
          minimum: 1
        min:
          type: number
        max:
          type: number
        precision:
          type: integer
          minimum: 1
        prefix:
          type: string
        suffix:
          type: string
        trueRate:
          type: number
          minimum: 0
          maximum: 1
        outputFormat:
          type: string
          enum:
            - iso
            - slash
            - sql
        weekdaysOnly:
          type: boolean
          default: false
        values:
          type: array
          items:
            type: string
          description: Allowed values for enum fields.
        weights:
          type: array
          items:
            type: number
            exclusiveMinimum: 0
          description: Optional enum weights. Count must match values count.
      additionalProperties: false
    SchemaEntityIndexConfig:
      type: object
      required:
        - fields
      properties:
        id:
          type: string
        fields:
          type: array
          items:
            type: string
        unique:
          type: boolean
          default: false
      additionalProperties: false
    SchemaFieldReferenceConfig:
      type: object
      required:
        - entity
        - field
      properties:
        entity:
          type: string
        field:
          type: string
        relation:
          type: string
          enum:
            - many-to-one
            - one-to-one
          default: many-to-one
        pick:
          type: string
          enum:
            - random
            - sequential
          default: random
        onDelete:
          type: string
          enum:
            - restrict
            - cascade
            - set-null
          default: restrict
        onUpdate:
          type: string
          enum:
            - restrict
            - cascade
            - set-null
          default: restrict
      additionalProperties: false
    FieldGenerationConfig:
      type: object
      description: Field-level generation settings.
      properties:
        emptyRate:
          type: number
          minimum: 0
          maximum: 1
          default: 0
          description: >-
            Chance to emit an empty value. Nullable fields emit null; required
            fields fall back to a generated value.
        uniqueValues:
          type: boolean
          description: >-
            Avoid duplicate generated values for this field when the value
            source has a finite pool, such as enum values, weightedChoice
            choices, or reference values. If the pool is exhausted, the entity
            inserts fewer rows and generation continues.
        strategy:
          $ref: '#/components/schemas/FieldGenerationStrategyConfig'
      additionalProperties: false
    FieldGenerationStrategyConfig:
      type: object
      required:
        - kind
      description: >-
        Generation strategy. Supported kinds are literal, sequence, randomInt,
        randomFloat, randomBoolean, weightedChoice, faker, template, dateRange,
        and reference.
      properties:
        kind:
          type: string
          enum:
            - literal
            - sequence
            - randomInt
            - randomFloat
            - randomBoolean
            - weightedChoice
            - faker
            - template
            - dateRange
            - reference
      additionalProperties: true
  responses:
    BadRequest:
      description: Validation or query error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    PublicUnauthorized:
      description: Missing, invalid, or revoked team API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingKey:
              value:
                error: API key required
            invalidKey:
              value:
                error: Invalid API key
    PublicForbidden:
      description: Authenticated but forbidden for the current API key scope
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    PublicNotFound:
      description: Resource not found (or not accessible for this team/scope)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    sourceApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Source API key created under /api/sources/:sourceId/api-keys
    teamApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: 'Team API key created under /api/api-keys. Prefix: sb_api_.'

````