# 🛡️ Audit records

The Jira audit logs are a set of records that document all the activities and changes made in Jira. These logs provide a detailed record of who did what, when, and where within Jira. Here are a few examples of the type of activities that are logged in the Jira audit logs:

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td>User login and logout events</td></tr><tr><td>Issue creation, modification, and deletion events</td></tr><tr><td>Workflow transition events</td></tr><tr><td>Project creation, modification, and deletion events</td></tr><tr><td>User management events such as user creation, modification, and deletion</td></tr><tr><td>User management events such as user creation, modification, and deletion</td></tr></tbody></table>

<figure><img src="/files/GDM2wKdMhaibSCumdngY" alt=""><figcaption></figcaption></figure>

The audit logs are useful for several reasons. For example, they can be used to track changes made to sensitive data, to identify who made specific changes to issues or projects, or to diagnose issues with Jira.

## Get audit records

`GET /rest/api/{2-3}/auditing/record`

This method allows you to retrieve the audit records for specific activities that have occurred within Jira.&#x20;

{% code fullWidth="true" %}

```go
package main

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

func main() {

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

	jira, err := v3.New(nil, host)
	if err != nil {
		return
	}

	jira.Auth.SetBasicAuth(mail, token)
	jira.Auth.SetUserAgent("curl/7.54.0")

	auditRecordOption := &models.AuditRecordGetOptions{

		//Filter the records by a word, in that case, the custom field history
		Filter: "",

		//Filter the records by the last month
		From: time.Now().AddDate(0, -1, 0),

		// Today
		To: time.Now(),
	}

	auditRecords, response, err := jira.Audit.Get(context.Background(), auditRecordOption, 0, 500)
	if err != nil {
		if response != nil {
			log.Println("Response HTTP Response", response.Bytes.String())
		}
		log.Fatal(err)
	}

	log.Println("Response HTTP Code", response.Code)
	log.Println("HTTP Endpoint Used", response.Endpoint)

	for _, record := range auditRecords.Records {

		log.Printf("Record ID: %v", record.ID)
		log.Printf("Record Category: %v", record.Category)
		log.Printf("Record Created: %v", record.Created)
		log.Printf("Record RemoteAddress: %v", record.RemoteAddress)
		log.Printf("Record Summary: %v", record.Summary)
		log.Printf("Record AuthorKey: %v", record.AuthorKey)
		log.Printf("\n")
	}
}
```

{% endcode %}


---

# 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.go-atlassian.io/jira-software-cloud/audit-records.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.
