From 9964f4cecba59df0fc646b74b74554ecc19f9ada Mon Sep 17 00:00:00 2001 From: Michael Withagen <3629094+michaelw85@users.noreply.github.com> Date: Mon, 27 Jul 2026 15:29:12 +0200 Subject: [PATCH] Update adding-custom-endpoints.md Add the list of allowed arguments for custom rest api's --- .../adding-custom-endpoints.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/extending-the-rest-api/adding-custom-endpoints.md b/extending-the-rest-api/adding-custom-endpoints.md index 7ac3542..a34a24c 100644 --- a/extending-the-rest-api/adding-custom-endpoints.md +++ b/extending-the-rest-api/adding-custom-endpoints.md @@ -123,6 +123,33 @@ Arguments are defined as a map in the key `args` for each endpoint (next to your * `validate_callback`: Used to pass a function that will be passed the value of the argument. That function should return true if the value is valid, and false if not. * `sanitize_callback`: Used to pass a function that is used to sanitize the value of the argument before passing it to the main callback. +Other allowed options are: +* `title` +* `description` +* `default` +* `type` +* `format` +* `enum` +* `items` +* `properties` +* `additionalProperties` +* `patternProperties` +* `minProperties` +* `maxProperties` +* `minimum` +* `maximum` +* `exclusiveMinimum` +* `exclusiveMaximum` +* `multipleOf` +* `minLength` +* `maxLength` +* `pattern` +* `minItems` +* `maxItems` +* `uniqueItems` +* `anyOf` +* `oneOf` + Using `sanitize_callback` and `validate_callback` allows the main callback to act only to process the request, and prepare data to be returned using the `WP_REST_Response` class. By using these two callbacks, you will be able to safely assume your inputs are valid and safe when processing. Taking our previous example, we can ensure the parameter passed in is always a number: