> For the complete documentation index, see [llms.txt](https://docs.go-atlassian.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.go-atlassian.io/jira-software-cloud/issues/metadata.md).

# Metadata

## Get create metadata issue types for a project

`GET /rest/api/{2-3}/issue/createmeta/{projectIdOrKey}/issuetypes`

**FetchIssueMappings** returns a page of issue type metadata for a specified project. Use the information to populate the requests in [Create issue](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post) and [Create issues](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulk-post). This operation can be accessed anonymously.

#### &#x20;<a href="#api-rest-api-3-issue-createmeta-projectidorkey-issuetypes-get" id="api-rest-api-3-issue-createmeta-projectidorkey-issuetypes-get"></a>

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"fmt"
	"github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
)

func main() {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		return
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	issueTypeMappings, response, err := atlassian.Issue.Metadata.FetchIssueMappings(context.Background(), "KP", 0, 50)
	if err != nil {
		log.Println(response.Bytes.String())
		log.Fatal(err)
	}

	fmt.Println(response.Endpoint)

	for _, issueType := range issueTypeMappings.Get("issueTypes").Array() {

		/*
			{
			      "description": "An error in the code",
			      "iconUrl": "https://your-domain.atlassian.net/images/icons/issuetypes/bug.png",
			      "id": "1",
			      "name": "Bug",
			      "self": "https://your-domain.atlassian.net/rest/api/3/issueType/1",
			      "subtask": false
			    }
		*/
		fmt.Println(issueType.Get("description").String())
		fmt.Println(issueType.Get("iconUrl").String())
		fmt.Println(issueType.Get("id").String())
		fmt.Println(issueType.Get("name").String())
		fmt.Println(issueType.Get("self").String())
		fmt.Println(issueType.Get("subtask").Bool())
		fmt.Println("------------")

	}
}
```

{% endcode %}

## Get create field metadata for a project and issue type id

`GET /rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}`

\
Returns a page of field metadata for a specified project and issuetype id. Use the information to populate the requests in [Create issue](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post) and [Create issues](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulk-post). This operation can be accessed anonymously.

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"fmt"
	"github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
)

func main() {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		return
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	fieldsMappings, response, err := atlassian.Issue.Metadata.FetchFieldMappings(context.Background(), "KP", "10001", 0, 50)
	if err != nil {
		log.Println(response.Bytes.String())
		log.Fatal(err)
	}

	fmt.Println(response.Endpoint)
	for _, fieldSchema := range fieldsMappings.Get("fields").Array() {

		fmt.Println("fieldId", fieldSchema.Get("fieldId"))
		fmt.Println("required", fieldSchema.Get("required"))
		fmt.Println("name", fieldSchema.Get("name"))
		fmt.Println("key", fieldSchema.Get("key"))
		fmt.Println("autoCompleteUrl", fieldSchema.Get("autoCompleteUrl"))
		fmt.Println("hasDefaultValue", fieldSchema.Get("hasDefaultValue"))
		fmt.Println("operations", fieldSchema.Get("operations").String())

		fmt.Println("schema.type", fieldSchema.Get("schema.type"))
		fmt.Println("schema.system", fieldSchema.Get("schema.system"))
		fmt.Println("schema.items", fieldSchema.Get("schema.items"))

		fmt.Println("------------")
	}

}
```

{% endcode %}

## Get Edit Issue Metadata

`GET /rest/api/{2-3}/issue/{issueIdOrKey}/editmeta`

Returns the edit screen fields for an issue that are visible to and editable by the user. Use the information to populate the requests in [Edit issue](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put).

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"fmt"
	v2 "github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
	"os"
)

func main() {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	metadata, response, err := atlassian.Issue.Metadata.Get(context.Background(), "KP-1", false, false)
	if err != nil {
		log.Fatal(err)
	}
	log.Println("HTTP Endpoint Used", response.Endpoint)


	fields, response, err := atlassian.Issue.Field.Gets(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	log.Println("HTTP Endpoint Used", response.Endpoint)

	for _, field := range fields {

		path := fmt.Sprintf("fields.%v.required", field.ID)
		value := metadata.Get(path)

		if value.Exists() {
			fmt.Println("Field Name:", field.Name, "Required?:", value.String())
		}
	}
}
```

{% endcode %}

## Get Create Issue Metadata

`GET /rest/api/{2-3}/issue/createmeta`

Returns details of projects, issue types within projects, and, when requested, the create screen fields for each issue type for the user. Use the information to populate the requests in [Create issue](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-post) and [Create issues](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-bulk-post).

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"fmt"
	v2 "github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"github.com/ctreminiom/go-atlassian/pkg/infra/models"
	"log"
	"os"
)

func main() {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	options := &models.IssueMetadataCreateOptions{
		ProjectIDs:     nil,
		ProjectKeys:    []string{"KP"},
		IssueTypeIDs:   nil,
		IssueTypeNames: nil,
		Expand:         "",
	}

	metadata, response, err := atlassian.Issue.Metadata.Create(context.Background(), options)
	if err != nil {
		log.Fatal(err)
	}
	log.Println("HTTP Endpoint Used", response.Endpoint)

	fmt.Println(metadata)
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.go-atlassian.io/jira-software-cloud/issues/metadata.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
