# apps/web/src/api
dir: apps/web/src/api

index: apps/web/src/api/.pi-map.index.md

## role
Provides typed HTTP API client functions for all backend operations across the web frontend, organized by domain entity with centralized Axios configuration.
## files
- client.ts | Configures an Axios HTTP client with authentication redirect handling and automatic retry logic for transient network/server errors | exp: apiClient, shouldSkipAuthRedirect | dep: axios
- config-profiles.ts | Defines TypeScript interfaces and API client functions for managing configuration profiles with environment variables, mounts, git mounts, files, and profile inheritance. | exp: ConfigProfile, ConfigProfileMount, GitMountMapping, GitMount, ConfigProfileInclude, ResolvedProfile, ResolvedMount, CreateConfigProfileRequest, UpdateConfigProfileRequest, UpdateIncludesRequest, listConfigProfiles, getConfigProfile, createConfigProfile, updateConfigProfile, deleteConfigProfile, updateProfileIncludes, previewConfigProfile, resolveDefaultProfile, ValidateGitUrlResponse, validateGitUrl | dep: ./client, apiClient
- dashboard.ts | Defines a TypeScript type and API function to fetch dashboard summary data | exp: DashboardSummary, getDashboardSummary | dep: ./client
- events.ts | Provides utilities for connecting to and checking the status of a server-sent events stream endpoint | exp: func:createEventSource() → EventSource, func:probeEventStreamStatus() → Promise<number | null>, call:setTimeout, call:controller.abort, call:fetch, call:clearTimeout
- git-repositories.ts | Defines TypeScript interfaces and API client functions for Git repository management, branch operations, and version control actions (commit, push, pull, merge, etc.) | exp: GitRepository, GitRepositoryCreate, URLParseResult, Branch, BranchesResponse, CommitHistoryEntry, CommitHistoryResponse, CommitDetail, GitStatus, CommitResponse, MergeResponse, func:parseGitUrl(url: string) → Promise<URLParseResult>, call:apiClient.post, func:listRepositories(projectId: string) → Promise<GitRepository[]>, func:listAllUserRepositories() → Promise<GitRepository[]>, func:createRepository(projectId: string, data: GitRepositoryCreate) → Promise<GitRepository>, call:apiClient.post, func:createExternalRepository(data: GitRepositoryCreate) → Promise<GitRepository>, func:deleteRepository(projectId: string, repoId: string) → Promise<void>, call:apiClient.delete, func:updateRepositorySshKey(projectId: string, repoId: string, sshKeyId: string | null) → Promise<GitRepository>, call:apiClient.patch, func:listRepositoryBranches(projectId: string, repoId: string) → Promise<BranchesResponse>, call:apiClient.get, func:getRepositoryHistory(projectId: string, repoId: string, branch: string, limit: number) → Promise<CommitHistoryResponse>, call:searchParams.set, call:String, call:searchParams.toString, call:apiClient.get, func:getCommitDetail(projectId: string, repoId: string, commitHash: string) → Promise<CommitDetail>, call:apiClient.get, func:getRepositoryStatus(projectId: string, repoId: string) → Promise<GitStatus>, call:apiClient.get, func:createBranch(projectId: string, repoId: string, name: string, baseBranch: string) → Promise<{ message: string; branch: string }>, call:apiClient.post, func:deleteBranch(projectId: string, repoId: string, branchName: string, force: boolean) → Promise<{ message: string }>, call:apiClient.delete, func:checkoutBranch(projectId: string, repoId: string, branch: string) → Promise<{ message: string; branch: string }>, call:apiClient.post, func:commitChanges(projectId: string, repoId: string, message: string, files: string[]) → Promise<CommitResponse>, call:apiClient.post, func:fetchRepository(projectId: string, repoId: string) → Promise<{ message: string }>, call:apiClient.post, func:pullRepository(projectId: string, repoId: string, branch: string) → Promise<{ message: string }>, call:apiClient.post, func:pushRepository(projectId: string, repoId: string, branch: string) → Promise<{ message: string }>, call:apiClient.post, func:mergeBranches(projectId: string, repoId: string, sourceBranch: string, targetBranch: string, message: string) → Promise<MergeResponse>, call:apiClient.post | dep: ./client, apiClient
- notifications.ts | Defines TypeScript interfaces and API functions for fetching, reading, dismissing, and clearing user notifications. | exp: NotificationItem, NotificationListResponse, UnreadCountResponse, MarkAllReadResponse, ClearAllResponse, getNotifications, getUnreadCount, markNotificationRead, markAllNotificationsRead, dismissNotification, clearAllNotifications | dep: ./client, apiClient
- profile.ts | Provides API functions to fetch, update, and upload an avatar for the current user's profile. | exp: UserProfile, ProfileUpdatePayload, getProfile, updateProfile, uploadAvatar | dep: ./client, ../types, apiClient, SessionUser
- projects.ts | Defines API client functions for CRUD operations on projects and setting default SSH keys. | exp: ProjectCreateInput, ProjectUpdateInput, SetDefaultSSHKeyInput, listProjects, createProject, updateProject, deleteProject, setDefaultSSHKey | dep: ./client, ../types, apiClient, Project, ProjectWithRepos
- sessions.ts | Provides API client functions for managing tool instances and user sessions in a development environment platform. | exp: ToolInstance, Session, InstanceHealth, func:listInstances(projectId: string, repoId: string) → Promise<ToolInstance[]>, call:apiClient.get, func:createInstance(projectId: string, repoId: string, toolTypeId: string, displayName: string, workspaceId: string, configProfileId: string, sshKeyIds: string[]) → Promise<ToolInstance>, call:apiClient.post, func:startInstance(projectId: string, repoId: string, instanceId: string, configProfileId: string, sshKeyIds: string[], retries) → Promise<{ status: string; url?: string }>, call:apiClient.post, call:setTimeout, call:startInstance, raise:error, func:stopInstance(projectId: string, repoId: string, instanceId: string) → Promise<{ status: string }>, call:apiClient.post, func:restartInstance(projectId: string, repoId: string, instanceId: string, configProfileId: string, sshKeyIds: string[], retries) → Promise<{ status: string; url?: string }>, call:apiClient.post, call:setTimeout, call:restartInstance, raise:error, func:deleteInstance(projectId: string, repoId: string, instanceId: string, force: boolean) → Promise<void>, call:apiClient.delete, func:getInstance(projectId: string, repoId: string, instanceId: string) → Promise<ToolInstance>, call:apiClient.get, func:getUserSessions() → Promise<Session[]>, call:apiClient.get, func:checkInstanceHealth(projectId: string, repoId: string, instanceId: string) → Promise<InstanceHealth>, call:apiClient.get, func:renameInstance(projectId: string, repoId: string, instanceId: string, displayName: string) → Promise<{ id: string; name: string; display_name: string }>, call:apiClient.patch, func:recreateInstanceTunnel(projectId: string, repoId: string, instanceId: string) → Promise<{ status: string; url?: string }>, call:apiClient.post | dep: axios, ./client
- settings.ts | Defines user configuration types and API functions for fetching and updating user settings via HTTP requests. | exp: UserConfig, UserConfigUpdate, getUserConfig, updateUserConfig | dep: ./client
- ssh-keys.ts | Provides a TypeScript API client module for SSH key management operations including listing, creating, deleting, and cryptographic signing/verification. | exp: SSHKey, SSHKeyCreate, SignPayloadRequest, SignatureResponse, VerifySignatureRequest, VerifySignatureResponse, func:listSSHKeys() → Promise<SSHKey[]>, func:createSSHKey(data: SSHKeyCreate) → Promise<SSHKey>, func:deleteSSHKey(keyId: string) → Promise<void>, call:apiClient.delete, func:signPayload(keyId: string, data: SignPayloadRequest) → Promise<SignatureResponse>, func:verifySignature(keyId: string, data: VerifySignatureRequest) → Promise<VerifySignatureResponse> | dep: ./client, apiClient
- terminal.ts | Provides a TypeScript API client for managing terminal sessions on remote instances via HTTP requests. | exp: TerminalSession, TerminalSessionListResponse, TerminalSessionCreateRequest, TerminalSessionCreateResponse, func:listTerminalSessions(instanceId: string) → Promise<TerminalSession[]>, call:apiClient.get, func:createTerminalSession(instanceId: string, name: string) → Promise<TerminalSessionCreateResponse>, call:apiClient.post, func:closeTerminalSession(instanceId: string, sessionId: string) → Promise<{ status: string; session_id: string }>, call:apiClient.delete, func:resetTerminalSession(instanceId: string, sessionId: string) → Promise<{ id: string; name: string; status: string }>, call:apiClient.post, func:renameTerminalSession(instanceId: string, sessionId: string, name: string) → Promise<{ id: string; name: string }>, call:apiClient.post | dep: ./client, apiClient
- tool-definitions.ts | Defines TypeScript interfaces and API client functions for CRUD operations and compilation of tool definitions in a Docker-based tool management system. | exp: ToolDefinitionManifest, CreateToolDefinitionRequest, UpdateToolDefinitionRequest, CompileResult, listToolDefinitions, getToolDefinition, createToolDefinition, updateToolDefinition, deleteToolDefinition, compileToolDefinition | dep: ./client
- tool-types.test.ts | Unit tests for tool type API CRUD operations including listing, creating, validating, updating, and deleting tool types with dockerfile and compose definitions | dep: vitest, ../api/tool-types, ../api/client
- tool-types.ts | Defines TypeScript interfaces and API client functions for CRUD operations on tool types in a containerized deployment system. | exp: ReadinessProbe, ToolType, CreateToolTypeRequest, UpdateToolTypeRequest, listToolTypes, getToolType, createToolType, updateToolType, deleteToolType, validateToolType | dep: ./client, apiClient
- workspace-files.ts | Provides an API client for listing, reading, and saving workspace files. | exp: FileEntry, func:listWorkspaceFiles(workspaceId: string, path: string) → Promise<FileEntry[]>, func:getWorkspaceFileContent(workspaceId: string, path: string) → Promise<string>, func:saveWorkspaceFile(workspaceId: string, path: string, content: string, commitMessage: string) → Promise<void>, call:apiClient.post | dep: ./client, apiClient
- workspace-git.ts | Provides a typed API client for workspace git operations including status, branches, commits, push/pull/fetch, checkout, and history. | exp: GitStatus, Commit, func:getGitStatus(workspaceId: string) → Promise<GitStatus>, func:getGitBranches(workspaceId: string) → Promise<{ branches: string[]; current_branch: string }>, func:gitCommit(workspaceId: string, message: string) → Promise<void>, call:apiClient.post, func:gitPush(workspaceId: string) → Promise<void>, call:apiClient.post, func:gitPull(workspaceId: string) → Promise<void>, call:apiClient.post, func:gitFetch(workspaceId: string) → Promise<void>, call:apiClient.post, func:gitCheckout(workspaceId: string, branch: string) → Promise<void>, call:apiClient.post, func:getGitHistory(workspaceId: string, path: string, limit: number) → Promise<Commit[]> | dep: ./client
- workspace-instances.ts | Provides API client functions for listing and creating workspace tool instances. | exp: func:listWorkspaceInstances(workspaceId: string) → Promise<ToolInstance[]>, func:createWorkspaceInstance(workspaceId: string, toolTypeId: string, displayName: string, configProfileId: string) → Promise<ToolInstance> | dep: ./client, ./sessions, apiClient, ToolInstance
- workspaces.ts | Provides an API client for CRUD and sync operations on workspaces in a project/repository hierarchy. | exp: func:listWorkspaces(projectId: string, repoId: string) → Promise<Workspace[]>, call:workspaceUrl, func:listAllWorkspaces() → Promise<Workspace[]>, func:createWorkspace(projectId: string, repoId: string, data: CreateWorkspaceRequest) → Promise<Workspace>, call:workspaceUrl, func:createWorkspaceTopLevel(data: CreateWorkspaceRequest & { repo_id: string }) → Promise<Workspace>, func:getWorkspace(projectId: string, repoId: string, workspaceId: string) → Promise<Workspace>, call:workspaceUrl, func:updateWorkspace(projectId: string, repoId: string, workspaceId: string, data: Partial<CreateWorkspaceRequest>) → Promise<Workspace>, call:workspaceUrl, func:deleteWorkspace(workspaceId: string, force) → Promise<{ status: string }>, func:syncWorkspace(projectId: string, repoId: string, workspaceId: string) → Promise<SyncResult>, call:workspaceUrl | dep: ./client, ../types/workspace, apiClient, Workspace, CreateWorkspaceRequest, SyncResult
## arch
Modular facade pattern with domain-segregated modules (one per entity), shared base client with interceptors, consistent TypeScript interfaces for request/response types, and thin wrappers over RESTful endpoints.
## tags
call:api, tool, client.post, create, git, profile, get, client
## symbols
- createEventSource
- probeEventStreamStatus
- parseGitUrl
- listRepositories
- listAllUserRepositories
- createRepository
- createExternalRepository
- deleteRepository
## workflows
- change api behavior
  read: client.ts, config-profiles.ts, dashboard.ts
- update api tests
  read: tool-types.test.ts
- change api CLI
  read: client.ts
- change api config
  read: config-profiles.ts
## dirty
-
