Repositories
Repository endpoints cover lifecycle operations: creating new storage, reading metadata, and coordinating upstream mirrors.Create repository POST
Creates a new repository in your organization, with optional links to an external mirror.| Parameter | Type | Description |
|---|---|---|
default_branch | Optional | Default branch name for the Code Storage repository (defaults to “main”) |
base_repo | Optional | Configuration for syncing with an external repository (e.g., GitHub) |
- Requires the
repo:writescope
401 Unauthorized- Invalid JWT or missingrepo:writescope409 Conflict- Repository already exists
Pull from upstream POST
Triggers a sync from the configured upstream repository (e.g., GitHub) for repositories with GitHub sync enabled.| Parameter | Type | Description |
|---|---|---|
ref | Optional | Specific ref to sync from upstream |
after | Optional | Only sync commits after this SHA |
- The JWT must include the repository in the
repoclaim - Requires
git:writescope
- Returns
202 Accepted- sync is initiated asynchronously - Only works for repositories that have an upstream configured via
base_repoduring creation - See GitHub Sync guide for setup details
- The SDK provides
repo.pullUpstream()for this operation
403 Forbidden- Invalid JWT or missinggit:writescope404 Not Found- Repository doesn’t exist400 Bad Request- Repository has no upstream configured500 Internal Server Error- Sync service unavailable
Branches
Branch endpoints help you explore parallel lines of work and compare them against the default branch.List branches GET
Retrieve branches in a repository with pagination.| Parameter | Type | Description |
|---|---|---|
cursor | Optional | Pagination cursor from previous response |
limit | Optional | Maximum number of branches to return (default: 20) |
- The JWT must include the repository in the
repoclaim - Requires
git:readscope
- The cursor field is an opaque pagination token for each branch
- The next_cursor value should be used for fetching the next page
- Branches are ordered by creation time
401 Unauthorized- Invalid JWT or missinggit:readscope
Get branch diff GET
Compares a feature branch to its base so you can review every change before merging.| Parameter | Type | Description |
|---|---|---|
branch | Required | The branch name to get the diff for |
base | Optional | Base branch to compare against (defaults to repository’s default branch) |
ephemeral | Optional | When true, resolves the branch ref under refs/namespaces/ephemeral/refs/heads/<branch> |
ephemeral_base | Optional | When true, resolves the base ref under refs/namespaces/ephemeral/refs/heads/<base> |
- The JWT must include the repository in the
repoclaim - Requires
git:readscope
- Shows all changes in the branch compared to the base branch
- If base is not specified, compares against the repository’s default branch (usually “main”)
- Uses three-dot diff notation internally (base…branch) to show changes since branch diverged
- Large files and binary files are included in
filtered_fileswithout diff content - Useful for reviewing all changes in a feature branch before merging
- For more about ephemeral branches, see the Ephemeral branches guide
404 Not Found- Branch or base branch doesn’t exist401 Unauthorized- Invalid JWT or missinggit:readscope400 Bad Request- Missing branch parameter or invalidephemeral/ephemeral_basevalue
Commits
Commit endpoints surface history so you can audit changes, inspect metadata, and pull down diffs when you need to troubleshoot a release.List commits GET
Retrieve commit history for a branch with pagination.| Parameter | Type | Description |
|---|---|---|
branch | Optional | Branch name (defaults to repository’s default branch) |
cursor | Optional | Pagination cursor from previous response |
limit | Optional | Maximum number of commits to return (default: 20) |
- The JWT must include the repository in the
repoclaim - Requires
git:readscope
- The cursor represents the number of commits to skip
- Commits are ordered by commit date (newest first)
- If branch is not specified, uses the repository’s default branch
404 Not Found- Branch doesn’t exist (includes branch name in error)401 Unauthorized- Invalid JWT or missinggit:readscope400 Bad Request- Invalid cursor format
Get commit diff GET
Streams the full diff for a commit to help you review file-level changes.| Parameter | Type | Description |
|---|---|---|
sha | Required | The full commit SHA to get the diff for |
baseSha | Optional | Base commit SHA to compare against. If not specified, compares against the commit’s parent(s) |
- The JWT must include the repository in the
repoclaim - Requires
git:readscope
- The diff includes both file-level changes and line-by-line diffs
- When
baseShais not provided, the diff shows changes from the commit’s parent(s) - When
baseShais provided, the diff shows changes between the base commit and the target commit (useful for comparing specific commits) - Large files (>500KB) or files with too many changes (>2000 lines) are included in
filtered_fileswithout diff content - Binary files and lock files are automatically filtered
- The
is_eoffield indicates whether the file ends with a newline - Git status codes:
A(added),M(modified),D(deleted),R(renamed),C(copied),T(type changed)
404 Not Found- Commit doesn’t exist401 Unauthorized- Invalid JWT or missinggit:readscope400 Bad Request- Missing or invalid SHA parameter
Create commit POST
Create a commit by streaming file contents as newline-delimited JSON.| Parameter | Type | Description |
|---|---|---|
target_branch | Required | Branch name (for example main) |
commit_message | Required | The commit message |
author | Required | Object with name, email, and optional ISO 8601 date |
files | Required | Array of file operations (see below) |
expected_head_sha | Optional | Commit SHA that must match the branch tip before writing; omit to fast-forward unconditionally |
base_branch | Optional | Source branch to copy when target_branch does not exist. If you also provide expected_head_sha, it must match the source branch head; otherwise the branch is created from the latest base branch commit |
committer | Optional | Object with name, email, and optional ISO 8601 date |
path(required): Repository-relative path; leading slashes are strippedoperation:upsert(default) to add or replace content,deleteto remove a filecontent_id(required): Identifier that blob chunks referencemode(optional): File mode such as100644or100755- For
deleteoperations, omit blob chunks—only the metadata entry is required
- Each line after the metadata must contain a
blob_chunkobject content_idties the chunk to a file operationdatais base64 encoded; decoded chunks must be 4 MiB or smaller- Use multiple
blob_chunkmessages per file for streaming; mark the last chunk with"eof": true - Empty files should send an EOF chunk with an empty base64 string
- The JWT must include the repository in the
repoclaim - Requires
git:writescope
- Successful requests return
201 Created; validation errors return4xxcodes with error details - Use the SDK’s
repo.createCommit()helper for streaming, chunking, and authentication automatically - The
target_branchmust already exist unless you includebase_branch, in which case the service creates the target branch from that source branch when it is missing - If you passed an
expected_head_sha, the service verifies it matches the source branch head before creating the new branch - Repositories with no refs can still omit
expected_head_shato seed their default branch - Pair
expected_head_shawith a commit SHA to enforce fast-forward semantics during migrations or CI jobs result.old_shais always a 40-character hex string reflecting the previous tip; it is0000000000000000000000000000000000000000when the target branch did not previously exist
401 Unauthorized- Invalid JWT or missinggit:writescope400 Bad Request- Invalid request format, missing required fields, or blob chunk validation errors409 Conflict- Expected head SHA doesn’t match current branch tip404 Not Found- Base branch doesn’t exist (when creating new target branch)
Create commit from diff POST
Create a commit by streaming a Git patch instead of individual file blobs.diff_chunk entries.
| Parameter | Type | Description |
|---|---|---|
target_branch | Required | Destination branch |
commit_message | Required | Commit message |
author | Required | Object with name, email, and optional ISO 8601 timestamp |
expected_head_sha | Optional | Guard ensuring the branch tip matches before applying the patch |
base_branch | Optional | Seed when the target branch does not exist yet |
committer | Optional | Object with name, email, and optional ISO 8601 timestamp |
ephemeral | Optional | Same semantics as commit-pack |
ephemeral_base | Optional | Same semantics as commit-pack |
diff_chunk.datacontains base64-encoded diff bytes; decoded payloads must be ≤ 4 MiB- Chunks are streamed sequentially; set
"eof": trueon the final chunk - The combined diff must be compatible with
git apply --cached --binary(include file headers, mode lines, and hunk metadata)
- The JWT must include the repository in the
repoclaim - Requires
git:writescope
result.successisfalsewhen the diff cannot be applied (for example, conflicts or empty diffs) andstatusreflects the mapped reason (conflict,precondition_failed, etc.)
404 Not Found- Branch doesn’t exist401 Unauthorized- Invalid JWT or missinggit:writescope400 Bad Request- Invalid request format or diff cannot be applied
Files
File endpoints give you flexible read access so you can power directory listings or stream individual blobs straight into your application.List files GET
Enumerates every file at the requested reference to help you build navigation or quick comparisons.| Parameter | Type | Description |
|---|---|---|
ref | Optional | Branch name or commit SHA. If not specified, uses the repository’s default branch |
- The JWT must include the repository in the
repoclaim - Requires
git:readscope
- Returns all files in the repository at the specified ref
- Directories are not included in the list, only files
- File paths are relative to the repository root
- If no
refis specified, the repository’s default branch is used (typicallymainormaster) paths: Array of file paths in the repositoryref: The resolved reference (branch name or commit SHA) that was used
404 Not Found- Reference doesn’t exist401 Unauthorized- Invalid JWT or missinggit:readscope
Get file content GET
Streams the bytes for a single file at any branch, tag, or commit.| Parameter | Type | Description |
|---|---|---|
path | Required | The path to the file to read |
ref | Optional | Branch name or commit SHA. If not specified, uses the repository’s default branch |
- The JWT must include the repository in the
repoclaim - Requires
git:readscope
- Returns raw file bytes as streaming response
- If no
refis specified, the repository’s default branch is used (typicallymain)
404 Not Found- File or reference doesn’t exist401 Unauthorized- Invalid JWT or missinggit:readscope400 Bad Request- Missingpathparameter or invalid file path