{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pipeshub/json-schema/pipeshub-create-connector-request-schema.json",
  "title": "CreateConnectorRequest",
  "description": "Request to create a new connector instance",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pipeshub-connector-instances-api-openapi.yml#/components/schemas/CreateConnectorRequest",
  "type": "object",
  "required": [
    "connectorType",
    "instanceName",
    "scope"
  ],
  "properties": {
    "connectorType": {
      "type": "string",
      "description": "Connector type from registry (e.g., google-drive, confluence, slack)"
    },
    "instanceName": {
      "type": "string",
      "description": "Display name for this connector instance",
      "minLength": 1,
      "maxLength": 100
    },
    "scope": {
      "$ref": "#/$defs/ConnectorScope"
    },
    "authType": {
      "type": "string",
      "description": "Authentication type (required if connector supports multiple auth methods)",
      "enum": [
        "OAUTH",
        "OAUTH_ADMIN_CONSENT",
        "API_TOKEN",
        "USERNAME_PASSWORD",
        "SERVICE_ACCOUNT"
      ]
    },
    "oauthConfigId": {
      "type": "string",
      "description": "ID of admin-created OAuth App to use (required for non-admin users creating OAuth connectors, optional for admins)"
    },
    "config": {
      "type": "object",
      "description": "Initial configuration (can also be set after creation)",
      "properties": {
        "auth": {
          "$ref": "#/$defs/ConnectorAuthConfig"
        },
        "sync": {
          "$ref": "#/$defs/ConnectorSyncConfig"
        },
        "filters": {
          "$ref": "#/$defs/ConnectorFiltersConfig"
        }
      }
    },
    "baseUrl": {
      "type": "string",
      "description": "Base URL for self-hosted instances (e.g., Confluence Server, GitLab Self-Managed)",
      "format": "uri"
    }
  },
  "$defs": {
    "ConnectorAuthConfig": {
      "type": "object",
      "description": "Authentication configuration for a connector instance",
      "properties": {
        "values": {
          "type": "object",
          "description": "Authentication values (keys depend on connector's auth schema)",
          "additionalProperties": true
        },
        "oauthConfigId": {
          "type": "string",
          "description": "ID of admin-created OAuth configuration to use"
        },
        "customValues": {
          "type": "object",
          "description": "Custom authentication values specific to the connector",
          "additionalProperties": true
        }
      }
    },
    "ConnectorFiltersConfig": {
      "type": "object",
      "description": "Filter configuration to control what data is synced (sync filters and indexing filters)",
      "properties": {
        "sync": {
          "type": "object",
          "description": "Sync filter selections",
          "properties": {
            "values": {
              "type": "object",
              "description": "Selected filter values (keys are filter field names)",
              "additionalProperties": true
            }
          }
        },
        "indexing": {
          "type": "object",
          "description": "Indexing filter selections",
          "properties": {
            "values": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      }
    },
    "ConnectorScope": {
      "type": "string",
      "description": "Scope determines visibility and access control for connectors:<br>\n<ul>\n<li><code>team</code> - Available to all users in the organization (admin-only creation)</li>\n<li><code>personal</code> - Private to the creating user only</li>\n</ul>\n",
      "enum": [
        "team",
        "personal"
      ]
    },
    "ConnectorSyncConfig": {
      "type": "object",
      "description": "Synchronization configuration for a connector instance",
      "properties": {
        "selectedStrategy": {
          "type": "string",
          "enum": [
            "MANUAL",
            "SCHEDULED",
            "WEBHOOK",
            "REALTIME"
          ],
          "description": "Sync strategy: MANUAL (user-triggered), SCHEDULED (interval/cron), WEBHOOK (event-driven), REALTIME (WebSocket)",
          "default": "MANUAL"
        },
        "scheduledConfig": {
          "type": "object",
          "description": "Configuration for scheduled sync strategy",
          "properties": {
            "intervalMinutes": {
              "type": "integer",
              "description": "Sync interval in minutes",
              "minimum": 5,
              "default": 60
            },
            "cronExpression": {
              "type": "string",
              "description": "Cron expression for advanced scheduling"
            },
            "timezone": {
              "type": "string",
              "description": "Timezone for scheduled sync",
              "default": "UTC"
            }
          }
        },
        "webhookConfig": {
          "type": "object",
          "description": "Configuration for webhook-based sync",
          "properties": {
            "webhookUrl": {
              "type": "string",
              "description": "URL to receive webhook events (auto-generated)"
            },
            "events": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Subscribed event types"
            }
          }
        },
        "values": {
          "type": "object",
          "description": "Sync setting values specific to the connector",
          "additionalProperties": true
        },
        "customValues": {
          "type": "object",
          "description": "Custom sync values",
          "additionalProperties": true
        }
      }
    }
  }
}