Use this API to interact with the Terraform CLI.

This API is used by the Terraform CLI and is generally not meant for manual consumption. Undocumented authentication methods might be removed in the future.

Retrieve latest version for a module

GET /api/v4/packages/terraform/modules/v1/{module_namespace}/{module_name}/{module_system}

Retrieves latest version for a specified module.

Parameters

NameTypeDescription
module_namespace
Path, required
StringGroup’s ID or slug
module_name
Path, required
StringThe module name
module_system
Path, required
StringThe module system (provider)

Responses

CodeDescriptionSchema
200OKAPIEntitiesTerraformModuleVersion
400Bad Request—
403Forbidden—
404Not found—

Retrieve download URL for latest module version

GET /api/v4/packages/terraform/modules/v1/{module_namespace}/{module_name}/{module_system}/download

Retrieves download URL for latest module version.

Parameters

NameTypeDescription
module_namespace
Path, required
StringGroup’s ID or slug
module_name
Path, required
StringThe module name
module_system
Path, required
StringThe module system (provider)

Responses

CodeDescriptionSchema
302Found—
400Bad Request—
403Forbidden—
404Not found—

List all available versions for a module

GET /api/v4/packages/terraform/modules/v1/{module_namespace}/{module_name}/{module_system}/versions

Lists all available versions for a specified module.

Parameters

NameTypeDescription
module_namespace
Path, required
StringGroup’s ID or slug
module_name
Path, required
StringThe module name
module_system
Path, required
StringThe module system (provider)

Responses

CodeDescriptionSchema
200OKAPIEntitiesTerraformModuleVersions
400Bad Request—
403Forbidden—
404Not Found—

Get details about specific version of a module

GET /api/v4/packages/terraform/modules/v1/{module_namespace}/{module_name}/{module_system}/{module_version}

Parameters

NameTypeDescription
module_namespace
Path, required
StringGroup’s ID or slug
module_name
Path, required
StringThe module name
module_system
Path, required
StringThe module system (provider)
module_version
Path, required
StringVersion of the module

Responses

CodeDescriptionSchema
200OKAPIEntitiesTerraformModuleVersion
400Bad Request—
403Forbidden—
404Not found—

Get download location for specific version of a module

GET /api/v4/packages/terraform/modules/v1/{module_namespace}/{module_name}/{module_system}/{module_version}/download

Download specific version of a module

Parameters

NameTypeDescription
module_namespace
Path, required
StringGroup’s ID or slug
module_name
Path, required
StringThe module name
module_system
Path, required
StringThe module system (provider)
module_version
Path, required
StringVersion of the module

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
403Forbidden—
404Not found—

Download specific version of a module

GET /api/v4/packages/terraform/modules/v1/{module_namespace}/{module_name}/{module_system}/{module_version}/file

Parameters

NameTypeDescription
module_namespace
Path, required
StringGroup’s ID or slug
module_name
Path, required
StringThe module name
module_system
Path, required
StringThe module system (provider)
module_version
Path, required
StringVersion of the module

Responses

CodeDescriptionSchema
200OKString (binary) (application/octet-stream)
400Bad Request—
403Forbidden—
404Not found—

Download the latest version of a module

GET /api/v4/projects/{id}/packages/terraform/modules/{module_name}/{module_system}

Downloads the latest version of a specified module. This feature was introduced in GitLab 16.7.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or full path of a project
module_name
Path, required
StringModule name
Example: infra-registry
module_system
Path, required
StringModule system
Example: aws
terraform-get
Query
StringTerraform get redirection flag
Allowed values: 1

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Download a specific version of a module

GET /api/v4/projects/{id}/packages/terraform/modules/{module_name}/{module_system}/{module_version}

This feature was introduced in GitLab 16.7

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or full path of a project
module_name
Path, required
StringModule name
Example: infra-registry
module_system
Path, required
StringModule system
Example: aws
module_version
Path, required
StringModule version
terraform-get
Query
StringTerraform get redirection flag
Allowed values: 1

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Upload Terraform Module package file

PUT /api/v4/projects/{id}/packages/terraform/modules/{module_name}/{module_system}/{module_version}/file

