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

# Create Connection

> Create a new connection with validation.

This endpoint validates the provided credentials and configuration against
the integration's requirements before creating the connection.

**Validation includes:**
- Required fields are present
- Field types match expected types (email, url, etc.)
- Values match validation patterns (regex)
- Length constraints are met
- OAuth credentials are valid (if applicable)

**Example:**
```json
{
    "label": "My Gmail Connection",
    "integration": "gmail",
    "integration_type": "connectors",
    "auth_method_id": "oauth2",
    "credentials": {
        "access_token": "ya29.a0...",
        "refresh_token": "1//0g...",
        "token_type": "Bearer",
        "expires_at": "2025-10-19T12:00:00Z"
    },
    "config": {}
}
```

**Error Response (validation failure):**
```json
{
    "detail": {
        "message": "Connection validation failed",
        "errors": [
            "Field 'API Key' is required",
            "Field 'Email' must be a valid email address"
        ]
    }
}
```



## OpenAPI

````yaml api-reference/openapi.json post /api/v1/connections
openapi: 3.1.0
info:
  title: FastAPI app
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/connections:
    post:
      tags:
        - Connections
      summary: Create Connection
      description: >-
        Create a new connection with validation.


        This endpoint validates the provided credentials and configuration
        against

        the integration's requirements before creating the connection.


        **Validation includes:**

        - Required fields are present

        - Field types match expected types (email, url, etc.)

        - Values match validation patterns (regex)

        - Length constraints are met

        - OAuth credentials are valid (if applicable)


        **Example:**

        ```json

        {
            "label": "My Gmail Connection",
            "integration": "gmail",
            "integration_type": "connectors",
            "auth_method_id": "oauth2",
            "credentials": {
                "access_token": "ya29.a0...",
                "refresh_token": "1//0g...",
                "token_type": "Bearer",
                "expires_at": "2025-10-19T12:00:00Z"
            },
            "config": {}
        }

        ```


        **Error Response (validation failure):**

        ```json

        {
            "detail": {
                "message": "Connection validation failed",
                "errors": [
                    "Field 'API Key' is required",
                    "Field 'Email' must be a valid email address"
                ]
            }
        }

        ```
      operationId: create_connection_api_v1_connections_post
      parameters:
        - name: X-Workspace-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The workspace ID
            title: X-Workspace-Id
          description: The workspace ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConnectionCreate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionRead'
        '404':
          description: Connection not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - DualAuthScheme: []
components:
  schemas:
    ConnectionCreate:
      properties:
        label:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Label
          description: Human-readable label for the connection
        integration:
          type: string
          title: Integration
          description: Integration name (slack, github, etc.)
        integration_type:
          $ref: '#/components/schemas/IntegrationType'
          description: >-
            Type of integration (connectors, mcp, tool, model, storage, api,
            custom)
        config:
          additionalProperties: true
          type: object
          title: Config
          description: Integration-specific configuration
        credential_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Credential Id
          description: ID of the credential to use for this connection
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
          description: User ID who owns this connection
        credentials:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Credentials
          description: Credentials to use for this connection
        auth_method_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Auth Method Id
          description: >-
            Authentication method ID to use (defaults to integration's default
            method)
      type: object
      required:
        - integration
        - integration_type
      title: ConnectionCreate
      description: Schema for creating a new connection.
    ConnectionRead:
      properties:
        label:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Label
          description: Human-readable label for the connection
        integration:
          type: string
          title: Integration
          description: Integration name (slack, github, etc.)
        integration_type:
          $ref: '#/components/schemas/IntegrationType'
          description: >-
            Type of integration (connectors, mcp, tool, model, storage, api,
            custom)
        config:
          additionalProperties: true
          type: object
          title: Config
          description: Integration-specific configuration
        id:
          type: string
          title: Id
        credential_id:
          type: string
          title: Credential Id
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
        workspace_id:
          type: string
          title: Workspace Id
        created_by:
          type: string
          title: Created By
        status:
          $ref: '#/components/schemas/ConnectionStatus'
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - integration
        - integration_type
        - id
        - credential_id
        - user_id
        - workspace_id
        - created_by
        - status
        - created_at
        - updated_at
      title: ConnectionRead
      description: Schema for reading connection data.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    IntegrationType:
      type: string
      enum:
        - connectors
        - mcp
        - tool
        - model
        - custom
        - storage
        - api
      title: IntegrationType
    ConnectionStatus:
      type: string
      enum:
        - active
        - inactive
        - testing
        - error
        - expired
      title: ConnectionStatus
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    DualAuthScheme:
      type: http
      scheme: bearer

````