POST /functions/v1/read-github
Fetches the latest commit information from a GitHub repository using a personal access token.Request
Headers
Bearer token for authentication:
Bearer <your-supabase-jwt-token>Must be
application/jsonBody Parameters
The workflow element ID used to load GitHub configuration from the database.
GitHub personal access token. If not provided, will be loaded from agent configuration based on
elementId.Repository in the format
owner/repo (e.g., facebook/react). If not provided, will be loaded from agent configuration.Branch name to fetch commits from. Defaults to
main.Response
Indicates whether the GitHub data was fetched successfully
The repository name in
owner/repo formatThe branch that was queried
Human-readable summary of the commit information
GitHub API
The function uses GitHub REST API v3:Required Headers
Authorization: token {accessToken}Accept: application/vnd.github.v3+jsonUser-Agent: Workflow-Agent
Configuration Loading
When parameters are not provided directly:- Queries
agent_configstable forgithub_readerconfiguration - Filters by
user_idandelement_id - Extracts
accessToken,repository, andbranch - Uses configuration values as defaults
Examples
Request with Element ID
Request with Full Parameters
Success Response
Empty Response (No Commits)
Error Response
Error Codes
| Status Code | Error Message | Description |
|---|---|---|
| 400 | Element ID is required | Missing elementId parameter |
| 400 | Repository name is required | Missing repository parameter |
| 400 | GitHub access token not found in configuration | No access token in config |
| 500 | Failed to retrieve GitHub configuration | Database error loading configuration |
| 500 | Failed to fetch GitHub data | GitHub API error (invalid token, repo not found, etc.) |
GitHub Access Token
Required Permissions
The personal access token needs:reposcope for private repositoriespublic_reposcope for public repositories only
Token Security
- Tokens are stored in
agent_configstable - Not encrypted (consider encrypting in production)
- Associated with specific
user_idandelement_id
Output Storage
Successful fetches are stored inagent_outputs table:
Workflow Integration
When used in workflows, the output is available for subsequent agents:GitHub API Rate Limits
- Authenticated: 5,000 requests per hour
- Unauthenticated: 60 requests per hour
- Rate limit headers are not checked by this function
Commit Limit
Currently hardcoded to fetch 1 commit (per_page=1). To modify:
- Change the
per_pageparameter in the GitHub API URL - The response will include more commits in the array
Notes
- Only fetches the latest commit by default
- The
branchparameter can be any valid branch name or tag - Repository must be accessible with the provided access token
- Private repositories require appropriate token permissions
- The function does not support pagination for multiple commits
- Configuration is stored with
agent_type: 'github_reader' - Access tokens should use GitHub’s fine-grained permissions when possible