Connect Github
https://agent.blackbox.ai/api/v1/git/configValidate and store a GitHub personal access token. Enables repository access for agent tasks. Replaces any previously stored token.
This endpoint validates a GitHub personal access token against the GitHub API and stores it for future agent tasks. If a token is already stored, it is replaced.
This endpoint requires a Pro subscription. Required GitHub token scopes: repo (for private repos) and user (for profile info).
Authentication
To use this API, you need a BLACKBOX API Key. Follow these steps to get your API key:
- Go to app.blackbox.ai/agent-api and click Get an API Key (requires a Pro subscription)
- Once provisioning completes, you will be redirected to your Dashboard
- From the Dashboard, create an API key to use with all Agent API requests
Your API key will be in the format: sk-xxxxxxxxxxxxxxxxxxxxxx
Headers
AuthorizationstringrequiredAPI Key of the form Bearer <api_key>.
Example: Bearer sk_b41b647ffbfed27f616560
Content-TypestringrequiredMust be application/json.
Request Body
githubTokenstringrequiredA GitHub personal access token (classic or fine-grained).
Example: "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Response Fields
successbooleantrue when the token was validated and stored successfully.
loginstringGitHub username confirmed by the token.
curl -X POST 'https://agent.blackbox.ai/api/v1/git/config' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{ "githubToken": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }'const API_KEY = "YOUR_API_KEY";
const response = await fetch(
"https://agent.blackbox.ai/api/v1/git/config",
{
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ githubToken: "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }),
}
);
const data = await response.json();
console.log(`Stored token for: ${data.login}`);import requests
API_KEY = "YOUR_API_KEY"
response = requests.post(
"https://agent.blackbox.ai/api/v1/git/config",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={"githubToken": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},
)
data = response.json()
print(f"Stored token for: {data['login']}")package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
apiKey := "YOUR_API_KEY"
url := "https://agent.blackbox.ai/api/v1/git/config"
body, _ := json.Marshal(map[string]string{
"githubToken": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
})
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
respBody, _ := io.ReadAll(resp.Body)
var result map[string]interface{}
json.Unmarshal(respBody, &result)
fmt.Printf("Stored token for: %s\n", result["login"])
}{
"success": true,
"login": "octocat"
}{
"error": "Invalid GitHub token: authentication failed"
}{
"error": "githubToken is required"
}Error Codes
| Status Code | Error | Description |
|---|---|---|
| 200 | Success | Token validated and stored |
| 400 | Bad Request | Missing githubToken or token rejected by GitHub |
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Pro subscription required |
| 500 | Internal Server Error | Failed to validate or store token |