curl -X POST https://api.relace.run/v1/repo/123e4567-e89b-12d3-a456-426614174000/update \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "diff",
"operations": [
{
"type": "write",
"filename": "src/search.ts",
"content": "function findItem(array: Item[], targetId: string): Item | undefined {\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n if (item.id === targetId) {\n return item;\n }\n }\n return undefined;\n}"
},
{
"type": "rename",
"old_filename": "src/utils.ts",
"new_filename": "src/helpers.ts"
},
{
"type": "delete",
"filename": "old-file.js"
}
]
},
"metadata": {
"version": "2.1.0",
"updated_by": "user123"
}
}'
import { Relace } from "@relace-ai/relace";
const client = new Relace({ apiKey: "YOUR_API_KEY" });
const repoId = "123e4567-e89b-12d3-a456-426614174000";
const result = await client.repo.update(repoId, {
source: {
type: "diff",
operations: [
{
type: "write",
filename: "src/search.ts",
content: "function findItem(array: Item[], targetId: string): Item | undefined {\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n if (item.id === targetId) {\n return item;\n }\n }\n return undefined;\n}"
},
{
type: "rename",
old_filename: "src/utils.ts",
new_filename: "src/helpers.ts"
},
{
type: "delete",
filename: "old-file.js"
}
]
},
metadata: {
version: "2.1.0",
updated_by: "user123"
}
});
console.log(result);
from relace import Relace
client = Relace(api_key="YOUR_API_KEY")
repo_id = "123e4567-e89b-12d3-a456-426614174000"
data = client.repo.update(
repo_id,
source={
"type": "diff",
"operations": [
{
"type": "write",
"filename": "src/search.ts",
"content": (
"function findItem(array: Item[], targetId: string): Item | undefined {\n"
" for (let i = 0; i < array.length; i++) {\n"
" const item = array[i];\n"
" if (item.id === targetId) {\n"
" return item;\n"
" }\n"
" }\n"
" return undefined;\n"
"}"
),
},
{
"type": "rename",
"old_filename": "src/utils.ts",
"new_filename": "src/helpers.ts",
},
{
"type": "delete",
"filename": "old-file.js",
},
],
},
metadata={
"version": "2.1.0",
"updated_by": "user123",
},
)
print(data)
{
"repo_head": "abc123def456",
"repo_id": "123e4567-e89b-12d3-a456-426614174000",
"changed_files": ["src/search.ts", "src/helpers.ts", "old-file.js"]
}
Source Control
Update Repo
Update repo content with files or sync from Git.
POST
/
v1
/
repo
/
{repo_id}
/
update
curl -X POST https://api.relace.run/v1/repo/123e4567-e89b-12d3-a456-426614174000/update \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "diff",
"operations": [
{
"type": "write",
"filename": "src/search.ts",
"content": "function findItem(array: Item[], targetId: string): Item | undefined {\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n if (item.id === targetId) {\n return item;\n }\n }\n return undefined;\n}"
},
{
"type": "rename",
"old_filename": "src/utils.ts",
"new_filename": "src/helpers.ts"
},
{
"type": "delete",
"filename": "old-file.js"
}
]
},
"metadata": {
"version": "2.1.0",
"updated_by": "user123"
}
}'
import { Relace } from "@relace-ai/relace";
const client = new Relace({ apiKey: "YOUR_API_KEY" });
const repoId = "123e4567-e89b-12d3-a456-426614174000";
const result = await client.repo.update(repoId, {
source: {
type: "diff",
operations: [
{
type: "write",
filename: "src/search.ts",
content: "function findItem(array: Item[], targetId: string): Item | undefined {\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n if (item.id === targetId) {\n return item;\n }\n }\n return undefined;\n}"
},
{
type: "rename",
old_filename: "src/utils.ts",
new_filename: "src/helpers.ts"
},
{
type: "delete",
filename: "old-file.js"
}
]
},
metadata: {
version: "2.1.0",
updated_by: "user123"
}
});
console.log(result);
from relace import Relace
client = Relace(api_key="YOUR_API_KEY")
repo_id = "123e4567-e89b-12d3-a456-426614174000"
data = client.repo.update(
repo_id,
source={
"type": "diff",
"operations": [
{
"type": "write",
"filename": "src/search.ts",
"content": (
"function findItem(array: Item[], targetId: string): Item | undefined {\n"
" for (let i = 0; i < array.length; i++) {\n"
" const item = array[i];\n"
" if (item.id === targetId) {\n"
" return item;\n"
" }\n"
" }\n"
" return undefined;\n"
"}"
),
},
{
"type": "rename",
"old_filename": "src/utils.ts",
"new_filename": "src/helpers.ts",
},
{
"type": "delete",
"filename": "old-file.js",
},
],
},
metadata={
"version": "2.1.0",
"updated_by": "user123",
},
)
print(data)
{
"repo_head": "abc123def456",
"repo_id": "123e4567-e89b-12d3-a456-426614174000",
"changed_files": ["src/search.ts", "src/helpers.ts", "old-file.js"]
}
Path Parameters
string
required
Repo ID
Request Body
object
Optional source for updating the repo content
Show properties
Show properties
string
required
Update type:
"git" for Git sync, "files" to replace all repo content, or
"diff" for specific operations- Git
- Files
- Diff
array
required
Array of file operations to perform
Show properties
Show properties
string
required
Operation type:
"write" to create/update, "rename" to change filename, or "delete" to removeobject
Optional object containing any key-value pairs, which overwrites any existing
metadata.
If neither
source nor metadata is provided, you’ll receive a 422 error.Response
string
The repository ID that was updated
string
Commit hash for the updated repo head
array
Array of file paths that were modified
curl -X POST https://api.relace.run/v1/repo/123e4567-e89b-12d3-a456-426614174000/update \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "diff",
"operations": [
{
"type": "write",
"filename": "src/search.ts",
"content": "function findItem(array: Item[], targetId: string): Item | undefined {\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n if (item.id === targetId) {\n return item;\n }\n }\n return undefined;\n}"
},
{
"type": "rename",
"old_filename": "src/utils.ts",
"new_filename": "src/helpers.ts"
},
{
"type": "delete",
"filename": "old-file.js"
}
]
},
"metadata": {
"version": "2.1.0",
"updated_by": "user123"
}
}'
import { Relace } from "@relace-ai/relace";
const client = new Relace({ apiKey: "YOUR_API_KEY" });
const repoId = "123e4567-e89b-12d3-a456-426614174000";
const result = await client.repo.update(repoId, {
source: {
type: "diff",
operations: [
{
type: "write",
filename: "src/search.ts",
content: "function findItem(array: Item[], targetId: string): Item | undefined {\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n if (item.id === targetId) {\n return item;\n }\n }\n return undefined;\n}"
},
{
type: "rename",
old_filename: "src/utils.ts",
new_filename: "src/helpers.ts"
},
{
type: "delete",
filename: "old-file.js"
}
]
},
metadata: {
version: "2.1.0",
updated_by: "user123"
}
});
console.log(result);
from relace import Relace
client = Relace(api_key="YOUR_API_KEY")
repo_id = "123e4567-e89b-12d3-a456-426614174000"
data = client.repo.update(
repo_id,
source={
"type": "diff",
"operations": [
{
"type": "write",
"filename": "src/search.ts",
"content": (
"function findItem(array: Item[], targetId: string): Item | undefined {\n"
" for (let i = 0; i < array.length; i++) {\n"
" const item = array[i];\n"
" if (item.id === targetId) {\n"
" return item;\n"
" }\n"
" }\n"
" return undefined;\n"
"}"
),
},
{
"type": "rename",
"old_filename": "src/utils.ts",
"new_filename": "src/helpers.ts",
},
{
"type": "delete",
"filename": "old-file.js",
},
],
},
metadata={
"version": "2.1.0",
"updated_by": "user123",
},
)
print(data)
{
"repo_head": "abc123def456",
"repo_id": "123e4567-e89b-12d3-a456-426614174000",
"changed_files": ["src/search.ts", "src/helpers.ts", "old-file.js"]
}
⌘I