CreateProjects
client.Projects.BulkNew(ctx, body) (*ProjectBulkNewResponse, error)
POST/gitpod.v1.ProjectService/CreateProjects
Creates multiple projects in a single request.
Use this method to:
- Onboard multiple repositories at once
- Import a batch of projects during initial setup
Returns successfully created projects and details about any failures. Each project in the request is processed independently — partial success is possible.
Examples
-
Create multiple projects:
Creates several projects in one request.
projects: - name: "Frontend" initializer: specs: - git: remoteUri: "https://github.com/org/frontend" - name: "Backend" initializer: specs: - git: remoteUri: "https://github.com/org/backend"
CreateProjects
package main
import (
"context"
"fmt"
"github.com/gitpod-io/gitpod-sdk-go"
"github.com/gitpod-io/gitpod-sdk-go/option"
)
func main() {
client := gitpod.NewClient(
option.WithBearerToken("My Bearer Token"),
)
response, err := client.Projects.BulkNew(context.TODO(), gitpod.ProjectBulkNewParams{
Projects: gitpod.F([]gitpod.ProjectBulkNewParamsProject{gitpod.ProjectBulkNewParamsProject{
Initializer: gitpod.F(gitpod.EnvironmentInitializerParam{
Specs: gitpod.F([]gitpod.EnvironmentInitializerSpecParam{gitpod.EnvironmentInitializerSpecParam{
Git: gitpod.F(gitpod.EnvironmentInitializerSpecsGitParam{
RemoteUri: gitpod.F("https://github.com/org/frontend"),
}),
}}),
}),
Name: gitpod.F("Frontend"),
}, gitpod.ProjectBulkNewParamsProject{
Initializer: gitpod.F(gitpod.EnvironmentInitializerParam{
Specs: gitpod.F([]gitpod.EnvironmentInitializerSpecParam{gitpod.EnvironmentInitializerSpecParam{
Git: gitpod.F(gitpod.EnvironmentInitializerSpecsGitParam{
RemoteUri: gitpod.F("https://github.com/org/backend"),
}),
}}),
}),
Name: gitpod.F("Backend"),
}}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.CreatedProjects)
}
{
"createdProjects": [
{
"environmentClass": {
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
},
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"automationsFilePath": "automationsFilePath",
"desiredPhase": "PROJECT_PHASE_UNSPECIFIED",
"devcontainerFilePath": "devcontainerFilePath",
"environmentClasses": [
{
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
}
],
"initializer": {
"specs": [
{
"contextUrl": {
"url": "https://example.com"
},
"git": {
"checkoutLocation": "checkoutLocation",
"cloneTarget": "cloneTarget",
"remoteUri": "remoteUri",
"targetMode": "CLONE_TARGET_MODE_UNSPECIFIED",
"upstreamRemoteUri": "upstreamRemoteUri"
}
}
]
},
"metadata": {
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"name": "x",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"updatedAt": "2019-12-27T18:11:19.117Z"
},
"prebuildConfiguration": {
"enabled": true,
"enableJetbrainsWarmup": true,
"environmentClassIds": [
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
],
"executor": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"timeout": "+9125115.360s",
"trigger": {
"dailySchedule": {
"hourUtc": 23
}
}
},
"recommendedEditors": {
"editors": {
"foo": {
"versions": [
"string"
]
}
}
},
"technicalDescription": "technicalDescription",
"usedBy": {
"subjects": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
}
],
"totalSubjects": 0
}
}
],
"failedProjects": [
{
"error": "error",
"index": 0,
"name": "name"
}
]
}Returns Examples
{
"createdProjects": [
{
"environmentClass": {
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
},
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"automationsFilePath": "automationsFilePath",
"desiredPhase": "PROJECT_PHASE_UNSPECIFIED",
"devcontainerFilePath": "devcontainerFilePath",
"environmentClasses": [
{
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
}
],
"initializer": {
"specs": [
{
"contextUrl": {
"url": "https://example.com"
},
"git": {
"checkoutLocation": "checkoutLocation",
"cloneTarget": "cloneTarget",
"remoteUri": "remoteUri",
"targetMode": "CLONE_TARGET_MODE_UNSPECIFIED",
"upstreamRemoteUri": "upstreamRemoteUri"
}
}
]
},
"metadata": {
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"name": "x",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"updatedAt": "2019-12-27T18:11:19.117Z"
},
"prebuildConfiguration": {
"enabled": true,
"enableJetbrainsWarmup": true,
"environmentClassIds": [
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
],
"executor": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"timeout": "+9125115.360s",
"trigger": {
"dailySchedule": {
"hourUtc": 23
}
}
},
"recommendedEditors": {
"editors": {
"foo": {
"versions": [
"string"
]
}
}
},
"technicalDescription": "technicalDescription",
"usedBy": {
"subjects": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
}
],
"totalSubjects": 0
}
}
],
"failedProjects": [
{
"error": "error",
"index": 0,
"name": "name"
}
]
}