Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions content/guides/04.connect/3.query-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ Saves the API response to a file. Valid values are `csv`, `json`, `xml`, `yaml`.

## Version

Queries a version of a record by version key when [content versioning](/guides/content/content-versioning) is enabled on a collection. Applies only to single item retrieval.
Queries a version of a record by version key when [content versioning](/guides/content/content-versioning) is enabled on a collection.

::callout{icon="material-symbols:info-outline"}
**Reserved version keys**
Expand All @@ -570,11 +570,18 @@ The keys `published` and `draft` are reserved. Use `published` (or `main` for ba

::code-group

```http [GET /items/posts/1]
?version=v1
```http
GET /items/posts?version=v1
GET /items/posts/1?version=v1
```

```graphql [GraphQL]
query {
posts(version: "v1") {
id
}
}

query {
posts_by_id(id: 1, version: "v1") {
id
Expand All @@ -587,23 +594,30 @@ import { createDirectus, rest, readItem } from "@directus/sdk";
const directus = createDirectus("https://directus.example.com").with(rest());

const result = await directus.request(
readItem("posts", {
readItems("posts", {
version: "v1",
}),
);

const item = await directus.request(
readItem("posts", 1, {
version: "v1",
}),
);
```

### Version Meta

When retrieving a versioned item, an additional `$meta` field is included in the response, containing metadata such as the version key and possibly an error message if the version failed to apply.

::

## VersionRaw

Specifies to return relational delta changes as a [detailed output](https://directus.io/docs/guides/connect/relations#creating-updating-deleting) on a version record.
Specifies to return relational delta changes as a [detailed output](https://directus.io/docs/guides/connect/relations#creating-updating-deleting) on a version record. Applies only to single item retrieval.

::code-group

```http [REST]
GET /items/posts/1
?version=v1&versionRaw=true
```http [GET /items/posts/1]
?version=v1&versionRaw=true
```

```graphql [GraphQL]
Expand Down
Loading