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

> Use this endpoint to create a new database connection for the organization. The `configName` must be unique per organization. The password is encrypted upon creation and a UUID is automatically generated as the connection identifier.



## OpenAPI

````yaml /en/openapi/v3-current/connections.yaml post /v1/management/connections
openapi: 3.1.0
info:
  title: Database Connections
  description: >-
    The database connections API provides endpoints for managing the database
    connections used by Reporter. It allows you to create, list, update, delete,
    and test database connections, as well as validate schemas against
    configured data sources.
  version: 1.0.0
servers:
  - url: https://reporter.sandbox.lerian.net
security: []
tags:
  - name: Database Connections
    description: Endpoints for managing database connections used by Reporter.
paths:
  /v1/management/connections:
    post:
      tags:
        - Database Connections
      summary: Create a connection
      description: >-
        Use this endpoint to create a new database connection for the
        organization. The `configName` must be unique per organization. The
        password is encrypted upon creation and a UUID is automatically
        generated as the connection identifier.
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - name: X-Product-Name
          in: header
          description: >-
            The product name to associate with this connection. Must contain
            only alphanumeric characters, underscores, and hyphens (max 100
            characters). The value is normalized to lowercase.
          required: true
          schema:
            type: string
            maxLength: 100
            pattern: ^[a-zA-Z0-9_-]+$
            example: my-product
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateConnectionRequest'
            example:
              configName: production-db
              type: POSTGRESQL
              host: db.example.com
              port: 5432
              databaseName: mydatabase
              userName: dbuser
              password: secretpassword
              schema: public
              ssl:
                mode: require
                ca: |
                  -----BEGIN CERTIFICATE-----
                  MIIDdzCCAl+gAwIBAgIEbV...
                  -----END CERTIFICATE-----
              metadata:
                environment: production
                team: data-engineering
      responses:
        '201':
          description: Indicates that the connection was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionResponse'
              example:
                id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                configName: production-db
                productName: my-product
                type: POSTGRESQL
                host: db.example.com
                port: 5432
                databaseName: mydatabase
                userName: dbuser
                schema: public
                ssl:
                  mode: require
                metadata:
                  environment: production
                  team: data-engineering
                createdAt: '2024-01-15T10:30:00Z'
                updatedAt: '2024-01-15T10:30:00Z'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0001:
                  $ref: '#/components/examples/Error0001'
                Error0402:
                  $ref: '#/components/examples/Error0402'
                Error0400:
                  $ref: '#/components/examples/Error0400'
                Error0410:
                  $ref: '#/components/examples/Error0410'
                Error0412:
                  $ref: '#/components/examples/Error0412'
                Error0411:
                  $ref: '#/components/examples/Error0411'
        '409':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error1002:
                  $ref: '#/components/examples/Error1002'
        '500':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0002:
                  $ref: '#/components/examples/Error0002'
        '503':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0003:
                  $ref: '#/components/examples/Error0003'
      security: []
components:
  parameters:
    Authorization:
      name: Authorization
      in: header
      description: >-
        The authorization token in the `Bearer <token>` format.


        **Important:** This header is required if your environment has Access
        Manager enabled. For more information, refer to the [Access
        Manager](/en/platform/access-manager/access-manager) documentation.
      required: false
      schema:
        type: string
        example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
  schemas:
    CreateConnectionRequest:
      type: object
      description: Request body for creating a new database connection.
      required:
        - configName
        - type
        - host
        - port
        - databaseName
        - userName
        - password
      properties:
        configName:
          type: string
          description: >-
            Unique identifier name for this connection configuration. Must be
            between 3 and 100 characters. Must be unique within the
            organization.
          minLength: 3
          maxLength: 100
          example: production-db
        type:
          type: string
          description: >-
            Database engine type. Supported values: `ORACLE`, `SQL_SERVER`,
            `POSTGRESQL`, `MONGODB`, `MYSQL`. Note that the data source `type`
            field in the [List Data
            Sources](/en/reference/reporter/list-data-sources) endpoint returns
            lowercase identifiers (`postgresql`, `mongodb`).
          enum:
            - ORACLE
            - SQL_SERVER
            - POSTGRESQL
            - MONGODB
            - MYSQL
          example: POSTGRESQL
        host:
          type: string
          description: Hostname or IP address of the database server.
          example: db.example.com
        port:
          type: integer
          description: Network port number for the database connection.
          minimum: 1
          maximum: 65535
          example: 5432
        databaseName:
          type: string
          description: Name of the database to connect to on the target server.
          example: mydatabase
        userName:
          type: string
          description: Username credential for database authentication.
          example: dbuser
        password:
          type: string
          description: >-
            Password credential for database authentication. This value is
            encrypted upon storage.
          format: password
          example: secretpassword
        schema:
          type: string
          description: >-
            Database schema name (for example, `public`, `my_schema`). Useful
            for PostgreSQL databases with custom schemas. If omitted, Reporter
            defaults to the `public` schema.
          example: public
        ssl:
          $ref: '#/components/schemas/SSL'
        metadata:
          $ref: '#/components/schemas/Metadata'
    ConnectionResponse:
      type: object
      description: Response object containing connection details.
      required:
        - id
        - configName
        - type
        - host
        - port
        - databaseName
        - userName
        - createdAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier of the connection (UUID format).
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        productName:
          type: string
          description: >-
            The product name associated with this connection. May be empty if
            the connection has not been assigned to a product.
          example: my-product
        configName:
          type: string
          description: Unique identifier name for this connection configuration.
          example: production-db
        type:
          type: string
          description: >-
            Database engine type. Supported values: `ORACLE`, `SQL_SERVER`,
            `POSTGRESQL`, `MONGODB`, `MYSQL`. Note that the data source `type`
            field in the [List Data
            Sources](/en/reference/reporter/list-data-sources) endpoint returns
            lowercase identifiers (`postgresql`, `mongodb`).
          enum:
            - ORACLE
            - SQL_SERVER
            - POSTGRESQL
            - MONGODB
            - MYSQL
          example: POSTGRESQL
        host:
          type: string
          description: Hostname or IP address of the database server.
          example: db.example.com
        port:
          type: integer
          description: Network port number for the database connection.
          example: 5432
        databaseName:
          type: string
          description: Name of the database to connect to on the target server.
          example: mydatabase
        userName:
          type: string
          description: Username credential for database authentication.
          example: dbuser
        schema:
          type: string
          description: Database schema name, when set.
          example: public
        ssl:
          $ref: '#/components/schemas/SSL'
        metadata:
          $ref: '#/components/schemas/Metadata'
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp indicating when the connection was created.
          example: '2024-01-15T10:30:00Z'
        updatedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp indicating when the connection was last updated.
          example: '2024-01-15T10:30:00Z'
    Error:
      type: object
      description: >-
        Response message error. Error codes use the `FET` prefix to identify
        issues related to the database connections API.
      required:
        - code
        - title
        - message
      properties:
        code:
          type: string
          description: A unique, stable identifier for the error (prefixed with `FET`).
          example: FET-0001
        title:
          type: string
          description: A brief summary of the issue.
          example: Missing required fields
        message:
          type: string
          description: Detailed guidance for resolving the error.
          example: >-
            One or more required fields are missing. Please ensure all required
            fields like configName, host, port, userName, and password are
            included.
    SSL:
      type: object
      description: SSL configuration object containing certificate and security options.
      required:
        - mode
      properties:
        mode:
          type: string
          description: >-
            SSL connection mode. Supported values: - `disable`: No SSL
            connection - `require`: SSL required but no certificate verification
            - `verify-ca`: SSL with CA certificate verification - `verify-full`:
            SSL with full certificate verification
          enum:
            - disable
            - require
            - verify-ca
            - verify-full
          example: require
        ca:
          type: string
          description: >-
            Certificate Authority (CA) certificate for server verification (PEM
            format).
          example: |
            -----BEGIN CERTIFICATE-----
            MIIDdzCCAl+gAwIBAgIEbV...
            -----END CERTIFICATE-----
        cert:
          type: string
          description: Client certificate for SSL mutual authentication (PEM format).
        key:
          type: string
          description: Private key for the client certificate (PEM format).
    Metadata:
      type: object
      additionalProperties:
        type: string
        maxLength: 2000
      description: >-
        An object containing key-value pairs for storing additional
        connection-related information. Keys (max 100 characters) and values
        (max 2000 characters) must be strings. Nested objects are not allowed.
      example:
        environment: production
        team: data-engineering
  examples:
    Error0001:
      summary: Missing required fields
      value:
        code: FET-0001
        title: Missing required fields
        message: >-
          One or more required fields are missing. Please ensure all required
          fields like configName, host, port, userName, and password are
          included.
    Error0402:
      summary: Missing Fields in Request
      value:
        code: FET-0402
        title: Missing Fields in Request
        message: >-
          Your request is missing one or more required fields. Please refer to
          the documentation to ensure all necessary fields are included in your
          request.
    Error0400:
      summary: Unexpected Fields in the Request
      value:
        code: FET-0400
        title: Unexpected Fields in the Request
        message: >-
          The request body contains more fields than expected. Please send only
          the allowed fields as per the documentation. The unexpected fields are
          listed in the fields object.
    Error0410:
      summary: Invalid Metadata Nesting
      value:
        code: FET-0410
        title: Invalid Metadata Nesting
        message: >-
          The metadata object cannot contain nested values. Please ensure that
          the value is not nested and try again.
    Error0412:
      summary: Metadata Key Length Exceeded
      value:
        code: FET-0412
        title: Metadata Key Length Exceeded
        message: >-
          The metadata key exceeds the maximum allowed length of 100 characters.
          Please use a shorter key.
    Error0411:
      summary: Metadata Value Length Exceeded
      value:
        code: FET-0411
        title: Metadata Value Length Exceeded
        message: >-
          The metadata value exceeds the maximum allowed length of 2000
          characters. Please use a shorter value.
    Error1002:
      summary: Conflict
      value:
        code: FET-1002
        title: Conflict
        message: >-
          An entity of type connection with the same unique attributes already
          exists. Please use different values to avoid conflicts and review the
          data provided in the request.
    Error0002:
      summary: Internal Server Error
      value:
        code: FET-0002
        title: Internal Server Error
        message: >-
          The server encountered an unexpected error. Please try again later or
          contact support.
    Error0003:
      summary: Service Unavailable
      value:
        code: FET-0003
        title: Service Unavailable
        message: >-
          The server is currently unable to handle the request due to temporary
          overloading or maintenance of the server. Please try again later.

````