Title: WP_REST_Attachments_Controller::get_endpoint_args_for_item_schema
Published: August 20, 2026

---

# WP_REST_Attachments_Controller::get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE ): array<string,

## In this article

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

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

Retrieves the query params for the attachments collection.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_endpoint_args_for_item_schema/?output_format=md#parameters)󠁿

 `$method`stringoptional

HTTP method of the request.
 The arguments for `CREATABLE` requests are checked 
for required values and may fall-back to a given default.

Default:`WP_REST_Server::CREATABLE`

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

 array<string, array<string, mixed>> Endpoint arguments.

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

    ```php
    public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
    	$args = parent::get_endpoint_args_for_item_schema( $method );

    	if ( WP_REST_Server::CREATABLE !== $method ) {
    		return $args;
    	}

    	$args['generate_sub_sizes'] = array(
    		'type'        => 'boolean',
    		'default'     => true,
    		'description' => __( 'Whether to generate image sub sizes.' ),
    	);

    	$args['convert_format'] = array(
    		'type'        => 'boolean',
    		'default'     => true,
    		'description' => __( 'Whether to convert image formats.' ),
    	);

    	$args['url'] = array(
    		'type'              => 'string',
    		'format'            => 'uri',
    		'description'       => __( 'URL of an external image to sideload into the media library, instead of uploading a file.' ),
    		'sanitize_callback' => 'sanitize_url',
    		'validate_callback' => static function ( $url, $request, $param ) {
    			/*
    			 * A custom validate_callback replaces the default
    			 * rest_validate_request_arg(), so re-apply it first to keep
    			 * the schema checks (string type, uri format) enforced.
    			 */
    			$valid = rest_validate_request_arg( $url, $request, $param );
    			if ( is_wp_error( $valid ) ) {
    				return $valid;
    			}

    			/*
    			 * Reject URLs that are not safe to request server-side. wp_http_validate_url()
    			 * enforces an HTTP(S) scheme and blocks private, local, and otherwise
    			 * disallowed hosts, guarding the sideload against SSRF.
    			 */
    			if ( false === wp_http_validate_url( $url ) ) {
    				return new WP_Error(
    					'rest_invalid_url',
    					__( 'Invalid URL. Provide a valid, publicly reachable HTTP or HTTPS image URL.' ),
    					array( 'status' => 400 )
    				);
    			}

    			return true;
    		},
    	);

    	return $args;
    }
    ```

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

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

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

Validate a request argument based on details registered to the route.

  | 
| [wp_http_validate_url()](https://developer.wordpress.org/reference/functions/wp_http_validate_url/)`wp-includes/http.php` |

Validates a URL as safe for use in the HTTP API.

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

Retrieves the translation of $text.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_endpoint_args_for_item_schema/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_endpoint_args_for_item_schema/?output_format=md#)

| Used by | Description | 
| [WP_REST_Attachments_Controller::get_edit_media_item_args()](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/)`wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php` |

Gets the request args for the edit item route.

  |

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

| Version | Description | 
| [7.1.0](https://developer.wordpress.org/reference/since/7.1.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_attachments_controller%2Fget_endpoint_args_for_item_schema%2F)
before being able to contribute a note or feedback.