Create a commit by streaming file operations directly to the service. This is designed for automation, AI agents, and other workflows that need atomic Git writes without running a local Git process.
JWT claims
Required scopes: git:write
Requires per repo scope: Yes
curl --request POST \
--url https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-ndjson' \
--data '
"{\"metadata\":{\"target_branch\":\"main\",\"expected_head_sha\":\"d34db33fd34db33fd34db33fd34db33fd34db33f\",\"commit_message\":\"Update docs\",\"author\":{\"name\":\"Docs Bot\",\"email\":\"docs@example.com\"},\"files\":[{\"path\":\"docs/changelog.md\",\"operation\":\"upsert\",\"content_id\":\"blob-1\",\"mode\":\"100644\"},{\"path\":\"docs/legacy.txt\",\"operation\":\"delete\",\"content_id\":\"blob-2\"}]}}\n{\"blob_chunk\":{\"content_id\":\"blob-1\",\"data\":\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\",\"eof\":true}}\n{\"blob_chunk\":{\"content_id\":\"blob-2\",\"data\":\"\",\"eof\":true}}\n"
'import requests
url = "https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack"
payload = "{\"metadata\":{\"target_branch\":\"main\",\"expected_head_sha\":\"d34db33fd34db33fd34db33fd34db33fd34db33f\",\"commit_message\":\"Update docs\",\"author\":{\"name\":\"Docs Bot\",\"email\":\"docs@example.com\"},\"files\":[{\"path\":\"docs/changelog.md\",\"operation\":\"upsert\",\"content_id\":\"blob-1\",\"mode\":\"100644\"},{\"path\":\"docs/legacy.txt\",\"operation\":\"delete\",\"content_id\":\"blob-2\"}]}}
{\"blob_chunk\":{\"content_id\":\"blob-1\",\"data\":\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\",\"eof\":true}}
{\"blob_chunk\":{\"content_id\":\"blob-2\",\"data\":\"\",\"eof\":true}}
"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/x-ndjson"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/x-ndjson'},
body: JSON.stringify('{"metadata":{"target_branch":"main","expected_head_sha":"d34db33fd34db33fd34db33fd34db33fd34db33f","commit_message":"Update docs","author":{"name":"Docs Bot","email":"docs@example.com"},"files":[{"path":"docs/changelog.md","operation":"upsert","content_id":"blob-1","mode":"100644"},{"path":"docs/legacy.txt","operation":"delete","content_id":"blob-2"}]}}\n{"blob_chunk":{"content_id":"blob-1","data":"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==","eof":true}}\n{"blob_chunk":{"content_id":"blob-2","data":"","eof":true}}\n')
};
fetch('https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('{"metadata":{"target_branch":"main","expected_head_sha":"d34db33fd34db33fd34db33fd34db33fd34db33f","commit_message":"Update docs","author":{"name":"Docs Bot","email":"docs@example.com"},"files":[{"path":"docs/changelog.md","operation":"upsert","content_id":"blob-1","mode":"100644"},{"path":"docs/legacy.txt","operation":"delete","content_id":"blob-2"}]}}
{"blob_chunk":{"content_id":"blob-1","data":"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==","eof":true}}
{"blob_chunk":{"content_id":"blob-2","data":"","eof":true}}
'),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/x-ndjson"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack"
payload := strings.NewReader("\"{\\\"metadata\\\":{\\\"target_branch\\\":\\\"main\\\",\\\"expected_head_sha\\\":\\\"d34db33fd34db33fd34db33fd34db33fd34db33f\\\",\\\"commit_message\\\":\\\"Update docs\\\",\\\"author\\\":{\\\"name\\\":\\\"Docs Bot\\\",\\\"email\\\":\\\"docs@example.com\\\"},\\\"files\\\":[{\\\"path\\\":\\\"docs/changelog.md\\\",\\\"operation\\\":\\\"upsert\\\",\\\"content_id\\\":\\\"blob-1\\\",\\\"mode\\\":\\\"100644\\\"},{\\\"path\\\":\\\"docs/legacy.txt\\\",\\\"operation\\\":\\\"delete\\\",\\\"content_id\\\":\\\"blob-2\\\"}]}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-1\\\",\\\"data\\\":\\\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\\\",\\\"eof\\\":true}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-2\\\",\\\"data\\\":\\\"\\\",\\\"eof\\\":true}}\\n\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/x-ndjson")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/x-ndjson")
.body("\"{\\\"metadata\\\":{\\\"target_branch\\\":\\\"main\\\",\\\"expected_head_sha\\\":\\\"d34db33fd34db33fd34db33fd34db33fd34db33f\\\",\\\"commit_message\\\":\\\"Update docs\\\",\\\"author\\\":{\\\"name\\\":\\\"Docs Bot\\\",\\\"email\\\":\\\"docs@example.com\\\"},\\\"files\\\":[{\\\"path\\\":\\\"docs/changelog.md\\\",\\\"operation\\\":\\\"upsert\\\",\\\"content_id\\\":\\\"blob-1\\\",\\\"mode\\\":\\\"100644\\\"},{\\\"path\\\":\\\"docs/legacy.txt\\\",\\\"operation\\\":\\\"delete\\\",\\\"content_id\\\":\\\"blob-2\\\"}]}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-1\\\",\\\"data\\\":\\\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\\\",\\\"eof\\\":true}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-2\\\",\\\"data\\\":\\\"\\\",\\\"eof\\\":true}}\\n\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-ndjson'
request.body = "\"{\\\"metadata\\\":{\\\"target_branch\\\":\\\"main\\\",\\\"expected_head_sha\\\":\\\"d34db33fd34db33fd34db33fd34db33fd34db33f\\\",\\\"commit_message\\\":\\\"Update docs\\\",\\\"author\\\":{\\\"name\\\":\\\"Docs Bot\\\",\\\"email\\\":\\\"docs@example.com\\\"},\\\"files\\\":[{\\\"path\\\":\\\"docs/changelog.md\\\",\\\"operation\\\":\\\"upsert\\\",\\\"content_id\\\":\\\"blob-1\\\",\\\"mode\\\":\\\"100644\\\"},{\\\"path\\\":\\\"docs/legacy.txt\\\",\\\"operation\\\":\\\"delete\\\",\\\"content_id\\\":\\\"blob-2\\\"}]}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-1\\\",\\\"data\\\":\\\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\\\",\\\"eof\\\":true}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-2\\\",\\\"data\\\":\\\"\\\",\\\"eof\\\":true}}\\n\""
response = http.request(request)
puts response.read_body{
"commit": {
"blob_count": 1,
"commit_sha": "<string>",
"pack_bytes": 1,
"target_branch": "<string>",
"tree_sha": "<string>"
},
"result": {
"branch": "<string>",
"new_sha": "<string>",
"old_sha": "<string>",
"status": "<string>",
"success": true,
"message": "<string>"
}
}{
"result": {
"branch": "main",
"message": "expected branch head did not match current tip",
"new_sha": "",
"old_sha": "",
"status": "precondition_failed",
"success": false
}
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"result": {
"branch": "main",
"message": "expected branch head did not match current tip",
"new_sha": "",
"old_sha": "",
"status": "precondition_failed",
"success": false
}
}{
"result": {
"branch": "main",
"message": "blob chunk size 5242881 exceeds maximum 4194304",
"new_sha": "",
"old_sha": "",
"status": "payload_too_large",
"success": false
}
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Repository name. Names that contain / or any other character that is not safe in a URL path segment must be URL encoded so the value occupies a single path segment. For example pierre/example is sent as pierre%2Fexample. Plain names such as example can be sent as-is. The server URL-decodes the value before resolving the repository.
Body
Send newline-delimited JSON where the first line is a metadata object and each following line is a blob_chunk. This lets you stream file contents without a local Git client.
NDJSON stream. The first line must be metadata; subsequent lines must be blob_chunk payloads. Decoded blob chunks are limited to 4 MiB each.
Response
Commit created and written to the target branch.
curl --request POST \
--url https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-ndjson' \
--data '
"{\"metadata\":{\"target_branch\":\"main\",\"expected_head_sha\":\"d34db33fd34db33fd34db33fd34db33fd34db33f\",\"commit_message\":\"Update docs\",\"author\":{\"name\":\"Docs Bot\",\"email\":\"docs@example.com\"},\"files\":[{\"path\":\"docs/changelog.md\",\"operation\":\"upsert\",\"content_id\":\"blob-1\",\"mode\":\"100644\"},{\"path\":\"docs/legacy.txt\",\"operation\":\"delete\",\"content_id\":\"blob-2\"}]}}\n{\"blob_chunk\":{\"content_id\":\"blob-1\",\"data\":\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\",\"eof\":true}}\n{\"blob_chunk\":{\"content_id\":\"blob-2\",\"data\":\"\",\"eof\":true}}\n"
'import requests
url = "https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack"
payload = "{\"metadata\":{\"target_branch\":\"main\",\"expected_head_sha\":\"d34db33fd34db33fd34db33fd34db33fd34db33f\",\"commit_message\":\"Update docs\",\"author\":{\"name\":\"Docs Bot\",\"email\":\"docs@example.com\"},\"files\":[{\"path\":\"docs/changelog.md\",\"operation\":\"upsert\",\"content_id\":\"blob-1\",\"mode\":\"100644\"},{\"path\":\"docs/legacy.txt\",\"operation\":\"delete\",\"content_id\":\"blob-2\"}]}}
{\"blob_chunk\":{\"content_id\":\"blob-1\",\"data\":\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\",\"eof\":true}}
{\"blob_chunk\":{\"content_id\":\"blob-2\",\"data\":\"\",\"eof\":true}}
"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/x-ndjson"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/x-ndjson'},
body: JSON.stringify('{"metadata":{"target_branch":"main","expected_head_sha":"d34db33fd34db33fd34db33fd34db33fd34db33f","commit_message":"Update docs","author":{"name":"Docs Bot","email":"docs@example.com"},"files":[{"path":"docs/changelog.md","operation":"upsert","content_id":"blob-1","mode":"100644"},{"path":"docs/legacy.txt","operation":"delete","content_id":"blob-2"}]}}\n{"blob_chunk":{"content_id":"blob-1","data":"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==","eof":true}}\n{"blob_chunk":{"content_id":"blob-2","data":"","eof":true}}\n')
};
fetch('https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('{"metadata":{"target_branch":"main","expected_head_sha":"d34db33fd34db33fd34db33fd34db33fd34db33f","commit_message":"Update docs","author":{"name":"Docs Bot","email":"docs@example.com"},"files":[{"path":"docs/changelog.md","operation":"upsert","content_id":"blob-1","mode":"100644"},{"path":"docs/legacy.txt","operation":"delete","content_id":"blob-2"}]}}
{"blob_chunk":{"content_id":"blob-1","data":"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==","eof":true}}
{"blob_chunk":{"content_id":"blob-2","data":"","eof":true}}
'),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/x-ndjson"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack"
payload := strings.NewReader("\"{\\\"metadata\\\":{\\\"target_branch\\\":\\\"main\\\",\\\"expected_head_sha\\\":\\\"d34db33fd34db33fd34db33fd34db33fd34db33f\\\",\\\"commit_message\\\":\\\"Update docs\\\",\\\"author\\\":{\\\"name\\\":\\\"Docs Bot\\\",\\\"email\\\":\\\"docs@example.com\\\"},\\\"files\\\":[{\\\"path\\\":\\\"docs/changelog.md\\\",\\\"operation\\\":\\\"upsert\\\",\\\"content_id\\\":\\\"blob-1\\\",\\\"mode\\\":\\\"100644\\\"},{\\\"path\\\":\\\"docs/legacy.txt\\\",\\\"operation\\\":\\\"delete\\\",\\\"content_id\\\":\\\"blob-2\\\"}]}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-1\\\",\\\"data\\\":\\\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\\\",\\\"eof\\\":true}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-2\\\",\\\"data\\\":\\\"\\\",\\\"eof\\\":true}}\\n\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/x-ndjson")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/x-ndjson")
.body("\"{\\\"metadata\\\":{\\\"target_branch\\\":\\\"main\\\",\\\"expected_head_sha\\\":\\\"d34db33fd34db33fd34db33fd34db33fd34db33f\\\",\\\"commit_message\\\":\\\"Update docs\\\",\\\"author\\\":{\\\"name\\\":\\\"Docs Bot\\\",\\\"email\\\":\\\"docs@example.com\\\"},\\\"files\\\":[{\\\"path\\\":\\\"docs/changelog.md\\\",\\\"operation\\\":\\\"upsert\\\",\\\"content_id\\\":\\\"blob-1\\\",\\\"mode\\\":\\\"100644\\\"},{\\\"path\\\":\\\"docs/legacy.txt\\\",\\\"operation\\\":\\\"delete\\\",\\\"content_id\\\":\\\"blob-2\\\"}]}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-1\\\",\\\"data\\\":\\\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\\\",\\\"eof\\\":true}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-2\\\",\\\"data\\\":\\\"\\\",\\\"eof\\\":true}}\\n\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.{cluster}.code.storage/api/repos/{repo_name}/commit-pack")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-ndjson'
request.body = "\"{\\\"metadata\\\":{\\\"target_branch\\\":\\\"main\\\",\\\"expected_head_sha\\\":\\\"d34db33fd34db33fd34db33fd34db33fd34db33f\\\",\\\"commit_message\\\":\\\"Update docs\\\",\\\"author\\\":{\\\"name\\\":\\\"Docs Bot\\\",\\\"email\\\":\\\"docs@example.com\\\"},\\\"files\\\":[{\\\"path\\\":\\\"docs/changelog.md\\\",\\\"operation\\\":\\\"upsert\\\",\\\"content_id\\\":\\\"blob-1\\\",\\\"mode\\\":\\\"100644\\\"},{\\\"path\\\":\\\"docs/legacy.txt\\\",\\\"operation\\\":\\\"delete\\\",\\\"content_id\\\":\\\"blob-2\\\"}]}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-1\\\",\\\"data\\\":\\\"IyBWZXJzaW9uIDIuMS4wCi0gcmVmcmVzaCBkb2NzCg==\\\",\\\"eof\\\":true}}\\n{\\\"blob_chunk\\\":{\\\"content_id\\\":\\\"blob-2\\\",\\\"data\\\":\\\"\\\",\\\"eof\\\":true}}\\n\""
response = http.request(request)
puts response.read_body{
"commit": {
"blob_count": 1,
"commit_sha": "<string>",
"pack_bytes": 1,
"target_branch": "<string>",
"tree_sha": "<string>"
},
"result": {
"branch": "<string>",
"new_sha": "<string>",
"old_sha": "<string>",
"status": "<string>",
"success": true,
"message": "<string>"
}
}{
"result": {
"branch": "main",
"message": "expected branch head did not match current tip",
"new_sha": "",
"old_sha": "",
"status": "precondition_failed",
"success": false
}
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"result": {
"branch": "main",
"message": "expected branch head did not match current tip",
"new_sha": "",
"old_sha": "",
"status": "precondition_failed",
"success": false
}
}{
"result": {
"branch": "main",
"message": "blob chunk size 5242881 exceeds maximum 4194304",
"new_sha": "",
"old_sha": "",
"status": "payload_too_large",
"success": false
}
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}{
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"error": "<string>",
"instance": "<string>"
}