> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFEntityGetSecretKey

> Gets the PlayFab secretKey associated with a title Entity. Will fail with E_PF_NOSECRETKEY if there is no Secret Key associated with the provided Entity.

Gets the PlayFab secretKey associated with a title Entity. Will fail with E\_PF\_NOSECRETKEY if there is no Secret Key associated with the provided Entity.

## Syntax

```cpp theme={null}
HRESULT PFEntityGetSecretKey(  
    PFEntityHandle handle,  
    size_t secretKeySize,  
    char* secretKey,  
    size_t* secretKeyUsed  
)  
```

### Parameters

**`handle`**   PFEntityHandle

Entity handle.

**`secretKeySize`**   size\_t

Size of the provided buffer. Required size can be obtained via PFServiceConfigGetSecretKeySize.

**`secretKey`**   char\*<br />*Out\_writes(secretKeySize)*

Buffer the secretKey will be written to.

**`secretKeyUsed`**   size\_t\*<br />*optional output*

The number of bytes used in the buffer including the null terminator.

### Return value

Type: HRESULT

Result code for this API operation.

## Requirements

**Header:** PFEntity.h

## See also

[PFEntity members](/services/playfab/api-references/c/pfentity/pfentity_members)


## Related topics

- [Entity Handles](/services/playfab/sdks/c/entity-handles.md)
- [Services C API overview - PFEntity.h](/services/playfab/api-references/c/pfentity/pfentity_members.md)
- [PFEntityGetSecretKeySize](/services/playfab/api-references/c/pfentity/functions/pfentitygetsecretkeysize.md)
- [PFAuthenticationGetEntityWithSecretKeyGetResult](/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationgetentitywithsecretkeygetresult.md)
- [PFAuthenticationGetEntityWithSecretKeyAsync](/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationgetentitywithsecretkeyasync.md)
