<@U04S8PLJWMT> how can i add a source type value i...
# ask-ai
o
@kapa.ai how can i add a source type value inorder to use it in the api to my python connector
k
To add a
source_type
value for use in the Airbyte API with your Python connector, you need to include the
source_type
field in your source configuration when making API requests. This is especially important when creating a source via the Airbyte API or Terraform, as the API expects this field to identify the connector type. Here’s how you can do it: ### 1. In API Requests When creating a source using the Airbyte API, include the
source_type
in your JSON payload. For example, if your connector is for Postgres, you would use
"source_type": "postgres"
. For a custom connector, use the appropriate identifier for your connector. Example (Python, using requests or similar):
Copy code
json {   "configuration": {     "host": "YourDatabaseServerName",     "port": 5432,     "source_type": "postgres",  // <-- This is the source_type field     "database": "YourDatabaseName",     "username": "YourSQLUser",     "password": "YourSQLUserPassword",     "schemas": ["public"],     "ssl_mode": {"mode": "require"},     "replication_method": {"method": "Standard"},     "tunnel_method": {"tunnel_method": "NO_TUNNEL"}   },   "name": "YourSourceName",   "workspaceId": "YourWorkspaceID" }
This field is required by the API to identify which connector to use for the source you are creating. If you omit it, the API may return an error or not recognize your connector properly. For custom connectors, ensure you use the correct
source_type
or provide the
definition_id
if required by your setup [see example here](https://airbyte.com/tutorials/create-and-monitor-a-data-pipeline-using-the-airbyte-api). ### 2. In Terraform Similarly, when using Terraform, you specify the
source_type
in your resource configuration:
Copy code
hcl resource "airbyte_source_custom" "my_source_stripe" {   configuration = jsonencode({     "source_type" : "stripe",     "account_id" : "YOUR_STRIPE_ACCOUNT_ID",     "client_secret" : "YOUR_STRIPE_CLIENT_SECRET",     "start_date" : "2023-07-01T00:00:00Z",     "lookback_window_days" : 0,     "slice_range" : 365   })   name = "Stripe"   workspace_id = var.workspace_id }
If you are using a custom connector, you may also need to provide the
definition_id
 [see documentation](https://docs.airbyte.com/platform/terraform-documentation#step-2-create-a-source). ### 3. For Python Connectors If you are developing a Python connector and want to use it with the API, ensure that your connector is registered with the correct
source_type
in Airbyte. When you create a source via the API, use this value in the
source_type
field as shown above. Note: There was a known issue where the
sourceType
field was missing in the API response for custom connectors, which could cause issues with some SDKs. If you encounter this, check for updates or workarounds in the Airbyte community [see GitHub issue](https://github.com/airbytehq/airbyte/issues/48788). --- In summary: - Always include the
source_type
field in your API or Terraform configuration when creating a source. - For custom connectors, ensure you use the correct identifier and, if needed, the
definition_id
. If you need to find the exact
source_type
for your connector, refer to your connector’s documentation or the manifest file you used to define it [see example](https://airbyte.com/tutorials/how-to-add-custom-source-to-pyairbyte-using-the-no-code-builder).
o
@kapa.ai i want to set a sourceType to my custom python source with the airbyte cdk how can i set it in my custom source?
k
A message from kapa.ai
To set a
sourceType
for your custom Python source connector built with the Airbyte CDK, you do not set this value directly in your Python code. Instead, the
sourceType
is determined by how your connector is registered and referenced in Airbyte. Here’s what the knowledge sources indicate: - The
sourceType
is used in API requests and Terraform configurations to identify which connector to use when creating a source instance. For custom connectors, this is typically managed by the connector’s registration and its metadata, not by a field in your Python code. - When you create a source via the API or Terraform, you specify the
sourceType
(or
definitionId
for custom connectors) in the configuration payload. This tells Airbyte which connector definition to use for the source you are creating [see example](https://docs.airbyte.com/platform/terraform-documentation#step-2-create-a-source). - In the connector’s code, you define the required configuration schema in the
spec.yaml
file, but there is no mention in the documentation of setting a
sourceType
attribute in the Python class itself [see basic concepts](https://docs.airbyte.com/platform/connector-development/cdk-python/basic-concepts). Summary: You do not set
sourceType
in your Python source code. Instead, ensure your connector is properly registered in Airbyte (with its metadata and manifest), and then reference it by
sourceType
or
definitionId
when creating a source via the API or Terraform. The knowledge sources do not describe a way to set
sourceType
directly in the Python CDK code. If you need to expose a specific identifier for your connector, ensure your connector’s metadata and manifest are correctly configured, as these are used by Airbyte to map the
sourceType
in API and UI operations [see metadata requirements](https://docs.airbyte.com/platform/contributing-to-airbyte/resources/qa-checks#-metadata).