Title: rest_url_prefix
Published: December 9, 2015
Last modified: February 24, 2026

---

# apply_filters( ‘rest_url_prefix’, string $prefix )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#user-contributed-notes)

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

Filters the REST URL prefix.

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

 `$prefix`string

URL prefix. Default `'wp-json'`.

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

    ```php
    return apply_filters( 'rest_url_prefix', 'wp-json' );
    ```

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

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

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

Retrieves the URL prefix for any API resource.

  |

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

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#comment-content-3708)
 2.    [Farhan Noor](https://profiles.wordpress.org/farhannoor/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/rest_url_prefix/#comment-3708)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_url_prefix%2F%23comment-3708)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_url_prefix%2F%23comment-3708)
 4.  Flushing rewrite rules is required for new prefix to work. Simplest method is 
     to visit Settings/Permalinks in your admin panel & Save Changes with existing 
     settings. It will refresh your permalinks.
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_url_prefix%2F%3Freplytocom%3D3708%23feedback-editor-3708)
 6.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/rest_url_prefix/?output_format=md#comment-content-6595)
 7.    [Ahmed Elgameel](https://profiles.wordpress.org/elgameel/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/rest_url_prefix/#comment-6595)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_url_prefix%2F%23comment-6595)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_url_prefix%2F%23comment-6595)
 9.  If you want to change WordPress’s default REST API URL prefix from `wp-json` to
     another prefix e.g. `api` add the following code to your theme’s `functions.php`
     file or in a custom plugin:
 10.     ```php
         add_filter( 'rest_url_prefix', function () {
             return 'api';
         } );
         ```
     
 11. Now, refresh rewrite rules by going to **Settings** -> **Permalinks** and hit **
     Save Changes**.
 12. Your new REST API URL will be `example.com/api/` instead of the default `example.
     com/wp-json/`.
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_url_prefix%2F%3Freplytocom%3D6595%23feedback-editor-6595)

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