GenerateBlocks registers REST API routes that the block editor and its dashboards use. This page covers the routes a developer is most likely to call or build on, then lists the rest by namespace. Most routes are for the editor, and they all check the current user’s permissions.
Jump to
How the routes work
The namespaces are:
| Namespace | Plugin | Used for |
|---|---|---|
generateblocks/v1 | GenerateBlocks | Queries, dynamic tags, meta, settings, the pattern library |
generateblocks-pro/v1 | GenerateBlocks Pro | Forms, Global Styles, the pattern library, the Asset Library, integrations and licence settings |
generateblocks-pro/advanced-conditions/v1 | GenerateBlocks Pro | Conditions |
generateblocks-pro/editor-access/v1 | GenerateBlocks Pro | Access profiles and control sets |
generateblocks-pro/overlays/v1 | GenerateBlocks Pro | Overlay Panels |
generateblocks-pro/design-tokens/v1 | GenerateBlocks Pro | Design Token usage |
To call a route from JavaScript in the editor, use wp.apiFetch( { path: '/generateblocks/v1/...' } ). From outside the editor, send the REST nonce in an X-WP-Nonce header with a logged in session. Every route checks a capability. Whether the capability can change is up to the plugin, so see the filters named below.
Query data
GB Free
These routes return the items the editor previews in a Query block. Both need the edit_posts capability.
| Route | Method | Description |
|---|---|---|
/generateblocks/v1/get-wp-query | POST | Runs a post query and returns the posts. Parameters: args (the query arguments), attributes, context, queryType, block, postId and authorId. The page parameter sets the page. The number of posts returned is capped by generateblocks_query_loop_editor_posts_cap. |
/generateblocks/v1/get-user-query | POST | Runs a user query. args.number is limited to 150. |
The arguments for get-wp-query pass through generateblocks_rest_get_wp_query_args.
Related: generateblocks_query_wp_query_args Guide: Display Posts with the Query Block
Dynamic tags and meta
GB Free
| Route | Method | Capability | Description |
|---|---|---|---|
/generateblocks/v1/dynamic-tag-replacements | POST | edit_posts | Resolves the dynamic tags in content for the editor preview. Parameters: content, context and clientId. Results are cached for users who can author dynamic data. |
/generateblocks/v1/post-record | GET | Can author dynamic data | Returns a post for tags. Parameters: postId (required), load (what to include: post, comments, terms) and options. |
/generateblocks/v1/get-user-record | GET | Can author dynamic data | Returns a user for tags. Parameter: id. |
/generateblocks/v1/meta/get-post-meta | GET | Can author dynamic data | Returns post meta. Parameters: id and key. |
/generateblocks/v1/meta/get-user-meta | GET | Can author dynamic data | Returns user meta. Parameters: id and key. |
/generateblocks/v1/meta/get-term-meta | GET | Can author dynamic data | Returns term meta. Parameters: id and key. |
/generateblocks/v1/meta/get-option | GET | edit_posts, and can author dynamic data | Returns an option. Parameters: key and singleOnly. Users who can’t manage options can only read the keys in generateblocks_allowed_option_keys_rest_api. |
“Can author dynamic data” is decided by generateblocks_user_can_author_dynamic_data. The post and user record responses pass through generateblocks_dynamic_tags_post_record_response and generateblocks_dynamic_tags_user_record_response.
GenerateBlocks Pro adds /generateblocks-pro/v1/get-acf-option-fields for Advanced Custom Fields options.
Related: generateblocks_get_meta_value Guide: Dynamic Tags
Pattern library
GB Free — GenerateBlocks Pro adds routes under its own namespace.
The pattern library routes feed the library panel in the editor. The read routes check generateblocks_can_view_pattern_library.
| Route | Method | Description |
|---|---|---|
/generateblocks/v1/pattern-library/libraries | GET | Lists the libraries. |
/generateblocks/v1/pattern-library/categories | GET | Lists the categories of a library. Parameter: libraryId. |
/generateblocks/v1/pattern-library/patterns | GET | Lists the patterns of a library. Parameters: libraryId, categoryId and search. |
Saving libraries needs the manage_options capability, and clearing the cache needs edit_posts.
Related: generateblocks_pattern_libraries Guide: Pattern Library
Forms
GB Pro
The Form block’s script uses two routes that visitors can reach, so they don’t need a login. A submission needs a security token, which the first route issues. The routes are meant for the Form block itself. To change what happens to a submission, use the hooks in Forms: processing and validation.
| Route | Method | Description |
|---|---|---|
/generateblocks-pro/v1/forms/security | GET | Issues the security token for a form. Parameters: formId and postId. |
/generateblocks-pro/v1/forms/submit | POST | Receives a submission. Parameters: formId, postId and the field values. |
The other form routes, under /generateblocks-pro/v1/admin/forms/ and /generateblocks-pro/v1/integrations/, need the capability to manage forms.
Related: generateblocks_form_verify_submission Guide: Forms
All other routes
These routes support the dashboards and editor panels. They aren’t documented in detail here.
| Namespace | Route groups |
|---|---|
generateblocks/v1 | settings, setting, onboarding, get-attachment-by-url |
generateblocks-pro/v1 | styles and global-classes (Global Styles), global-styles, template-library, get_templates, get_template_data, sync_template_library, export-asset-group, icon-settings, shape-settings, license, pattern-library, admin and integrations (forms) |
generateblocks-pro/advanced-conditions/v1 | conditions, get_condition_types, get_condition_rules, get_condition_operators, get_condition_categories, get_rule_metadata, manage_category, validate_conditions, batch_object_titles and the search_* routes |
generateblocks-pro/editor-access/v1 | access-profiles, control-sets |
generateblocks-pro/overlays/v1 | overlays, get_modal_categories, manage_category |
generateblocks-pro/design-tokens/v1 | usages |
Their capabilities follow the filters on each feature’s page: conditions, Editor Access, overlays, Global Styles and forms.