Support Log in
All Features of Field Forge

REST API — Expose Custom Fields to Headless Apps

Field Forge provides a full REST API for custom fields. Field values of the fields that opt in are exposed on standard WordPress REST endpoints (so /wp-json/wp/v2/posts/123 returns them in a fieldforge property next to the core data), plus dedicated Field Forge endpoints for field groups, field values, options pages, ACF import and AI generation. Authentication uses WordPress’s existing REST API auth.


Two ways to access custom fields

1. Inline on core REST endpoints

When Field Forge is active, every wp/v2/posts, wp/v2/pages, and wp/v2/{custom_post_type} response includes a fieldforge property. A field appears in it only when its definition has show_in_rest set or a site allows it with the filter fieldforge/rest/public_field_allowed; the field group editor has no input for show_in_rest. Password fields never appear, and a field whose name contains words such as password, secret, token or api key also needs the filter fieldforge/rest/public_sensitive_field_allowed. With such fields the property looks like this:

GET /wp-json/wp/v2/posts/123

{
  "id": 123,
  "title": { "rendered": "About Us" },
  "content": { "rendered": "..." },
  "fieldforge": {
    "hero_title": "Welcome to Our Site",
    "hero_subtitle": "Building better WordPress experiences",
    "hero_image": {
      "ID": 456,
      "url": "https://example.com/hero.jpg",
      "width": 1600,
      "height": 900,
      "alt": "Hero image",
      "title": "hero"
    },
    "team_members": [
      {
        "name": "Alice Johnson",
        "photo": { "ID": 234, "url": "...", "width": 800, "height": 800, "alt": "Alice", "title": "alice" },
        "bio": "Alice is..."
      },
      {
        "name": "Bob Smith",
        "photo": { "ID": 235, "url": "...", "width": 800, "height": 800, "alt": "Bob", "title": "bob" },
        "bio": "Bob is..."
      }
    ]
  }
}

A request for a post returns its custom fields in the same response, with no extra requests.

2. Dedicated Field Forge endpoints

For advanced use cases, Field Forge exposes its own REST API under /wp-json/fieldforge/v1/.


Endpoint reference

Field groups

GET    /wp-json/fieldforge/v1/field-groups
GET    /wp-json/fieldforge/v1/field-groups/{id}
POST   /wp-json/fieldforge/v1/field-groups
PUT    /wp-json/fieldforge/v1/field-groups/{id}
DELETE /wp-json/fieldforge/v1/field-groups/{id}

List, read, create, update, and delete field groups. Use cases: headless admin panels, programmatic field group setup, CI/CD schema deployment. The two GET routes need manage_options by default; the filter fieldforge/rest/read_groups_permission can widen that check, for example for a headless frontend. Creating, updating and deleting always need manage_options.

Field values

GET    /wp-json/fieldforge/v1/fields/{post_id}
PUT    /wp-json/fieldforge/v1/fields/{post_id}

Get the field values of a specific post, or update them. GET needs a logged-in user who can read the post (read_post); PUT needs manage_options. The GET response is an object that maps each field name to its value. A PUT with a Text or Textarea value that is longer than the character limit of its field answers 400 (rest_invalid_param) and saves nothing from that request.

Example:

{
  "hero_title": "Welcome",
  "hero_subtitle": "Building better WordPress experiences"
}

Options pages

GET    /wp-json/fieldforge/v1/options/{page_slug}

Read the values of an options page. It needs manage_options, and there is no PUT for option values. The options pages themselves are managed with GET and POST on /options-pages and GET, PUT and DELETE on /options-pages/{id}, all with manage_options.

Aggregate

GET    /wp-json/fieldforge/v1/aggregate

Returns one number computed over the posts of a post type. The field parameter names the field and is required. The optional parameters are post_type (default post), status (default publish) and op (sum by default, or avg, min, max, count). The response has field, post_type, status, op, value and formatted. The formatted text can be shaped with the optional parameters format (number by default, currency or percentage), decimals (2 by default), symbol, symbol_position (prefix by default, or suffix), thousands_sep (, by default) and decimal_sep (. by default).

Field Forge has no REST route that returns the whole schema, TypeScript definitions or GraphQL SDL. GET /field-groups returns the field group definitions as JSON.

Migration and import

POST   /wp-json/fieldforge/v1/import/acf

Imports the ACF field groups of the site into Field Forge. The route imports field groups only, not field values, and it needs a user with the manage_options capability.

AI generation

POST   /wp-json/fieldforge/v1/generate

Body:

{
  "prompt": "Hero section with title, subtitle, background image, and CTA button"
}

Returns the generated groups and a message as JSON. The route does not save anything: to keep a group, create it with the field-groups routes above. Like the Generate button on the Tools screen, it answers a description that matches a built-in template with that template and asks the AI only when no template matches. Use in custom admin tools or automation workflows.


Authentication

Field Forge’s REST API uses WordPress’s native authentication mechanisms:

Cookie authentication (logged-in users)

If the request comes from a logged-in WordPress user (e.g., your admin panel making AJAX calls), the user’s cookies authenticate the request automatically.

Application passwords (headless frontends)

WordPress 5.6+ supports application passwords — per-user API credentials that can be generated in the WordPress admin under Users → Edit → Application Passwords. Use these for headless frontend authentication:

curl -u username:application_password https://wp.example.com/wp-json/fieldforge/v1/field-groups

JWT authentication (third-party plugin)

If you use a JWT auth plugin (like “JWT Authentication for WP REST API”), Field Forge’s endpoints use the current user that the authentication plugin sets.


Capability checks

REST endpoints respect WordPress capabilities:

  • GET /field-groups and GET /field-groups/{id}: manage_options by default, widened with the filter fieldforge/rest/read_groups_permission
  • GET /aggregate: manage_options by default, widened with the filter fieldforge/rest/aggregate_permission
  • GET /fields/{post_id}: a logged-in user who can read that post (read_post); anonymous requests are refused
  • GET /options/{page}: manage_options
  • Everything that writes (field groups, PUT /fields/{post_id}, options pages), POST /import/acf and POST /generate: manage_options (administrators only)

The two filters change the check for the field group reads and for the aggregate. The other routes have fixed checks.


Field values on WP REST API

Field Forge exposes field values on core WordPress REST endpoints as a fieldforge property. This is the recommended approach for headless frontends because:

  • One request fetches post data + custom fields
  • Standard REST API format

For a headless site that only reads values, the fieldforge property on core REST endpoints can be enough. Dedicated Field Forge endpoints are for advanced use cases.


How REST reads work

The fieldforge property reads values through the same per-post cache as get_field(): the first read of a post runs one query for its top-level values, and the entry stays in the object cache for 300 seconds. A list endpoint such as /wp/v2/posts?per_page=20 costs one such query per post; Field Forge does not batch them across posts.


Combining with GraphQL

Field Forge supports both REST API and WPGraphQL integration. Use whichever fits your frontend:

  • REST API: works with any HTTP client
  • GraphQL: one query can ask for deeply nested data; typed when combined with GraphQL Code Generator

Both APIs expose the same underlying Field Forge data.


Ready to go headless with WordPress custom fields?

See pricing →

The REST API is in the free version too: field values on core REST endpoints, plus the dedicated endpoints for field groups and field values. AI generation, Options Pages and the values of PRO field types need a paid plan.

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs