curl -X PUT https://api.relace.run/v1/repo/3fa85f64-5717-4562-b3fc-2c963f66afa6/file/src/main.py \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary "def main():
print('Hello World!')
if __name__ == '__main__':
main()"
const repoId = "3fa85f64-5717-4562-b3fc-2c963f66afa6";
const filePath = "src/main.py";
const content = `def main():
print("Hello World!")
if __name__ == "__main__":
main()`;
const url = `https://api.relace.run/v1/repo/${repoId}/file/${encodeURIComponent(filePath)}`;
const headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/octet-stream"
};
const response = await fetch(url, {
method: "PUT",
headers: headers,
body: content
});
const data = await response.json();
console.log(data);
const repoId = '3fa85f64-5717-4562-b3fc-2c963f66afa6';
const filePath = 'src/main.py';
const content = `def main():
print("Hello World!")
if __name__ == "__main__":
main()`;
const url = `https://api.relace.run/v1/repo/${repoId}/file/${encodeURIComponent(
filePath
)}`;
fetch(url, {
method: 'PUT',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/octet-stream',
},
body: content,
})
.then((response) => response.json())
.then((data) => console.log(data));
// Example from a Next.js API route
const file = { name: 'src/main.py', content: 'base64-encoded-content' };
const buffer = Buffer.from(file.content, 'base64');
const uploadRes = await fetch(
`${
process.env.NEXT_PUBLIC_AGENT_URL
}/repo/${repoId}/file/${encodeURIComponent(file.name)}`,
{
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.RELACE_API_KEY}`,
'Content-Type': 'application/octet-stream',
},
body: buffer,
}
);
if (!uploadRes.ok) {
throw new Error(`Failed to upload file: ${file.name}`);
}
{
"repo_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"repo_head": "abc123def456789",
"changed_files": ["src/main.py"]
}
Source Control
Upload File
Upload a file to the repository
PUT
/
v1
/
repo
/
{repo_id}
/
file
/
{file_path}
curl -X PUT https://api.relace.run/v1/repo/3fa85f64-5717-4562-b3fc-2c963f66afa6/file/src/main.py \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary "def main():
print('Hello World!')
if __name__ == '__main__':
main()"
const repoId = "3fa85f64-5717-4562-b3fc-2c963f66afa6";
const filePath = "src/main.py";
const content = `def main():
print("Hello World!")
if __name__ == "__main__":
main()`;
const url = `https://api.relace.run/v1/repo/${repoId}/file/${encodeURIComponent(filePath)}`;
const headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/octet-stream"
};
const response = await fetch(url, {
method: "PUT",
headers: headers,
body: content
});
const data = await response.json();
console.log(data);
const repoId = '3fa85f64-5717-4562-b3fc-2c963f66afa6';
const filePath = 'src/main.py';
const content = `def main():
print("Hello World!")
if __name__ == "__main__":
main()`;
const url = `https://api.relace.run/v1/repo/${repoId}/file/${encodeURIComponent(
filePath
)}`;
fetch(url, {
method: 'PUT',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/octet-stream',
},
body: content,
})
.then((response) => response.json())
.then((data) => console.log(data));
// Example from a Next.js API route
const file = { name: 'src/main.py', content: 'base64-encoded-content' };
const buffer = Buffer.from(file.content, 'base64');
const uploadRes = await fetch(
`${
process.env.NEXT_PUBLIC_AGENT_URL
}/repo/${repoId}/file/${encodeURIComponent(file.name)}`,
{
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.RELACE_API_KEY}`,
'Content-Type': 'application/octet-stream',
},
body: buffer,
}
);
if (!uploadRes.ok) {
throw new Error(`Failed to upload file: ${file.name}`);
}
{
"repo_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"repo_head": "abc123def456789",
"changed_files": ["src/main.py"]
}
Path Parameters
string
required
Repo ID
string
required
Path to the file within the repository (URL encoded)
Request Body
The request body should contain the raw file content as binary data. Set theContent-Type header to application/octet-stream.
Response
Returns HTTP status201 Created on success.
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 PUT https://api.relace.run/v1/repo/3fa85f64-5717-4562-b3fc-2c963f66afa6/file/src/main.py \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary "def main():
print('Hello World!')
if __name__ == '__main__':
main()"
const repoId = "3fa85f64-5717-4562-b3fc-2c963f66afa6";
const filePath = "src/main.py";
const content = `def main():
print("Hello World!")
if __name__ == "__main__":
main()`;
const url = `https://api.relace.run/v1/repo/${repoId}/file/${encodeURIComponent(filePath)}`;
const headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/octet-stream"
};
const response = await fetch(url, {
method: "PUT",
headers: headers,
body: content
});
const data = await response.json();
console.log(data);
const repoId = '3fa85f64-5717-4562-b3fc-2c963f66afa6';
const filePath = 'src/main.py';
const content = `def main():
print("Hello World!")
if __name__ == "__main__":
main()`;
const url = `https://api.relace.run/v1/repo/${repoId}/file/${encodeURIComponent(
filePath
)}`;
fetch(url, {
method: 'PUT',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/octet-stream',
},
body: content,
})
.then((response) => response.json())
.then((data) => console.log(data));
// Example from a Next.js API route
const file = { name: 'src/main.py', content: 'base64-encoded-content' };
const buffer = Buffer.from(file.content, 'base64');
const uploadRes = await fetch(
`${
process.env.NEXT_PUBLIC_AGENT_URL
}/repo/${repoId}/file/${encodeURIComponent(file.name)}`,
{
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.RELACE_API_KEY}`,
'Content-Type': 'application/octet-stream',
},
body: buffer,
}
);
if (!uploadRes.ok) {
throw new Error(`Failed to upload file: ${file.name}`);
}
{
"repo_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"repo_head": "abc123def456789",
"changed_files": ["src/main.py"]
}
⌘I