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

# Create a data source

> Registers a data source connection. The password is write-only: it is encrypted at rest and never returned by any operation.



## OpenAPI

````yaml /pt/openapi/v3-current/reporter.yaml post /v1/data-sources
openapi: 3.1.0
info:
  contact:
    name: Discord community
    url: https://discord.gg/DnhqKwkGv3
  description: >-
    This is OpenAPI documentation for Reporter. The unified reporter binary
    serves the REST API (RUN_MODE=api) and/or the RabbitMQ report-generation
    worker (RUN_MODE=worker); RUN_MODE=all runs both in one process for local
    development. All REST endpoints documented here serve only when RUN_MODE=api
    or all (port :4005); the worker (port :4006) exposes health/readyz/version
    only.
  license:
    name: Lerian Studio General License
  title: Midaz Reporter API
  version: 4.0.0
servers:
  - url: http://localhost:4005
  - url: https://localhost:4005
security:
  - BearerAuth: []
tags:
  - description: Generated report instances and their lifecycle.
    name: Reports
  - description: Reusable report definitions.
    name: Templates
  - description: Interactive construction of report templates.
    name: Template Builder
  - description: Scheduled report due-date tracking.
    name: Deadlines
  - description: Configured inputs that feed report data.
    name: Data Sources
  - description: Aggregated reporting metrics.
    name: Metrics
  - description: Published business event catalog and delivery policies.
    name: Streaming
paths:
  /v1/data-sources:
    post:
      tags:
        - Data Sources
      summary: Create a data source
      description: >-
        Registers a data source connection. The password is write-only: it is
        encrypted at rest and never returned by any operation.
      operationId: createDataSource
      requestBody:
        content:
          application/json:
            schema:
              properties:
                configName:
                  description: >-
                    Stable business key referenced by templates; unique among
                    live data sources.
                  examples:
                    - midaz_onboarding
                  type: string
                databaseName:
                  description: Database name.
                  examples:
                    - onboarding
                  type: string
                host:
                  description: Database host.
                  examples:
                    - db.internal
                  type: string
                metadata:
                  additionalProperties: {}
                  description: Free-form metadata.
                  type: object
                options:
                  description: >-
                    MongoDB URI options string (e.g. authSource=admin). Not
                    applicable to postgresql.
                  examples:
                    - authSource=admin
                  type: string
                password:
                  description: >-
                    Write-only credential: encrypted at rest, never returned by
                    any operation.
                  examples:
                    - '-'
                  type: string
                port:
                  description: Database port.
                  examples:
                    - 5432
                  format: int64
                  type: integer
                schemas:
                  description: >-
                    PostgreSQL schemas to expose; defaults to [public]. Not
                    applicable to mongodb.
                  examples:
                    - - public
                  items:
                    type: string
                  type:
                    - array
                    - 'null'
                sslCaBase64:
                  description: >-
                    MongoDB or PostgreSQL: standard Base64 of a PEM CA bundle.
                    Mutually exclusive with an existing CA file; requires
                    verified TLS (postgresql requires sslMode verify-ca or
                    verify-full).
                  examples:
                    - ''
                  type: string
                sslMode:
                  description: >-
                    TLS mode: disable, require, verify-ca, or verify-full.
                    Defaults to verify-full for PostgreSQL with sslCaBase64;
                    otherwise defaults to require when omitted.
                  examples:
                    - require
                  type: string
                type:
                  description: 'Data source engine type: postgresql or mongodb.'
                  examples:
                    - postgresql
                  type: string
                username:
                  description: Database username.
                  examples:
                    - reporter_ro
                  type: string
              required:
                - configName
                - databaseName
                - host
                - password
                - port
                - type
                - username
              type: object
        description: JSON request payload.
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataSource'
          description: Created
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unauthorized
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Forbidden
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Conflict
        '412':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Precondition Failed
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
components:
  schemas:
    DataSource:
      properties:
        builtIn:
          description: >-
            True for a data source the platform provides from the tenant's
            Lerian module databases; read-only, never registered
          examples:
            - false
          type: boolean
        configName:
          description: Stable business key referenced by templates
          examples:
            - midaz_onboarding
          type: string
        createdAt:
          description: Creation timestamp in UTC
          examples:
            - '2026-01-01T00:00:00Z'
          format: date-time
          type: string
        databaseName:
          description: Database name
          examples:
            - onboarding
          type: string
        host:
          description: Database host
          examples:
            - db.internal
          type: string
        id:
          description: Unique data source identifier
          examples:
            - 00000000-0000-0000-0000-000000000000
          type: string
        lastConnection:
          $ref: '#/components/schemas/DataSourceConnection'
          description: >-
            Outcome of the most recent connectivity probe; absent means never
            probed, which is not the same as failed
        metadata:
          additionalProperties: {}
          description: Free-form metadata
          type: object
        options:
          description: MongoDB URI options string (e.g. authSource=admin); mongodb only
          examples:
            - authSource=admin
          type: string
        port:
          description: Database port
          examples:
            - 5432
          format: int64
          type: integer
        schemas:
          description: PostgreSQL schemas to expose
          examples:
            - - public
          items:
            type: string
          type:
            - array
            - 'null'
        sslCaBase64:
          description: >-
            Base64-encoded PEM CA bundle for MongoDB or PostgreSQL; never a
            private key. PostgreSQL requires sslMode verify-ca or verify-full.
          examples:
            - ''
          type: string
        sslMode:
          description: 'TLS mode: disable, require, verify-ca, or verify-full'
          examples:
            - require
          type: string
        type:
          description: Data source engine type
          examples:
            - postgresql
          type: string
        updatedAt:
          description: Most recent update timestamp in UTC
          examples:
            - '2026-01-01T00:00:00Z'
          format: date-time
          type: string
        username:
          description: Database username
          examples:
            - reporter_ro
          type: string
      type: object
    Detail:
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          examples:
            - - location: body.templateId
                message: expected string to match 'uuid' format
                value: not-a-uuid
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    DataSourceConnection:
      additionalProperties: false
      properties:
        checkedAt:
          description: >-
            When the last probe ran, in UTC. Distinct from updatedAt, which
            records configuration edits
          examples:
            - '2026-01-01T00:00:00Z'
          format: date-time
          type: string
        latencyMs:
          description: Full dial+ping round trip of the last probe, in milliseconds
          examples:
            - 42
          format: int64
          type: integer
        message:
          description: >-
            Client-safe classification of the last probe; raw driver errors
            never appear here
          examples:
            - connection successful
          type: string
        status:
          description: 'Outcome of the last probe: connected or failed'
          examples:
            - connected
          type: string
      required:
        - status
        - message
        - latencyMs
        - checkedAt
      type: object
    ErrorDetail:
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          examples:
            - body.templateId
          type: string
        message:
          description: Error message text
          examples:
            - expected string to match 'uuid' format
          type: string
        value:
          description: The value at the given location
          examples:
            - not-a-uuid
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````