Title: WP_REST_Pattern_Directory_Controller::get_item_schema
Published: July 20, 2021
Last modified: May 20, 2026

---

# WP_REST_Pattern_Directory_Controller::get_item_schema(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#wp--skip-link--target)

Retrieves the block pattern’s schema, conforming to JSON Schema.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#return)󠁿

 array Item schema data.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#source)󠁿

    ```php
    public function get_item_schema() {
    	if ( $this->schema ) {
    		return $this->add_additional_fields_schema( $this->schema );
    	}

    	$this->schema = array(
    		'$schema'    => 'http://json-schema.org/draft-04/schema#',
    		'title'      => 'pattern-directory-item',
    		'type'       => 'object',
    		'properties' => array(
    			'id'             => array(
    				'description' => __( 'The pattern ID.' ),
    				'type'        => 'integer',
    				'minimum'     => 1,
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'title'          => array(
    				'description' => __( 'The pattern title, in human readable format.' ),
    				'type'        => 'string',
    				'minLength'   => 1,
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'content'        => array(
    				'description' => __( 'The pattern content.' ),
    				'type'        => 'string',
    				'minLength'   => 1,
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'categories'     => array(
    				'description' => __( "The pattern's category slugs." ),
    				'type'        => 'array',
    				'uniqueItems' => true,
    				'items'       => array( 'type' => 'string' ),
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'keywords'       => array(
    				'description' => __( "The pattern's keywords." ),
    				'type'        => 'array',
    				'uniqueItems' => true,
    				'items'       => array( 'type' => 'string' ),
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'description'    => array(
    				'description' => __( 'A description of the pattern.' ),
    				'type'        => 'string',
    				'minLength'   => 1,
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'viewport_width' => array(
    				'description' => __( 'The preferred width of the viewport when previewing a pattern, in pixels.' ),
    				'type'        => 'integer',
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),

    			'block_types'    => array(
    				'description' => __( 'The block types which can use this pattern.' ),
    				'type'        => 'array',
    				'uniqueItems' => true,
    				'items'       => array( 'type' => 'string' ),
    				'context'     => array( 'view', 'embed' ),
    			),
    		),
    	);

    	return $this->add_additional_fields_schema( $this->schema );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php#L231)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php#L231-L302)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#related)󠁿

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_item_schema/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.2.0](https://developer.wordpress.org/reference/since/6.2.0/) | Added `'block_types'` to schema. | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_pattern_directory_controller%2Fget_item_schema%2F)
before being able to contribute a note or feedback.