# Connect GitHub repository Connect a GitHub repository to an existing automation for automatic synchronization. #### Path Parameters **`automation_id`** string required The ID of the automation to connect. #### Headers **`Authorization`** string required **`Content-Type`** string required ยท `application/json` #### Request Body **`repository_url`** string required GitHub repository URL (e.g., `https://github.com/owner/repo`) **`branch`** string required Branch name to sync from (e.g., `main`) **`credentials`** object required GitHub authentication credentials - **`token`** string required - GitHub personal access token ## Returns Returns the updated automation object with GitHub connection details. Basic Request ```bash curl -X POST "https://api.aitronos.com/v1/streamline/automations/auto_abc123/github/connect" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "repository_url": "https://github.com/owner/repo", "branch": "main", "credentials": { "token": "ghp_..." } }' ``` ```python import os import requests automation_id = "auto_abc123" response = requests.post( f"https://api.aitronos.com/v1/streamline/automations/{automation_id}/github/connect", headers={ "Authorization": f"Bearer {os.environ['FREDDY_SESSION_TOKEN']}", "Content-Type": "application/json" }, json={ "repository_url": "https://github.com/owner/repo", "branch": "main", "credentials": { "token": os.environ["GITHUB_TOKEN"] } } ) response.raise_for_status() automation = response.json() ``` ```javascript const automationId = "auto_abc123"; const res = await fetch( `https://api.aitronos.com/v1/streamline/automations/${automationId}/github/connect`, { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ repository_url: "https://github.com/owner/repo", branch: "main", credentials: { token: process.env.GITHUB_TOKEN } }) } ); const automation = await res.json(); ``` Different Branch ```bash curl -X POST "https://api.aitronos.com/v1/streamline/automations/auto_abc123/github/connect" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "repository_url": "https://github.com/owner/repo", "branch": "develop", "credentials": { "token": "ghp_..." } }' ``` ```python import os import requests response = requests.post( "https://api.aitronos.com/v1/streamline/automations/auto_abc123/github/connect", headers={ "Authorization": f"Bearer {os.environ['FREDDY_SESSION_TOKEN']}", "Content-Type": "application/json" }, json={ "repository_url": "https://github.com/owner/repo", "branch": "develop", "credentials": {"token": os.environ["GITHUB_TOKEN"]} } ) automation = response.json() print(f"Connected to {automation['git_repository_url']} on {automation['git_branch']}") ``` ```javascript const response = await fetch( "https://api.aitronos.com/v1/streamline/automations/auto_abc123/github/connect", { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ repository_url: "https://github.com/owner/repo", branch: "develop", credentials: { token: process.env.GITHUB_TOKEN } }) } ); const automation = await response.json(); console.log(`Connected to ${automation.git_repository_url} on ${automation.git_branch}`); ``` **Response:** 200 OK ```json { "id": "auto_abc123", "name": "My Automation", "organization_id": "org_xyz789", "automation_id": "internal_id", "execution_file_path": "main.py", "upload_method": "git", "description": "Automation description", "parameters": {}, "git_repository_url": "https://github.com/owner/repo", "git_branch": "main", "git_last_commit_sha": "abc123def456", "git_last_sync_at": "2025-11-15T10:30:00Z", "git_webhook_id": "12345678", "schedule_enabled": false, "cron_expression": null, "timezone": null, "is_active": true, "created_at": "2025-11-15T10:00:00Z", "updated_at": "2025-11-15T10:30:00Z" } ``` 400 Bad Request ```json { "success": false, "error": { "code": "INVALID_INPUT", "message": "Invalid repository URL format", "status": 400, "trace_id": "req_d4a118e7" } } ``` 401 Unauthorized ```json { "success": false, "error": { "code": "INVALID_CREDENTIALS", "message": "Invalid GitHub token", "status": 401, "trace_id": "req_bf0fa421" } } ``` 404 Not Found ```json { "success": false, "error": { "code": "RESOURCE_NOT_FOUND", "message": "Automation not found", "status": 404, "trace_id": "req_05f27f1d" } } ``` 409 Conflict ```json { "success": false, "error": { "code": "RESOURCE_ALREADY_EXISTS", "message": "Automation already connected to a GitHub repository", "status": 409, "trace_id": "req_35651c18" } } ```