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

# Create integration

> Create a new HTTP or MCP integration. For MCP integrations, tools are automatically synced from the MCP server. Authentication is validated during creation.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/integration
openapi: 3.1.0
info:
  title: Diga API
  version: 0.1.0
servers:
  - url: https://api.diga.io
    description: Production
security: []
paths:
  /v1/integration:
    post:
      tags:
        - Integration
      summary: Create integration
      description: >-
        Create a new HTTP or MCP integration. For MCP integrations, tools are
        automatically synced from the MCP server. Authentication is validated
        during creation.
      operationId: create_integration_v1_integration_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateIntegrationRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IntegrationResponse'
        '401':
          description: Unauthorized - MCP authentication failed
          content:
            application/json:
              example:
                status: error
                error_code: M_C_P_AUTHENTICATION_FAILED
                message: 'MCP server authentication failed: Invalid credentials'
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              example:
                status: error
                error_code: MISSING_PERMISSIONS
                message: Missing required permissions to create integrations
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              example:
                status: error
                error_code: INTERNAL_SERVER_ERROR
                message: 'Error: Internal Server Error'
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '502':
          description: Bad gateway - MCP server error
          content:
            application/json:
              example:
                status: error
                error_code: M_C_P_SERVER_ERROR
                message: MCP server returned an error
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '504':
          description: Gateway timeout - MCP connection timeout
          content:
            application/json:
              example:
                status: error
                error_code: M_C_P_CONNECTION_TIMEOUT
                message: Connection to MCP server timed out
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
      security:
        - CustomHTTPBearer: []
components:
  schemas:
    CreateIntegrationRequest:
      properties:
        name:
          type: string
          title: Name
          description: Integration name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Integration description
        base_url:
          type: string
          title: Base Url
          description: Base URL (HTTP API or MCP server)
        integration_type:
          $ref: '#/components/schemas/IntegrationType'
          description: Integration type
        auth_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Auth Key
          description: Bearer token or API key
        headers:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Headers
          description: Custom headers
      type: object
      required:
        - name
        - base_url
        - integration_type
      title: CreateIntegrationRequest
      description: Request schema for creating an integration.
    IntegrationResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        base_url:
          type: string
          title: Base Url
        auth_type:
          $ref: '#/components/schemas/IntegrationAuthType'
        integration_type:
          $ref: '#/components/schemas/IntegrationType'
        auth_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Auth Key
        headers:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Headers
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - name
        - base_url
        - auth_type
        - integration_type
        - created_at
        - updated_at
      title: IntegrationResponse
      description: Response schema for integration.
    ErrorResponseSchema:
      properties:
        status:
          type: string
          title: Status
          description: Status of the response, always 'error' for error responses
          default: error
        error_code:
          type: string
          title: Error Code
          description: Machine-readable error code in SCREAMING_SNAKE_CASE format
          examples:
            - PROJECT_NOT_FOUND
            - INVALID_EMAIL
            - UNAUTHORIZED_ROLE
        message:
          type: string
          title: Message
          description: Human-readable error message with details
          examples:
            - Project with id 550e8400-e29b-41d4-a716-446655440000 not found
            - The email invalid@email is not valid
            - Insufficient permissions to perform this action
      type: object
      required:
        - error_code
        - message
      title: ErrorResponseSchema
      description: Standard error response format for all API errors.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    IntegrationType:
      type: string
      enum:
        - HTTP
        - MCP
      title: IntegrationType
      description: Integration type enum
    IntegrationAuthType:
      type: string
      enum:
        - NONE
        - API_KEY
      title: IntegrationAuthType
    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:
    CustomHTTPBearer:
      type: http
      scheme: bearer

````