# `AshAuthentication.Strategy.ApiKey.GenerateApiKey`
[🔗](https://github.com/team-alembic/ash_authentication/blob/main/lib/ash_authentication/strategies/api_key/generate_api_key.ex#L5)

Generates a random API key for a user.

The API key is generated using a random byte string and a prefix. The prefix
is used to generate a key that is compliant with secret scanning. You can use
this to set up an endpoint that will automatically revoke leaked tokens, which
is an extremely powerful and useful security feature.

See [the guide on Github](https://docs.github.com/en/code-security/secret-scanning/secret-scanning-partnership-program/secret-scanning-partner-program) for more information.

## Options

* `:prefix` - The prefix to use for the API key.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
