> ## 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.

# Create Source



## OpenAPI

````yaml POST /public/v1/projects/{projectId}/sources
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/projects/{projectId}/sources:
    post:
      tags:
        - Public v1 Sources
      summary: Create a source
      operationId: publicV1CreateSource
      parameters:
        - $ref: '#/components/parameters/ProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSourceRequest'
            examples:
              managed:
                summary: Managed runtime target
                value:
                  name: Accounts source
                  schemaVersionId: 11111111-1111-1111-1111-111111111111
                  kind: postgres
                  config: {}
                  populate: false
              supabaseRuntimeTarget:
                summary: Supabase runtime target
                value:
                  name: Supabase source
                  schemaVersionId: 11111111-1111-1111-1111-111111111111
                  kind: postgres
                  config:
                    runtimeTarget:
                      provider: supabase
                      schema: sb_synth_data
                      connectionString: >-
                        postgresql://postgres:[password]@db.abcd1234.supabase.co:5432/postgres
                      projectRef: abcd1234
                  populate: false
      responses:
        '201':
          description: Source created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourceCreateResponse'
        '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:
  parameters:
    ProjectId:
      name: projectId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Project UUID in the team associated with the API key.
      example: 11111111-1111-1111-1111-111111111111
  schemas:
    CreateSourceRequest:
      type: object
      required:
        - name
        - schemaVersionId
      description: >-
        Create a source from a schema version. Use config.runtimeTarget for
        provider-specific runtime settings.
      properties:
        name:
          type: string
        description:
          type: string
        schemaVersionId:
          type: string
          format: uuid
        config:
          $ref: '#/components/schemas/CreateSourceConfig'
        kind:
          type: string
          enum:
            - postgres
            - mysql
          default: postgres
        seed:
          type: string
          description: Optional deterministic seed used by generators.
        generatorConfig:
          type: object
          additionalProperties: true
          description: >-
            Generation overrides (for example generationDefaults
            rowCount/locale/timezone and per-entity row counts).
        basePath:
          type: string
          description: Optional custom runtime base path for this source.
        rateLimitRpm:
          type: integer
          minimum: 1
          default: 100
          description: Runtime API per-source rate limit (requests per minute).
        corsOrigins:
          type: array
          description: Allowed CORS origins for runtime API requests.
          items:
            type: string
        requireAuth:
          type: boolean
          default: true
          description: Whether runtime endpoints require x-api-key authentication.
        populate:
          type: boolean
          default: true
          description: >-
            If true, triggers an initial populate generation after source
            creation.
    SourceCreateResponse:
      type: object
      additionalProperties: true
      description: >-
        Create-source response. Generation fields depend on inline vs queue
        execution mode.
      required:
        - source
      properties:
        source:
          $ref: '#/components/schemas/Source'
        generation:
          type: object
          nullable: true
          additionalProperties: true
          description: Inline generation audit when execution happens synchronously.
        generationJob:
          $ref: '#/components/schemas/GenerationJobSummary'
          description: Queue job details when execution is asynchronous.
        autoProvisionedApiKey:
          type: object
          nullable: true
          additionalProperties: true
        autoProvisionedReadOnlyDbAccess:
          type: object
          nullable: true
          additionalProperties: true
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error summary.
    CreateSourceConfig:
      type: object
      additionalProperties: true
      properties:
        runtimeTarget:
          $ref: '#/components/schemas/CreateSourceRuntimeTarget'
      description: Source configuration payload.
    Source:
      type: object
      additionalProperties: true
      properties:
        id:
          type: string
          format: uuid
        slug:
          type: string
        name:
          type: string
        description:
          type: string
          nullable: true
        schemaVersionId:
          type: string
          format: uuid
        config:
          type: object
          additionalProperties: true
          description: >-
            Source configuration. For Supabase runtime targets, responses
            include runtimeTarget.connectionSecretId and never return plaintext
            runtimeTarget.connectionString.
        kind:
          type: string
          enum:
            - postgres
            - mysql
        seed:
          type: string
          nullable: true
        generatorConfig:
          type: object
          nullable: true
          additionalProperties: true
        rateLimitRpm:
          type: integer
        requireAuth:
          type: boolean
        lastGenerationAt:
          type: string
          format: date-time
          nullable: true
        generationAudit:
          type: object
          nullable: true
          additionalProperties: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
          nullable: true
    GenerationJobSummary:
      type: object
      additionalProperties: true
      description: Background generation job summary when queue mode is enabled.
      properties:
        id:
          type: string
          description: Job ID used by /generation-jobs/{jobId}.
        status:
          type: string
          description: >-
            Current queue status (for example waiting, active, completed,
            failed).
        queueName:
          type: string
          nullable: true
          description: Queue name handling this generation job.
        attemptsMade:
          type: integer
          nullable: true
          description: Number of processing attempts made so far.
        finishedOn:
          type: string
          format: date-time
          nullable: true
          description: Completion timestamp when the job has finished.
        failedReason:
          type: string
          nullable: true
          description: Failure reason when status is failed.
        result:
          type: object
          nullable: true
          additionalProperties: true
          description: >-
            Optional result payload, typically including generation audit
            details.
    CreateSourceRuntimeTarget:
      type: object
      additionalProperties: true
      properties:
        provider:
          type: string
          enum:
            - managed
            - supabase
          default: managed
          description: >-
            Runtime target provider. Must be supabase when using Supabase
            connection details.
        schema:
          type: string
          description: Target runtime schema. Required when provider is supabase.
        connectionSecretId:
          type: string
          format: uuid
          description: Encrypted runtime connection secret identifier.
        connectionString:
          type: string
          description: >-
            Supabase/Postgres connection string. Required for Supabase targets
            when connectionSecretId is not provided. Stored encrypted and never
            returned in source responses.
        projectRef:
          type: string
          description: >-
            Optional Supabase project reference for source settings and
            generation metadata.
  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_.'

````