|
| 1 | +--- |
| 2 | +page_title: Manage module versions - API Docs - HCP Terraform |
| 3 | +description: |- |
| 4 | + Use these module management endpoints to deprecate and revert the deprecation of module versions you published to an organization's private registry. |
| 5 | +tfc_only: true |
| 6 | +--- |
| 7 | + |
| 8 | +[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 |
| 9 | + |
| 10 | +[201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 |
| 11 | + |
| 12 | +[202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 |
| 13 | + |
| 14 | +[204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 |
| 15 | + |
| 16 | +[400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 |
| 17 | + |
| 18 | +[401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 |
| 19 | + |
| 20 | +[403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 |
| 21 | + |
| 22 | +[404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 |
| 23 | + |
| 24 | +[409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 |
| 25 | + |
| 26 | +[412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 |
| 27 | + |
| 28 | +[422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 |
| 29 | + |
| 30 | +[429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 |
| 31 | + |
| 32 | +[500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 |
| 33 | + |
| 34 | +[503]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503 |
| 35 | + |
| 36 | +[JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents |
| 37 | + |
| 38 | +[JSON API error object]: https://jsonapi.org/format/#error-objects |
| 39 | + |
| 40 | +# Manage module versions API |
| 41 | + |
| 42 | +This topic provides reference information about API endpoints that let your deprecate module versions in your organization’s private registry. |
| 43 | + |
| 44 | +## Introduction |
| 45 | + |
| 46 | +When you deprecate a module version, HCP Terraform adds warnings to the module's registry page and to run outputs when anyone uses the deprecated version. |
| 47 | + |
| 48 | +<!-- BEGIN: TFC:only name:pnp-callout --> |
| 49 | +@include "tfc-package-callouts/manage-module-versions.mdx" |
| 50 | +<!-- END: TFC:only name:pnp-callout --> |
| 51 | + |
| 52 | +After deprecating a module version, you can revert that deprecated status to remove the warnings from that version in the registry and outputs. For more details on module deprecation, refer to [Deprecate module versions](/terraform/cloud-docs/registry/manage-module-versions). |
| 53 | + |
| 54 | +@include "public-beta/manage-module-versions.mdx" |
| 55 | + |
| 56 | +## Deprecate a module version |
| 57 | + |
| 58 | +Use this endpoint to deprecate a module version. |
| 59 | + |
| 60 | +`PATCH /api/v2/organizations/:organization_name/registry-modules/private/:organization_name/:module_name/:module_provider/:module_version` |
| 61 | + |
| 62 | + |
| 63 | +| Parameter | Description | |
| 64 | +| :---- | :---- | |
| 65 | +| `:organization_name` | The name of the organization the module belongs to. | |
| 66 | +| `:module_name` | The name of the module whose version you want to deprecate. | |
| 67 | +| `:module_provider` | Specifies the Terraform provider that this module is used for. | |
| 68 | +| `:module_version` | The module version you want to deprecate. | |
| 69 | + |
| 70 | +This endpoint allows you to deprecate a specific module version. Deprecating a module version adds warnings to the run output of any consumers using this module. |
| 71 | + |
| 72 | + |
| 73 | +| Status | Response | Reason | |
| 74 | +| :---- | :---- | :---- | |
| 75 | +| [200](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) | [JSON API document](http://terraform/cloud-docs/api-docs#json-api-documents) | Successfully deprecated a module version. | |
| 76 | +| [404](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404) | [JSON API error object](http://jsonapi.org/format/#error-objects) | This organization is not authorized to deprecate this module version, or the module version does not exist. | |
| 77 | +| [422](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422) | [JSON API error object](http://jsonapi.org/format/#error-objects) | Malformed request body, for example the request is missing attributes or uses the wrong types. | |
| 78 | +| [500](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) or [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) | [JSON API error object](http://jsonapi.org/format/#error-objects) | Failure occurred while deprecating a module version. | |
| 79 | + |
| 80 | +### **Sample Payload** |
| 81 | + |
| 82 | +```json |
| 83 | +{ |
| 84 | + "data": { |
| 85 | + "type": "module-versions", |
| 86 | + "attributes": { |
| 87 | + "deprecation": { |
| 88 | + "deprecated-status": "Deprecated", |
| 89 | + "reason": "Deprecated due to a security vulnerability issue.", |
| 90 | + "link": "https://www.hashicorp.com/" |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +### **Sample Request** |
| 98 | + |
| 99 | +```shell |
| 100 | +curl \ |
| 101 | + --header "Authorization: Bearer $TOKEN" \ |
| 102 | + --header "Content-Type: application/vnd.api+json" \ |
| 103 | + --request PATCH \ |
| 104 | + --data @payload.json \ |
| 105 | +https://app.terraform.io/api/v2/organizations/hashicorp/registry-modules/private/hashicorp/lb-http/google/11.0.0 |
| 106 | +``` |
| 107 | + |
| 108 | +### Sample Response |
| 109 | + |
| 110 | +```json |
| 111 | +{ |
| 112 | + "data": { |
| 113 | + "type": "module-versions", |
| 114 | + "id": "1", |
| 115 | + "relationships": { |
| 116 | + "deprecation": { |
| 117 | + "data": { |
| 118 | + "id": "2", |
| 119 | + "type": "deprecations" |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + }, |
| 124 | + "included": [ |
| 125 | + { |
| 126 | + "type": "deprecations", |
| 127 | + "id": "2", |
| 128 | + "attributes": { |
| 129 | + "link": "https://www.hashicorp.com/", |
| 130 | + "reason": "Deprecated due to a security vulnerability issue. Applies will be blocked in 15 days." |
| 131 | + } |
| 132 | + } |
| 133 | + ] |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | + |
| 138 | +## Revert the deprecation status for a module version |
| 139 | + |
| 140 | +Use this endpoint to revert the deprecation of a module version. |
| 141 | + |
| 142 | +`PATCH /api/v2/organizations/:organization_name/registry-modules/private/:organization_name/:module_name/:module_provider/:module_version` |
| 143 | + |
| 144 | +| Parameter | Description | |
| 145 | +| :---- | :---- | |
| 146 | +| `:organization_name` | The name of the organization the module belongs to. | |
| 147 | +| `:module_name` | The name of the module you want to revert the deprecation of. | |
| 148 | +| `:module_provider` | Specifies the Terraform provider that this module is used for. | |
| 149 | +| `:module_version` | The module version you want to revert the deprecation of. | |
| 150 | + |
| 151 | +Deprecating a module version adds warnings to the run output of any consumers using this module. Reverting the deprecation status removes warnings from the output of consumers and fully reinstates the module version. |
| 152 | + |
| 153 | +| Status | Response | Reason | |
| 154 | +| :---- | :---- | :---- | |
| 155 | +| [200](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) | [JSON API document](http:///terraform/cloud-docs/api-docs#json-api-documents) | Successfully reverted a module version’s deprecation status and reinstated that version. | |
| 156 | +| [404](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404) | [JSON API error object](http://jsonapi.org/format/#error-objects) | This organization is not authorized to revert the depreciation of this module version, or the module version does not exist. | |
| 157 | +| [422](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422) | [JSON API error object](http://jsonapi.org/format/#error-objects) | Malformed request body, for example the request is missing attributes or uses the wrong types. | |
| 158 | +| [500](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) or [503] | [JSON API error object](http://jsonapi.org/format/#error-objects) | Failure occurred while reverting the deprecation of a module version. | |
| 159 | + |
| 160 | +### **Sample Request** |
| 161 | + |
| 162 | +```shell |
| 163 | +curl \ |
| 164 | + --header "Authorization: Bearer $TOKEN" \ |
| 165 | + --header "Content-Type: application/vnd.api+json" \ |
| 166 | + --request PATCH \ |
| 167 | + --data @payload.json \ |
| 168 | +https://app.terraform.io/api/v2/organizations/hashicorp/registry-modules/private/hashicorp/lb-http/google/11.0.0 |
| 169 | +``` |
| 170 | + |
| 171 | +**Sample payload** |
| 172 | + |
| 173 | +```json |
| 174 | +{ |
| 175 | + "data": { |
| 176 | + "type": "module-versions", |
| 177 | + "attributes": { |
| 178 | + "deprecation": { |
| 179 | + "deprecated-status": "Undeprecated" |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | +} |
| 184 | +``` |
| 185 | + |
| 186 | +### Sample Response |
| 187 | + |
| 188 | +```json |
| 189 | +{ |
| 190 | + "data": { |
| 191 | + "type": "module-versions", |
| 192 | + "id": "1" |
| 193 | + } |
| 194 | +} |
| 195 | +``` |
0 commit comments