List a repository's branches
Asks the git provider for the branches of one repository the connection can see, the default branch first, then by name, at most 200. You must be someone who may deploy the site.
GET/ api/ corestack/ sites/ {site}/ deployments/ branches
Path parameters
siteintegerRequired
The id of a site row. A website's production site and each of its environments has its own id. Digits only. At least 1.
Query parameters
connectionintegerRequired
The id of a repository connection you may use on this site, as the settings list them in connections.
repostringRequired
The repository as owner/name, or group/subgroup/name on GitLab. Up to 200 characters.
Returns
200 The branches.
Fields of the 200 answer
branchesarray of objectsRequired
Up to 200 items.
Fields of each item
defaultbooleanRequired
namestringRequired
shastring or nullRequired
The branch's newest commit.
If it is refused
| Status | Reason | What to do |
|---|---|---|
401 | none | Send a valid token as Authorization: Bearer <token>. |
403 | company_unavailable | Your company is unavailable. |
403 | scope_required | Use a token with the scope named in scope. |
403 | two_factor_required | Turn on two-factor on your account, then send again. |
404 | none | Check the id. You see only what your account can reach. |
409 | needs_reauth | The repository's connection is gone or needs authorising again. Reconnect the repository. |
422 | invalid | Fix the field named in field; errors says why. |
429 | rate_limited | Wait for the seconds in Retry-After. |
502 | none | Read the message; it says what happened. |
Reasons are listed by name in Errors and refusals.
The same task elsewhere
curl 'https://manage.corefinity.com/api/corestack/sites/1042/deployments/branches?connection=4217&repo=northwind-digital%2Fharbourandfinch' \
-H "Authorization: Bearer $COREFINITY_TOKEN" \
-H "Accept: application/json"use Illuminate\Support\Facades\Http;
$response = Http::withToken(env('COREFINITY_TOKEN'))
->acceptJson()
->get('https://manage.corefinity.com/api/corestack/sites/1042/deployments/branches?connection=4217&repo=northwind-digital%2Fharbourandfinch');
$data = $response->json();const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/deployments/branches?connection=4217&repo=northwind-digital%2Fharbourandfinch', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
Accept: 'application/json',
},
});
// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);import os
import requests
res = requests.get(
"https://manage.corefinity.com/api/corestack/sites/1042/deployments/branches?connection=4217&repo=northwind-digital%2Fharbourandfinch",
headers={
"Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
"Accept": "application/json",
},
)
data = res.json() if res.content else None{
"branches": [
{
"default": true,
"name": "main",
"sha": "9730595c6ec7aa59b77674ada74e30d961b1817c"
},
{
"default": false,
"name": "develop",
"sha": "4b1f0c9d2e7a8b6c5d4e3f2a1b0c9d8e7f6a5b4c"
}
]
}{
"message": "Unauthenticated."
}{
"code": "company_unavailable",
"message": "Your company is unavailable.",
"reason": "company_unavailable"
}{
"message": "Not found."
}{
"code": "needs_reauth",
"message": "The GitLab connection needs re-authorising",
"reason": "needs_reauth"
}{
"code": "invalid",
"errors": {
"repo": [
"Enter the repository as owner/name",
"or group/subgroup/name on GitLab"
]
},
"field": "repo",
"message": "Enter the repository as owner/name, or group/subgroup/name on GitLab",
"reason": "invalid"
}{
"code": "rate_limited",
"message": "Too many requests. Try again in 60 seconds.",
"reason": "rate_limited",
"retry_after_seconds": 60
}{
"message": "GitLab did not answer. Try again."
}Try it
Was this helpful?