CreateSecret
Creates a new secret for a project.
Use this method to:
- Store sensitive configuration values
- Set up environment variables
- Configure registry authentication
- Add file-based secrets
Examples
-
Create environment variable:
Creates a secret that will be available as an environment variable.
name: "DATABASE_URL" projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047" value: "postgresql://user:pass@localhost:5432/db" environmentVariable: true -
Create file secret:
Creates a secret that will be mounted as a file.
name: "SSH_KEY" projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047" value: "-----BEGIN RSA PRIVATE KEY-----\n..." filePath: "/home/gitpod/.ssh/id_rsa" -
Create registry auth:
Creates credentials for private container registry.
name: "DOCKER_AUTH" projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047" value: "username:password" containerRegistryBasicAuthHost: "https://registry.example.com"
Body ParametersJSON
api_only indicates the secret is only available via API/CLI. These secrets are NOT automatically injected into services or devcontainers. Useful for secrets that should only be consumed programmatically (e.g., by security agents).
secret will be mounted as a docker config in the environment VM, mount will have the docker registry host
secret will be created as an Environment Variable with the same name as the secret
absolute path to the file where the secret is mounted value must be an absolute path (e.g. /path/to/file):
this.matches('^/[^/].*$')CreateSecret
curl https://app.gitpod.io/api/gitpod.v1.SecretService/CreateSecret \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $GITPOD_API_KEY" \
-d '{}'{
"secret": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"apiOnly": true,
"containerRegistryBasicAuthHost": "https://example.com",
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"environmentVariable": true,
"filePath": "filePath",
"name": "name",
"projectId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"scope": {
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"projectId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"serviceAccountId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"userId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
"updatedAt": "2019-12-27T18:11:19.117Z"
}
}Returns Examples
{
"secret": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"apiOnly": true,
"containerRegistryBasicAuthHost": "https://example.com",
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"environmentVariable": true,
"filePath": "filePath",
"name": "name",
"projectId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"scope": {
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"projectId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"serviceAccountId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"userId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
"updatedAt": "2019-12-27T18:11:19.117Z"
}
}