diff --git a/docs/content/docs/plugins/api-key.mdx b/docs/content/docs/plugins/api-key.mdx index aab3cb7a15..bf3abf3f60 100644 --- a/docs/content/docs/plugins/api-key.mdx +++ b/docs/content/docs/plugins/api-key.mdx @@ -369,6 +369,19 @@ This function will delete all API keys that have an expired expiration date. Any time an endpoint in Better Auth is called that has a valid API key in the headers, we will automatically create a mock session to represent the user. + + + ```ts + const session = await auth.api.getSession({ + headers: new Headers({ + 'x-api-key': apiKey, + }), + }); + ``` + + + + The default header key is `x-api-key`, but this can be changed by setting the `apiKeyHeaders` option in the plugin options. ```ts