> 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/confluence-cloud/content/versions.md).

# Versions

## Get content versions

`GET /wiki/rest/api/content/{id}/version`

{% hint style="info" %}
Deprecated, use [Confluence's v2 API](/confluence-cloud/v2.md).
{% endhint %}

Returns the versions for a piece of content in descending order.

{% code fullWidth="true" %}

```go
package main

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

func main() {

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

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

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

	var (
		ctx       = context.Background()
		contentID = "80412692"
		expand    = []string{"collaborators", "content"}
		start     = 0
		limit     = 50
	)

	versions, response, err := instance.Content.Version.Gets(ctx, contentID, expand, start, limit)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	for _, version := range versions.Results {
		fmt.Println(version.Number, version.Content.Title, version.By.Email)
	}
}
```

{% endcode %}

## Restore content version

`POST /wiki/rest/api/content/{id}/version`

Restores a historical version to be the latest version. That is, a new version is created with the content of the historical version.

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"fmt"
	"github.com/ctreminiom/go-atlassian/confluence"
	"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")
	)

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

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

	ctx := context.Background()
	contentID := "80412692"
	expand := []string{"collaborators", "content"}

	payload := &models.ContentRestorePayloadScheme{
		OperationKey: "restore",
		Params: &models.ContentRestoreParamsPayloadScheme{
			VersionNumber: 1,
			Message:       "message sample :)",
			RestoreTitle:  true,
		},
	}

	version, response, err := instance.Content.Version.Restore(ctx, contentID, payload, expand)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	fmt.Println(version.Content.Title)
	fmt.Println(version.Content.ID)
	fmt.Println(version.By.Email)
	fmt.Println(version.By.Type)
	fmt.Println(version.By.AccountID)
	fmt.Println(version.Collaborators.UserKeys)
}
```

{% endcode %}

## Get content version

`GET /wiki/rest/api/content/{id}/version/{versionNumber}`

{% hint style="info" %}
Deprecated, use [Confluence's v2 API](/confluence-cloud/v2.md).
{% endhint %}

Returns a version for a piece of content.

{% code fullWidth="true" %}

```go
package main

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

func main() {

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

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

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

	var (
		ctx       = context.Background()
		contentID = "80412692"
		versionID = 1
		expand    = []string{"collaborators", "content"}
	)

	version, response, err := instance.Content.Version.Get(ctx, contentID, versionID, expand)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	fmt.Println(version.Content.Title)
	fmt.Println(version.Content.ID)
	fmt.Println(version.By.Email)
	fmt.Println(version.By.Type)
	fmt.Println(version.By.AccountID)
	fmt.Println(version.Collaborators.UserKeys)
}
```

{% endcode %}

## Delete content version

`DELETE /wiki/rest/api/content/{id}/version/{versionNumber}`

Delete a historical version. This does not delete the changes made to the content in that version, rather the changes for the deleted version are rolled up into the next version. Note, you cannot delete the current version.

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"github.com/ctreminiom/go-atlassian/confluence"
	"log"
	"os"
)

func main() {

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

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

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

	var (
		ctx           = context.Background()
		contentID     = "80412692"
		versionNumber = 2
	)

	response, err := instance.Content.Version.Delete(ctx, contentID, versionNumber)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}
}
```

{% 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/confluence-cloud/content/versions.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.
