Skip to content
FeedbackDashboard

Create a new project branch

$client->projects->branches->create(string project, string branch, string branchFrom, ?bool force): ProjectBranch
POST/v0/projects/{project}/branches

Create a new branch for a project.

The branch inherits the config files from the revision pointed to by the branch_from parameter. In addition, if the revision is a branch name, the branch will also inherit custom code changes from that branch.

ParametersExpand Collapse
project: string
branch: string

Branch name

branchFrom: string

Branch or commit SHA to branch from

force?:optional bool

Whether to throw an error if the branch already exists. Defaults to false.

ReturnsExpand Collapse
string branch

Branch name

ConfigCommit configCommit

A Git commit that points to the latest set of config files on a given branch.

?Build latestBuild
Object_ object
string org
string project

Project name

Create a new project branch

<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(apiKey: 'My API Key', environment: 'staging');

$projectBranch = $client->projects->branches->create(
  project: 'project', branch: 'branch', branchFrom: 'branch_from', force: true
);

var_dump($projectBranch);
{
  "branch": "branch",
  "config_commit": {
    "repo": {
      "branch": "branch",
      "host": "host",
      "name": "name",
      "owner": "owner"
    },
    "sha": "sha",
    "stats": {
      "additions": 0,
      "deletions": 0,
      "total": 0
    },
    "tree_oid": "tree_oid"
  },
  "latest_build": {
    "id": "id",
    "config_commit": "config_commit",
    "created_at": "2019-12-27T18:11:19.117Z",
    "documented_spec": {
      "content": "content",
      "type": "content"
    },
    "object": "build",
    "org": "org",
    "project": "project",
    "targets": {
      "cli": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "csharp": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "go": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "java": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "kotlin": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "node": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "openapi": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "php": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "python": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "ruby": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "sql": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "terraform": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "typescript": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      }
    },
    "updated_at": "2019-12-27T18:11:19.117Z"
  },
  "object": "project_branch",
  "org": "org",
  "project": "project"
}
Returns Examples
{
  "branch": "branch",
  "config_commit": {
    "repo": {
      "branch": "branch",
      "host": "host",
      "name": "name",
      "owner": "owner"
    },
    "sha": "sha",
    "stats": {
      "additions": 0,
      "deletions": 0,
      "total": 0
    },
    "tree_oid": "tree_oid"
  },
  "latest_build": {
    "id": "id",
    "config_commit": "config_commit",
    "created_at": "2019-12-27T18:11:19.117Z",
    "documented_spec": {
      "content": "content",
      "type": "content"
    },
    "object": "build",
    "org": "org",
    "project": "project",
    "targets": {
      "cli": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "csharp": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "go": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "java": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "kotlin": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "node": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "openapi": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "php": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "python": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "ruby": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "sql": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "terraform": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      },
      "typescript": {
        "commit": {
          "status": "not_started"
        },
        "install_url": "install_url",
        "object": "build_target",
        "status": "not_started",
        "build": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "test": {
          "status": "not_started"
        }
      }
    },
    "updated_at": "2019-12-27T18:11:19.117Z"
  },
  "object": "project_branch",
  "org": "org",
  "project": "project"
}