Files
directus/docs/reference/api/system/utilities.md
Rijk van Zanten 18b2fa99c6 API Reference 2.0 (#4916)
* Rework API reference to include GQL

* Almost done

* Finish API reference update

* Remove items nesting on gql in query params

* Update template examples to match

* Add link to files on assets overview
2021-04-08 15:34:31 -04:00

2.1 KiB

pageClass
pageClass
page-reference

Utilities

Utilities are the various helper endpoints located within the API.

toc


Generate a Hash

Generate a hash for a given string.

Request Body

string Required
String to hash.

Returns

Hashed string.

REST API

POST /utils/hash/generate
Example
// POST /utils/hash/generate

{
	"string": "Hello World!"
}

GraphQL

type Mutation {
	utils_hash_generate(string: String!): String
}
Example
mutation {
	utils_hash_generate(string: "Hello World!")
}

Verify a Hash

Verify a string with a hash.

Request Body

string Required
Source string.

hash Required
Hash you want to verify against.

Returns

Boolean.

REST API

POST /utils/hash/verify
Example
// POST /utils/hash/verify

{
	"string": "Hello World!",
	"hash": "$arg...fEfM"
}

GraphQL

type Mutation {
	utils_hash_verify(hash: String!, string: String!): Boolean
}

Manually Sort Items in Collection

If a collection has a sort field, this util can be used to move items in that manual order.

Request Body

item Required
Primary key of the item you're moving in the collection.

to Required
Primary key of the item you're moving the source item too.

Returns

Empty body.

REST API

POST /utils/sort/:collection
Example
// POST /utils/sort/articles

{
	"item": 16,
	"to": 51
}

GraphQL

type Mutation {
	utils_sort(collection: String!, item: ID!, to: ID!): Boolean
}
Example
mutation {
	utils_sort(collection: "articles", item: 16, to: 51)
}