projects

Create a Terraform state protection rule for a project

This feature was introduced in GitLab 19.1.

post/api/v4/projects/{id}/terraform/state_protection_rules

Request

  • Base URL
    https://gitlab.com
  • Auth
    none declared

Path parameters

idstring required

The ID or URL-encoded path of the project

Request body

state_namestring required

Terraform state name to protect. Maximum 255 characters. Must be unique per project.

minimum_access_level_for_write'developer' | 'maintainer' | 'owner' | 'admin' required

Minimum GitLab access level required to write to the Terraform state. Valid values: developer, maintainer, owner, admin.

allowed_from'anywhere' | 'ci_only' | 'ci_on_protected_branch_only'

Source restriction for write requests. Default: anywhere. Valid values: anywhere, ci_only, ci_on_protected_branch_only.

Response

Create a Terraform state protection rule for a project

idinteger required
project_idinteger required
state_namestring required
minimum_access_level_for_writestring required
allowed_fromstring required

Example response

{
  "id": 1,
  "project_id": 1,
  "state_name": "production",
  "minimum_access_level_for_write": "maintainer",
  "allowed_from": "ci_only"
}

Changes

No recorded changes to this operation across all 5 revisions of this API.