Rename a working branch
const url = 'https://api.hydrate.sh/v1/branches/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://api.hydrate.sh/v1/branches/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "example" }'Rename a working branch you own. There is no separate archive state for a branch (that shape is DELETE, which is already recoverable by id via the audit trail if needed) — this route is rename-only.
Requires graph:write, same as the delta-apply route: a rename round-trips (nothing is destroyed), so it carries no scope of its own.
The protected main branch cannot be renamed: 409 main_not_writable. A branch that exists but is no longer active (already discarded or merged) cannot be renamed either: 409 branch_not_active.
Only the branch’s owner may rename it; a caller who can see the branch but does not own it gets the same 404 a non-existent branch gets.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The branch to rename.
The branch to rename.
Request Bodyrequired
Section titled “Request Bodyrequired”Body for PATCH /v1/branches/{branch_id}. Rename only — a branch
has no archive state the way a project does; discard (the DELETE route
beside this one) is already the non-listed-but-recoverable-by-id shape a
project gets from archiving. name is required (not optional-with-a-
no-fields-guard, unlike the project patch body): there is only one field,
so an absent body is already a 422 from Pydantic without extra code.
object
New name for the branch.
Examplegenerated
{ "name": "example"}Responses
Section titled “Responses”Successful Response
Rename returns the branch alone — the project is not affected.
object
object
Examplegenerated
{ "branch": { "base_main_version": 1, "created_at": "example", "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "is_main": true, "last_active_at": "example", "merged_at": "example", "name": "example", "owner_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "project_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "status": "example", "version": 1 }, "project_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "version": "example"}No credentials, malformed credentials, or revoked credentials. The envelope is leak-parity (same shape across all 401 paths) so an attacker cannot distinguish revoked vs. unknown via the body.
object
Example
{ "detail": "unauthenticated"}Credentials are valid but lack the scope required for this route, or the principal lacks membership in the target project.
object
object
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Resource not found OR not accessible to this principal. Leak parity: the response is identical in both cases so an attacker cannot enumerate resources via 404-vs-403 timing.
object
object
Example
{ "detail": { "code": "not_found" }}Validation Error
object
object
object
Examplegenerated
{ "detail": [ { "ctx": {}, "input": "example", "loc": [ "example" ], "msg": "example", "type": "example" } ]}Per-bucket rate limit exceeded. The response carries Retry-After and the standard X-RateLimit-* headers (Limit / Remaining / Reset).
object
Example
{ "detail": "rate_limited"}