Docs
BlogHomeStart building

GitHub API

Two-way GitHub sync for your project via a fine-grained personal access token.


Note

For a step-by-step, user-facing walkthrough, see the GitHub integration guide. The endpoints below are the raw API reference.

Connect a GitHub repository to your project for two-way sync. After connecting, Totalum auto-pushes to develop after every completed prompt and pushes to main when you publish (deploy). All endpoints require the api-key header and are free.

#Connect GitHub Repository

POST/api/v1/vcaas/projects/:projectId/github/connectFree

Connect a GitHub repository to your project using a Fine-grained Personal Access Token (PAT). This validates permissions, stores credentials, sets up branches (develop and main), and performs the initial sync. After connecting, Totalum automatically pushes to develop after every completed prompt, and pushes to main when you publish (deploy) the project.

Create a GitHub token
  1. Go to https://github.com/settings/personal-access-tokens.
  2. Click "Generate new token".
  3. Select "Only select repositories" and choose your repo.
  4. Under "Repository permissions", set: Contents: Read and Write; Pull requests: Read and Write; Administration: Read and Write.
  5. Click "Generate token" and copy it (it starts with github_pat_).
Branch setup

For empty repositories, Totalum creates the develop and main branches automatically. For non-empty repositories, both branches must already exist.

syncDirection (controls behavior when the repo has existing content with no common git history):

  • "totalum_to_github" (default) — pushes the Totalum project code to GitHub, replacing the repository content on both develop and main branches.
  • "github_to_totalum" — pulls the GitHub repository code into Totalum, replacing the current project code. If the develop branch doesn't exist on GitHub, it is created from main.

Path parameters

ParameterTypeDescription
projectIdstringThe project ID

Body parameters

FieldTypeRequiredDescription
tokenstringYesGitHub Fine-grained Personal Access Token
repositoryFullNamestringYesFull repository name (e.g. "owner/repo")
syncDirectionstringNo"totalum_to_github" (default) or "github_to_totalum". Controls behavior when repo has existing content with no common history

Response fields

FieldTypeDescription
data.connectedbooleantrue if connection was successful
data.repositoryFullNamestringThe connected repository
data.syncActionstring"push_new", "push", "pull", "merge_and_push", or "already_synced"
data.repoHasContentbooleanWhether the repo had existing content
data.requiresRebuildbooleanWhether a rebuild was triggered. If true, poll GET /github/pull-status until status is "success" or "error"

Example request

bash
curl -X POST \
  -H "api-key: tlm_sk_your_key" \
  -H "Content-Type: application/json" \
  -d '{"token":"github_pat_xxx","repositoryFullName":"myuser/my-repo","syncDirection":"totalum_to_github"}' \
  https://api-accounts.totalum.app/api/v1/vcaas/projects/my-app/github/connect
Success · 200 OK
json
{
  "errors": null,
  "data": {
    "connected": true,
    "repositoryFullName": "myuser/my-repo",
    "syncAction": "push_new",
    "repoHasContent": false,
    "requiresRebuild": false
  }
}
Error · 400
json
{
  "errors": {
    "errorCode": "MISSING_GITHUB_FIELDS",
    "errorMessage": "token and repositoryFullName are required"
  },
  "data": null
}

Error codes

CodeHTTPMeaning
MISSING_GITHUB_FIELDS400token and repositoryFullName are required
INVALID_SYNC_DIRECTION400syncDirection must be "totalum_to_github" or "github_to_totalum"
GITHUB_VALIDATION_FAILED400Token invalid, missing permissions, or repo not found
GITHUB_SECRET_STORE_ERROR400Failed to store GitHub credentials
GITHUB_SYNC_FAILED400Initial sync with GitHub failed
AGENT_RUNNING409Cannot connect while agent is running
SERVER_NOT_READY409Server auto-starting, poll until Active then retry

#Disconnect GitHub

DELETE/api/v1/vcaas/projects/:projectId/github/connectFree

Remove the GitHub integration from your project. Deletes the stored token and repository credentials. Code already in your project is not affected.

Path parameters

ParameterTypeDescription
projectIdstringThe project ID

Response fields

FieldTypeDescription
data.successbooleantrue on success
data.messagestringConfirmation message

Example request

bash
curl -X DELETE -H "api-key: tlm_sk_your_key" \
  https://api-accounts.totalum.app/api/v1/vcaas/projects/my-app/github/connect
Success · 200 OK
json
{ "errors": null, "data": { "success": true, "message": "GitHub disconnected successfully" } }
Error · 400
json
{
  "errors": {
    "errorCode": "GITHUB_NOT_CONNECTED",
    "errorMessage": "GitHub is not connected to this project"
  },
  "data": null
}

Error codes

CodeHTTPMeaning
GITHUB_NOT_CONNECTED400GitHub is not connected to this project

#Get GitHub Status

GET/api/v1/vcaas/projects/:projectId/github/statusFree

