API Documentation
Backend API Endpoints
The application communicates with a backend API for user management, organizations, and billing:
Authentication
POST /authentication/password-login- User loginPOST /authentication/verify-user- Verify user emailPATCH /authentication/recovery-password- Recover user passwordPATCH /user/update/{userId}- Update user profile
Organizations
GET /organization/user- Get user organizationsPOST /organization- Create organizationPATCH /organization/member/{org_id}- Add memberPATCH /organization/update-role/{org_id}- Update member role
Projects
GET /project/orgs/{orgId}- Get organization projectsPOST /project/create- Create projectGET /project/{projectId}- Get project detailsPATCH /project/{projectId}- Update projectDELETE /project/{projectId}- Delete project
Note:
/src/redux/features/project/project-api.tsis responsible for handling project-related API calls.
Subscriptions
GET /package- Get available packagesPOST /subscription- Create subscriptionGET /subscription/user/{userId}- Get user subscription
Note:
/src/redux/features/project/package-api-slice.tsis responsible for handling project-related API calls.
GitHub API Integration
Direct GitHub API integration through Octokit:
Content API and Commit API
The application uses two main API slices for GitHub operations:
Content API - Repository data retrieval and management:
GET /user/installations- Get GitHub App installations with token authenticationGET /app/installations/{installation_id}- Get specific installation detailsGET /user/installations/{installation_id}/repositories- Get accessible repositories for installationGET /repos/{owner}/{repo}/git/trees/{tree_sha}- Get repository file tree (recursive support)GET /repos/{owner}/{repo}/contents/{path}- Get file content with frontmatter parsingGET /repos/{owner}/{repo}/branches- Get repository branches (up to 100 per page)GET /repos/{owner}/{repo}- Get single repository detailsGET /users/{username}/repos- Get user repositoriesGET /repos/{owner}/{repo}/deployments- Get deployment informationGET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses- Get deployment status
Commit API - Git operations and file modifications:
GET /repos/{owner}/{repo}/commits- Get commit history with path filteringGET /repos/{owner}/{repo}/git/ref/{ref}- Get branch reference detailsGET /repos/{owner}/{repo}/branches/{branch}- Get specific branch informationGET /user- Get authenticated user details for commit attributionPOST /repos/{owner}/{repo}/git/blobs- Create file blob with base64 encoding supportPOST /repos/{owner}/{repo}/git/trees- Create tree object with base tree supportPOST /repos/{owner}/{repo}/git/commits- Create commit with author/committer detailsPATCH /repos/{owner}/{repo}/git/refs/{ref}- Update branch reference (force push support)
Special Operations & Advanced Features:
Complex Mutations:
updateFilesmutation - Complete Git workflow (blob creation β tree construction β commit β branch update)- Supports multiple file operations in a single commit
- Automatic base64 encoding for media files
- Co-author attribution with
Co-authored-bytrailer - Optimistic UI updates with cache invalidation
renameFoldermutation - Atomic folder renaming operations- Creates new tree structure with renamed paths
- Preserves file history and maintains Git integrity
- Automatic cache updates for affected file trees
Content Processing:
- Frontmatter Detection: Automatic detection of YAML (
---), TOML (+++,---toml) formats - Content Parsing: Intelligent parsing with
fmDetectorandparseContentJsonutilities - Media Handling: Base64 encoding detection via
checkMediafunction - Tree Transformation: Directory structure optimization with
pathToDirutility
Cache Management:
- RTK Query Integration: Automatic cache invalidation and updates
- Optimistic Updates: Immediate UI feedback before server confirmation
- Selective Updates: Targeted cache updates based on file path patterns
Legacy Support & Migration:
- Automatic Migration:
.zeonCmsβ.sitepinsfolder conversion - Configuration Detection: Automatic site config loading and parsing
- Backward Compatibility: Support for legacy folder structures
Note: Ensure that the GitHub App has the necessary permissions to access the repository.
See the GitHub REST API documentationΒ for more details.
React Hooks & API Usage
Content API Hooks:
// Repository and installation management
const { data: installations } = useGetInstallationsQuery();
const { data: installation } = useGetInstallationQuery({ installation_id });
const { data: repos } = useGetReposByInstallationIdQuery({ installation_id });
// Repository content operations
const { data: branches } = useGetBranchesQuery({ owner, repo });
const { data: repository } = useGetSingleRepoQuery({ owner, repo });
const { data: userRepos } = useGetUserReposQuery({ username });
const { data: trees } = useGetTreesQuery({
owner,
repo,
tree_sha,
recursive: "1",
});
// File content and configuration
const { data: content } = useGetContentQuery({
owner,
repo,
path,
ref,
parser: true,
});
const { data: config } = useGetSiteConfigQuery({ owner, repo, path, ref });
const { data: image } = useGetImageQuery({ owner, repo, path, ref });
// Deployment monitoring
const { data: deployStatus } = useGetDeployStatusQuery({ owner, repo });Commit API Hooks:
// Git operations
const { data: commits } = useGetCommitQuery({ owner, repo, sha, path });
const [updateFiles, { isLoading, error }] = useUpdateFilesMutation();
// Example usage
await updateFiles({
owner: "username",
repo: "repository",
tree: "main",
files: [{ path: "content/post.md", content: "# Hello World" }],
message: "Add new post",
description: "Created via Sitepins CMS",
});