Design System is here - Read the release post

Learn GeneratePress

Developers

REST API

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:

NamespacePluginUsed for
generateblocks/v1GenerateBlocksQueries, dynamic tags, meta, settings, the pattern library
generateblocks-pro/v1GenerateBlocks ProForms, Global Styles, the pattern library, the Asset Library, integrations and licence settings
generateblocks-pro/advanced-conditions/v1GenerateBlocks ProConditions
generateblocks-pro/editor-access/v1GenerateBlocks ProAccess profiles and control sets
generateblocks-pro/overlays/v1GenerateBlocks ProOverlay Panels
generateblocks-pro/design-tokens/v1GenerateBlocks ProDesign 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.

Back to top

Query data

GB Free

These routes return the items the editor previews in a Query block. Both need the edit_posts capability.

RouteMethodDescription
/generateblocks/v1/get-wp-queryPOSTRuns 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-queryPOSTRuns 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

Back to top

Dynamic tags and meta

GB Free

RouteMethodCapabilityDescription
/generateblocks/v1/dynamic-tag-replacementsPOSTedit_postsResolves 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-recordGETCan author dynamic dataReturns a post for tags. Parameters: postId (required), load (what to include: post, comments, terms) and options.
/generateblocks/v1/get-user-recordGETCan author dynamic dataReturns a user for tags. Parameter: id.
/generateblocks/v1/meta/get-post-metaGETCan author dynamic dataReturns post meta. Parameters: id and key.
/generateblocks/v1/meta/get-user-metaGETCan author dynamic dataReturns user meta. Parameters: id and key.
/generateblocks/v1/meta/get-term-metaGETCan author dynamic dataReturns term meta. Parameters: id and key.
/generateblocks/v1/meta/get-optionGETedit_posts, and can author dynamic dataReturns 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

Back to top

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.

RouteMethodDescription
/generateblocks/v1/pattern-library/librariesGETLists the libraries.
/generateblocks/v1/pattern-library/categoriesGETLists the categories of a library. Parameter: libraryId.
/generateblocks/v1/pattern-library/patternsGETLists 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

Back to top

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.

RouteMethodDescription
/generateblocks-pro/v1/forms/securityGETIssues the security token for a form. Parameters: formId and postId.
/generateblocks-pro/v1/forms/submitPOSTReceives 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

Back to top

All other routes

These routes support the dashboards and editor panels. They aren’t documented in detail here.

NamespaceRoute groups
generateblocks/v1settings, setting, onboarding, get-attachment-by-url
generateblocks-pro/v1styles 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/v1conditions, 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/v1access-profiles, control-sets
generateblocks-pro/overlays/v1overlays, get_modal_categories, manage_category
generateblocks-pro/design-tokens/v1usages

Their capabilities follow the filters on each feature’s page: conditions, Editor Access, overlays, Global Styles and forms.

Back to top