Authentication
The CodeBeaver API uses API keys to authenticate requests. You can manage your API keys from the Team page. Every team can have multiple API keys. Team members can deactivate API keys if needed.API endpoints
POST Webhook
The POST Webhook endpoint allows you to programmatically trigger CodeBeaver to analyze and write tests for your code. This is particularly useful when you want to integrate CodeBeaver into your own CI/CD pipelines or development workflows.Endpoint
Headers
To authenticate your request, include your API token in the Authorization header:Request Body
The webhook accepts different types of actions through its payload. Here are the supported payload structures: For triggering analysis on a Pull Request:Field Descriptions
-
type
: Specifies what you want CodeBeaver to analyze. Currently supports:pull_request
: Analyze changes in a pull requestcommit
: Analyze changes in a specific commit
-
action
: Defines what CodeBeaver should do. Supports:analyze
: Analyzes changes and provides test results and bug detection analysisanalyze-and-generate
: Does everythinganalyze
does, plus generates test filesdry-run
: Performs analysis and shows what would be generated without making any changes
-
git_provider
: Identifies which Git hosting service you’re using. Supports:github
: GitHub repositoriesgitlab
: GitLab repositoriesbitbucket
: Bitbucket repositories
-
git_provider_id
: The unique identifier of your repository in your Git provider’s system -
pr_number
: Required when type is “pull_request”. The number of the pull request to analyze -
commit_sha
: Required when type is “commit”. The full SHA hash of the commit to analyze
Response
A successful request will return:Error Responses
The API may return the following error responses: 401 Unauthorized:Example Usage
Here’s a complete example showing how to trigger CodeBeaver on a pull request using curl:Rate Limits
To ensure service quality, the webhook API is rate limited. Current limits are:- 10 requests per minute per API token
- 1000 requests per day per team
Best Practices
When using the webhook API, consider these recommendations:- Store your API token securely and never commit it to version control
- Implement proper error handling for API responses
- Consider implementing retries with exponential backoff for failed requests
- Monitor your API usage to stay within rate limits
- Keep your API tokens rotated regularly for security
Getting Help
If you encounter any issues or need assistance with the webhook API:- Join our Discord community
- Contact our support team at info@codebeaver.ai