Check whether GitHub is connected and the token is still valid.

Path parameters

ParameterTypeDescription
projectIdstringThe project ID

Response fields

FieldTypeDescription
data.connectedbooleanWhether GitHub is connected
data.tokenValidbooleanWhether the PAT token is still valid
data.tokenExpiredbooleanTrue when the last linked PAT was detected as expired/revoked. Sticky until the user reconnects. Use this to prompt the user to reconnect
data.repositoryFullNamestringConnected repository, or last-known repo when tokenExpired is true
data.developBranchstring"develop" (only if connected)
data.productionBranchstring"main" (only if connected)

Example request

bash
curl -H "api-key: tlm_sk_your_key" \
  https://api-accounts.totalum.app/api/v1/vcaas/projects/my-app/github/status
Success · 200 OK
json
{
  "errors": null,
  "data": {
    "connected": true,
    "tokenValid": true,
    "tokenExpired": false,
    "repositoryFullName": "myuser/my-repo",
    "developBranch": "develop",
    "productionBranch": "main"
  }
}

#Pull from GitHub

POST/api/v1/vcaas/projects/:projectId/github/pullFree

Pull the latest changes from the GitHub develop branch into your project. If files changed, the server rebuilds automatically in the background. Poll the pull status endpoint until complete. This is an async operation.

Path parameters

ParameterTypeDescription
projectIdstringThe project ID

Response fields

FieldTypeDescription
data.statusstring"pulling" (async rebuild started) or "no_changes"
data.messagestringStatus message
data.filesUpdatednumberNumber of files updated

Example request

bash
curl -X POST -H "api-key: tlm_sk_your_key" \
  https://api-accounts.totalum.app/api/v1/vcaas/projects/my-app/github/pull
Success · 200 OK
json
{
  "errors": null,
  "data": {
    "status": "pulling",
    "message": "Pull started successfully",
    "filesUpdated": 5
  }
}
Error · 400
json
{
  "errors": {
    "errorCode": "GITHUB_NOT_CONNECTED",
    "errorMessage": "GitHub is not connected (connect first)"
  },
  "data": null
}

Error codes

CodeHTTPMeaning
GITHUB_NOT_CONNECTED400GitHub is not connected (connect first)
GITHUB_PULL_ERROR400Failed to pull changes
AGENT_RUNNING409Cannot pull while agent is running
SERVER_NOT_READY409Server auto-starting, poll until Active

#Get Pull Status

GET/api/v1/vcaas/projects/:projectId/github/pull-statusFree

Poll this endpoint after calling Pull from GitHub, OR after a Connect GitHub call that returned requiresRebuild: true (e.g. github_to_totalum direction). Returns the current rebuild status. Auto-completes after 5 minutes.

Path parameters

ParameterTypeDescription
projectIdstringThe project ID

Response fields

FieldTypeDescription
data.statusstring"pulling", "success", "error", or null (no pull)
data.createdAtstringISO 8601 date when the pull started

Example request

bash
curl -H "api-key: tlm_sk_your_key" \
  https://api-accounts.totalum.app/api/v1/vcaas/projects/my-app/github/pull-status
Success · 200 OK
json
{ "errors": null, "data": { "status": "success", "createdAt": "2026-03-17T10:00:00.000Z" } }

#Download Environment Variables

GET/api/v1/vcaas/projects/:projectId/github/envFree

Get the project's environment variables as .env file content for both development and production environments. Use this to set up a local development environment or configure production deployments.

Path parameters

ParameterTypeDescription
projectIdstringThe project ID

Response fields

FieldTypeDescription
data.envDevstring.env file content for development (KEY=VALUE format, one per line)
data.envProdstring.env file content for production (KEY=VALUE format, one per line)

Example request

bash
curl -H "api-key: tlm_sk_your_key" \
  https://api-accounts.totalum.app/api/v1/vcaas/projects/my-app/github/env
Success · 200 OK
json
{
  "errors": null,
  "data": {
    "envDev": "# Totalum Configuration\nTOTALUM_API_KEY=tlm_sk_xxx\nBETTER_AUTH_SECRET=xxxx\nNODE_ENV=development\nNEXT_PUBLIC_APP_URL=http://localhost:3000\n\n# User-defined environment variables\n...",
    "envProd": "# Totalum Configuration\nTOTALUM_API_KEY=tlm_sk_xxx\nBETTER_AUTH_SECRET=xxxx\nNODE_ENV=production\nNEXT_PUBLIC_APP_URL=https://my-app.totalum-project.com\n\n# User-defined environment variables\n..."
  }
}
Error · 400
json
{
  "errors": {
    "errorCode": "ENV_DOWNLOAD_ERROR",
    "errorMessage": "Failed to get environment variables"
  },
  "data": null
}

Error codes

CodeHTTPMeaning
ENV_DOWNLOAD_ERROR400Failed to get environment variables