Title: _wp_connectors_mask_api_key
Published: May 20, 2026

---

# _wp_connectors_mask_api_key( string $key ): string

## In this article

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

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Masks an API key, showing only the last 4 characters.

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

 `$key`stringrequired

The API key to mask.

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

 string The masked key, e.g. "____****____fj39".

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

    ```php
    function _wp_connectors_mask_api_key( string $key ): string {
    	if ( strlen( $key ) <= 4 ) {
    		return $key;
    	}

    	return str_repeat( "\u{2022}", min( strlen( $key ) - 4, 16 ) ) . substr( $key, -4 );
    }
    ```

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

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

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

Masks and validates connector API keys in REST responses.

  |

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

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

## User Contributed Notes

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