# Module

This endpoint is used to create, update, search or delete module information inside a Terrakube organization.

{% hint style="warning" %}
To use this endpoint you should have "manageModule" access at team level and a Terrakube organization
{% endhint %}

### Entity fields:

| Path                             | Type    | Description                                    |
| -------------------------------- | ------- | ---------------------------------------------- |
| data.type                        | string  | Should be "workspace"                          |
| data.attributes.name             | string  | Unique workspace for an Terrakube organization |
| data.attributes.branch           | boolean | Git branch to be used                          |
| data.attributes.source           | boolean | Git repository to be used                      |
| data.attributes.terraformVersion | boolean | Terraform version to run the workspace         |
| data.relationships.vcs.data.type | string  | Should be "vcs" (OPTIONAL)                     |
| data.relationships.vcs.data.type | string  | Should be the VCS Connection Id (OPTIONAL)     |

### Example:

```
{
  "data": {
    "type": "module",
    "attributes": {
      "name": "Terrakube module",
      "description": "Module Description",
      "provider": "Terraform Provider",
      "source": "https://github.com/AzBuilder/terraform-sample-repository.git"
    },
        "relationships": {
            "vcs": {
                "data": {
                    "type": "vcs",
                    "id": "{{vcsId}}"
                }
            }
        }
  }
}
```

### Supported Operations

## GET /organization/{organizationId}/module/{moduleId}

> Returns an instance of type module

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"module"}],"servers":[{"url":"/api/v1"}],"paths":{"/organization/{organizationId}/module/{moduleId}":{"get":{"tags":["module"],"description":"Returns an instance of type module","parameters":[{"name":"fields[module]","in":"query","description":"Selects the set of module fields that should be returned in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["createdBy","createdDate","description","downloadQuantity","folder","latestVersion","name","provider","registryPath","source","tagPrefix","updatedBy","updatedDate","organization","ssh","vcs","version"]}}},{"name":"include","in":"query","description":"Selects the set of relationships that should be expanded as a compound document in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["organization","ssh","vcs","version"]}}}],"responses":{"200":{"description":"Successful response","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/module"},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}}}}}},"components":{"schemas":{"module":{"type":"object","properties":{"type":{"type":"string","description":"Create Permissions : (team manage module)\nDelete Permissions : (team manage module)"},"id":{"type":"string"},"attributes":{"type":"object","properties":{"createdBy":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"createdDate":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"description":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"downloadQuantity":{"type":"integer","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","format":"int32","readOnly":false,"writeOnly":false},"folder":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"latestVersion":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"name":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"provider":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"registryPath":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"source":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"tagPrefix":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"updatedBy":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false},"updatedDate":{"type":"string","description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false}}},"relationships":{"type":"object","properties":{"organization":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["organization"]},"id":{"type":"string"}},"description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false}}}},"ssh":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["ssh"]},"id":{"type":"string"}},"description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false}}}},"vcs":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["vcs"]},"id":{"type":"string"}},"description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false}}}},"version":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["module_version"]},"id":{"type":"string"}},"description":"Read Permissions : (team view module)\nUpdate Permissions : (team manage module OR user is a super service)","readOnly":false,"writeOnly":false}}}}}}}}}}}
```

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/azb-server/main/openapi-spec/v1_3.yml>" path="/organization/{organizationId}/module" method="post" %}
<https://raw.githubusercontent.com/AzBuilder/azb-server/main/openapi-spec/v1_3.yml>
{% endopenapi %}

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/azb-server/main/openapi-spec/v1_3.yml>" path="/organization/{organizationId}/module/{moduleId}" method="delete" %}
<https://raw.githubusercontent.com/AzBuilder/azb-server/main/openapi-spec/v1_3.yml>
{% endopenapi %}

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/azb-server/main/openapi-spec/v1_3.yml>" path="/organization/{organizationId}/module/{moduleId}" method="patch" %}
<https://raw.githubusercontent.com/AzBuilder/azb-server/main/openapi-spec/v1_3.yml>
{% endopenapi %}

{% hint style="info" %}
For a complete list of organization operation please visit the [OpenAPI specification](https://github.com/AzBuilder/terrakube-server/tree/main/openapi-spec)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.terrakube.io/api/methods/module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
