v5

latestOpenAPI 3.0.3Apache 2.0raw.githubusercontent.com2026-02-283466592.5 MB
Code references

Upsert branch

Create a new branch if it doesn't exist, or update the branch if it already exists.

put/api/v2/code-refs/repositories/{repo}/branches/{branch}

Path parameters

repostring string required

The repository name

The repository name

branchstring string required

The URL-encoded branch name

The URL-encoded branch name

Request body

namestring required

The branch name

headstring required

An ID representing the branch HEAD. For example, a commit SHA.

updateSequenceIdinteger

An optional ID used to prevent older data from overwriting newer data. If no sequence ID is included, the newly submitted data will always be saved.

syncTimeinteger required
commitTimeinteger

Example request

{
  "name": "main",
  "head": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
  "updateSequenceId": 25,
  "references": [
    {
      "path": "/main/index.js",
      "hint": "javascript",
      "hunks": [
        {
          "startingLineNumber": 45,
          "lines": "var enableFeature = 'enable-feature';",
          "projKey": "default",
          "flagKey": "enable-feature",
          "aliases": [
            "enableFeature",
            "EnableFeature"
          ]
        }
      ]
    }
  ]
}

Response

Action succeeded