curl -X POST https://api.relace.run/v1/repo \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "files",
"files": [
{
"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}"
},
{
"filename": "src/types.ts",
"content": "interface Item {\n id: string;\n value: string;\n metadata?: Record<string, unknown>;\n}"
}
# ... more files
]
},
"metadata": {
"name": "my-codebase",
"id": "my-internal-id"
}
}'
{
"repo_id": "123e4567-e89b-12d3-a456-426614174000",
"repo_head": "a1b2c3d4e5f6789012345678901234567890abcdef"
}
Source Control
Create Repo
Create a new repo from files or a GitHub repo.
POST
/
v1
/
repo
curl -X POST https://api.relace.run/v1/repo \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "files",
"files": [
{
"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}"
},
{
"filename": "src/types.ts",
"content": "interface Item {\n id: string;\n value: string;\n metadata?: Record<string, unknown>;\n}"
}
# ... more files
]
},
"metadata": {
"name": "my-codebase",
"id": "my-internal-id"
}
}'
{
"repo_id": "123e4567-e89b-12d3-a456-426614174000",
"repo_head": "a1b2c3d4e5f6789012345678901234567890abcdef"
}
Request Body
Optional object to initialize the repo from existing source
Show properties
Show properties
The source type:
"files" for direct file upload, "git" for GitHub repo, or "relace" for Relace repo- From Files
- From Git Repo
- From Relace Repo
Git repo URL to clone from
Specific branch to clone
Whether to import using a shallow clone
Commit history is not preserved when this option is enabled, so operations that require in-tact history (e.g. GitHub sync) will not work.
Optional object containing any key-value pairs for custom metadata about the
repo
Optional flag to enable automatic code indexing/embedding after repo creation and updates.
This parameter must be enabled for semantic retrieval to work.
Response
Unique identifier for the newly created repo
Commit hash for the current repo head
curl -X POST https://api.relace.run/v1/repo \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "files",
"files": [
{
"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}"
},
{
"filename": "src/types.ts",
"content": "interface Item {\n id: string;\n value: string;\n metadata?: Record<string, unknown>;\n}"
}
# ... more files
]
},
"metadata": {
"name": "my-codebase",
"id": "my-internal-id"
}
}'
{
"repo_id": "123e4567-e89b-12d3-a456-426614174000",
"repo_head": "a1b2c3d4e5f6789012345678901234567890abcdef"
}
⌘I