Title: ACF_Rest_Api
Author: Brandon Kraft
Published: February 21, 2025

---

# ACF_Rest_Api

## In this article

 * [Properties](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#properties)
    - [$request](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#request)
    - [$embed_links](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#embed_links)
 * [Methods](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#methods)
    - [register_field](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#register_field)
    - [get_schema](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_schema)
    - [validate_rest_arg](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#validate_rest_arg)
    - [load_fields](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#load_fields)
    - [update_fields](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#update_fields)
    - [make_identifier](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#make_identifier)
    - [object_type_has_field_group](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#object_type_has_field_group)
    - [get_field_groups_by_object_type](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_field_groups_by_object_type)
    - [get_field_groups_by_id](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_field_groups_by_id)
    - [get_fields](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_fields)

[ Back to top](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#wp--skip-link--target)

## 󠀁[Properties](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#properties)󠁿

### 󠀁[$request](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#request)󠁿

 * @var ACF_Rest_Request

### 󠀁[$embed_links](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#embed_links)󠁿

 * @var ACF_Rest_Embed_Links

## 󠀁[Methods](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#methods)󠁿

### 󠀁[register_field](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#register_field)󠁿

Register our custom property as a REST field.

### 󠀁[get_schema](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_schema)󠁿

Dynamically generate the schema for the current request.

 * @return array

### 󠀁[validate_rest_arg](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#validate_rest_arg)󠁿

Validate the request args. Mostly a wrapper for `rest_validate_request_arg()`, but
also
 fires off a filter, so we can add some custom validation for specific fields.

 * This will likely no longer be needed once WordPress implements something like`
   validate_callback`
    and `sanitize_callback` for nested schema properties, see:
   [https://core.trac.wordpress.org/ticket/49960](https://core.trac.wordpress.org/ticket/49960)
 * @param mixed $value
 * @param \[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)
   $request
 * @param string $param
 * @return boolean|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

### 󠀁[load_fields](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#load_fields)󠁿

Load field values into the requested object. This method is not a part of any public
API and is only public as
 it is required by WordPress.

 * @param array $object An array representation of the post, term, or user object.
 * @param string $field_name
 * @param [WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)
   $request
 * @param string $object_sub_type Note that this isn’t the same as $this->object_type.
   This variable is
    more specific and can be a post type or taxonomy.
 * @return array

### 󠀁[update_fields](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#update_fields)󠁿

Update any incoming field values for the given object. This method is not a part
of any public API and is only
 public as it is required by WordPress.

 * @param array $data
 * @param [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)|
   [WP_Term](https://developer.wordpress.org/reference/classes/wp_term/)|[WP_User](https://developer.wordpress.org/reference/classes/wp_user/)
   $object
 * @param string $property ‘acf’
 * @param [WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)
   $request
 * @param string $object_sub_type This will be the post type, the taxonomy, or ‘
   user’.
 * @return boolean|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

### 󠀁[make_identifier](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#make_identifier)󠁿

Make the ACF identifier string for the given object.

 * @param integer $object_id
 * @param string $object_type ‘user’, ‘term’, or ‘post’
 * @return string

### 󠀁[object_type_has_field_group](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#object_type_has_field_group)󠁿

Gets an array of the location types that a field group is configured to use.

 * @param string $object_type ‘user’, ‘term’, or ‘post’
 * @param array $field_group The field group to check.
 * @param array $location_types An array of location types.
 * @return boolean

### 󠀁[get_field_groups_by_object_type](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_field_groups_by_object_type)󠁿

Get all field groups for the provided object type.

 * @param string $object_type ‘user’, ‘term’, or ‘post’
 * @return array An array of field groups that display for that location type.

### 󠀁[get_field_groups_by_id](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_field_groups_by_id)󠁿

Get all field groups for a given object.

 * @param integer $object_id
 * @param string $object_type ‘user’, ‘term’, or ‘post’
 * @param string|null $object_sub_type The post type or taxonomy. When an $object_type
   of ‘user’ is in play, this can be ignored.
 * @param array $scope Field group keys to limit the returned set of field groups
   to. This is used to scope field lookups to specific groups.
 * @return array An array of matching field groups.

### 󠀁[get_fields](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/?output_format=md#get_fields)󠁿

Get all ACF fields for a given field group and allow third party filtering.

 * @param array $field_group This could technically be other possible values supported
   by acf_get_fields() but in this
    context, we’re only using the field group arrays.
 * @param null|integer $object_id The ID of the object being prepared.
 * @return array

First published

February 21, 2025

Last updated

February 21, 2025

Edit article

[ Improve it on GitHub: ACF_Rest_Api ](https://github.com/wordpress/secure-custom-fields/edit/trunk/docs/code-reference/rest-api/class-acf-rest-api-file.md)

Changelog

[ See list of changes: ACF_Rest_Api ](https://github.com/wordpress/secure-custom-fields/commits/trunk/docs/code-reference/rest-api/class-acf-rest-api-file.md)

[  Previous: Acf Wp Functions Global Functions](https://developer.wordpress.org/secure-custom-fields/code-reference/acf-wp-functions-file/)

[  Next: Acf Rest API Functions Global Functions](https://developer.wordpress.org/secure-custom-fields/code-reference/class-acf-rest-api-file/acf-rest-api-functions-file/)