Hi <@U04S8PLJWMT> which api to use to start a job ...
# ask-ai
i
Hi @kapa.ai which api to use to start a job programmatically in airbyte ?
k
To start a job programmatically in Airbyte, you should use the Airbyte Public API endpoint:
Copy code
POST /jobs
This endpoint allows you to trigger a sync or reset job for a specific connection. You need to provide the following in the request body: - connectionId: The UUID of the connection you want to trigger. - jobType: Either "sync" or "reset". Example request body:
Copy code
json {   "connectionId": "your-connection-uuid",   "jobType": "sync" }
You can find more details and example code for triggering a job using this API in the official documentation and tutorials. For example, here is a C# snippet that demonstrates how to trigger a sync job:
Copy code
csharp var client = new RestClient("https://api.airbyte.com/v1/jobs");   var request = new RestRequest();   request.AddHeader("accept", "application/json");   request.AddHeader("content-type", "application/json");   request.AddHeader("Authorization", "Bearer {YourApiKey}");   request.AddParameter("application/json", "{\"connectionId\":\"YourConnectionID\",\"jobType\":\"sync\"}", ParameterType.RequestBody);   var response = client.ExecutePost(request);
Replace
YourApiKey
and
YourConnectionID
with your actual values. This will start the job for the specified connection [Create and Monitor a Data Pipeline Using the Airbyte API](https://airbyte.com/tutorials/create-and-monitor-a-data-pipeline-using-the-airbyte-api) and [Airbyte Public API Reference](https://reference.airbyte.com/reference/start). For more details on authentication and API usage, refer to the official API documentation [API documentation](https://docs.airbyte.com/developers/api-documentation).
i
@kapa.ai in the dev tools, when i click in airbyte UI the sync button This api is being hit api/v1/connections/sync
k
A message from kapa.ai
Yes, when you click the "Sync" button in the Airbyte UI, the API endpoint that is hit is:
Copy code
POST /api/v1/connections/sync
This endpoint triggers a sync job for the specified connection. You need to provide the
connectionId
in the request body. For example, using cURL:
Copy code
bash curl -X POST "http://localhost:8000/api/v1/connections/sync" \   -H "Accept: application/json" \   -H "Content-Type: application/json" \   -d '{"connectionId":"<your-connection-id>"}'
This will start a sync job, and you should see a response indicating the job has started, including its status and job ID [Airflow and Airbyte OSS - Better Together](https://airbyte.com/tutorials/how-to-use-airflow-and-airbyte-together). This matches the behavior you observed in the developer tools when clicking the sync button in the Airbyte UI.