This feature was introduced in GitLab 13.11

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or full path of a project
module_name
Path, required
StringModule name
Example: infra-registry
module_system
Path, required
StringModule system
Example: aws
module_version
Path, required
StringModule version

Request body (multipart/form-data)

PropertyTypeDescription
file
Required
String (binary)The package file to be published (generated by Multipart middleware)

Responses

CodeDescriptionSchema
201Created—
400Invalid file—
401Unauthorized—
403Forbidden—
404Not found—

Workhorse authorize Terraform Module package file

PUT /api/v4/projects/{id}/packages/terraform/modules/{module_name}/{module_system}/{module_version}/file/authorize

This feature was introduced in GitLab 13.11

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or full path of a project
module_name
Path, required
StringModule name
Example: infra-registry
module_system
Path, required
StringModule system
Example: aws
module_version
Path, required
StringModule version

Responses

CodeDescriptionSchema
200OK—
400Bad Request—
403Forbidden—
404Not Found—

Retrieve a Terraform state

GET /api/v4/projects/{id}/terraform/state/{name}

Retrieves a Terraform state by name for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state
ID
Query
StringTerraform state lock ID
Maximum length: 255

Responses

CodeDescriptionSchema
200OK—
204Empty state—
400Bad Request—
403Forbidden—
404Not found—
422Validation failure—

Create or update a Terraform state

POST /api/v4/projects/{id}/terraform/state/{name}

Creates or updates a Terraform state for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state

Request body (multipart/form-data)

PropertyTypeDescription
file
Required
String (binary)The package file to be published (generated by Multipart middleware)

Responses

CodeDescriptionSchema
200OK—
204No data provided—
400Bad Request—
403Forbidden—
404Not Found—
413Request Entity Too Large—
422Validation failure—

Delete a Terraform state

DELETE /api/v4/projects/{id}/terraform/state/{name}

Deletes a Terraform state for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state

Responses

CodeDescriptionSchema
200OK—
400Bad Request—
403Forbidden—
404Not found—
422Validation failure—

Authorize Terraform state upload

POST /api/v4/projects/{id}/terraform/state/{name}/authorize

Authorizes uploading a Terraform state for a specified project. This feature was introduced in GitLab 18.5.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state

Responses

CodeDescriptionSchema
200OK—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—

Lock a Terraform state

POST /api/v4/projects/{id}/terraform/state/{name}/lock

Locks a Terraform state for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state

Request body (application/json)

PropertyTypeDescription
Created
Required
StringTerraform state lock timestamp
ID
Required
StringTerraform state lock ID
Maximum length: 255
Info
Required
StringTerraform info
Operation
Required
StringTerraform operation
Path
Required
StringTerraform path
Version
Required
StringTerraform version
Who
Required
StringTerraform state lock owner

Responses

CodeDescriptionSchema
200OK—
400Bad Request—
403Forbidden—
404Not found—
409Conflict—
422Validation failure—

Unlock a Terraform state

DELETE /api/v4/projects/{id}/terraform/state/{name}/lock

Unlocks a Terraform state for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state
ID
Query
StringTerraform state lock ID
Maximum length: 255

Responses

CodeDescriptionSchema
200OK—
400Bad Request—
403Forbidden—
404Not found—
409Conflict—
422Validation failure—

Retrieve a Terraform state version

GET /api/v4/projects/{id}/terraform/state/{name}/versions/{serial}

Retrieves a specified Terraform state version.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state
serial
Path, required
IntegerThe version number of the state

Responses

CodeDescriptionSchema
200OKString (binary) (application/octet-stream)
400Bad Request—
403Forbidden—
404Not found—

Delete a Terraform state version

DELETE /api/v4/projects/{id}/terraform/state/{name}/versions/{serial}

Deletes a specified Terraform state version.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
name
Path, required
StringThe name of a Terraform state
serial
Path, required
IntegerThe version number of the state

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
403Forbidden—
404Not found—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesTerraformModuleVersion

PropertyTypeDescription
nameString—
providerString—
providersString—
rootString—
sourceString—
submodulesString—
versionString—
versionsString—

APIEntitiesTerraformModuleVersions

PropertyTypeDescription
modulesString—