# Site Identity REST Endpoint for Apps and Headless Sites

> Adds a public /wp-json/site/v1/identity endpoint with the site name, tagline, logo, site icon, language and home URL, so headless front ends and apps can brand themselves from WordPress.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: rest-api, headless, branding
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/rest-site-identity-endpoint/

## Code

```php
add_action( 'rest_api_init', function () {
    register_rest_route( 'site/v1', '/identity', array(
        'methods'             => WP_REST_Server::READABLE,
        'permission_callback' => '__return_true',
        'callback'            => function () {
            $logo_id  = (int) get_theme_mod( 'custom_logo' );
            $response = new WP_REST_Response( array(
                'name'        => get_bloginfo( 'name' ),
                'description' => get_bloginfo( 'description' ),
                'url'         => home_url( '/' ),
                'language'    => get_bloginfo( 'language' ),
                'logo'        => $logo_id ? wp_get_attachment_image_url( $logo_id, 'full' ) : null,
                'icon'        => get_site_icon_url( 512 ) ? get_site_icon_url( 512 ) : null,
                'timezone'    => wp_timezone_string(),
            ) );
            $response->header( 'Cache-Control', 'public, max-age=3600' );
            return $response;
        },
    ) );
} );
```

## Notes

Only public information is returned; the response can be cached by browsers for an hour.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Site Identity REST Endpoint for Apps and Headless Sites" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
