# Pass API Key to Lambda Function

**URL:** <https://forum.serverless.com/t/pass-api-key-to-lambda-function/13386>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, api-gateway\
**Created:** [December 14, 2020, 3:58am UTC](https://forum.serverless.com/t/pass-api-key-to-lambda-function/13386 "2020-12-14T03:58:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlevit](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mlevit/32/3325_2.png) [@mlevit](https://forum.serverless.com/u/mlevit)\
**Post date:** [December 14, 2020, 3:58am UTC](https://forum.serverless.com/t/pass-api-key-to-lambda-function/13386/1 "2020-12-14T03:58:26Z")

</div>

Hey all,

I’m trying to create a private API using API key generated by API Gateway. Is there a way to pass the newly generated key directly into my Lambda function in the same serverless.yml file without any manual intervention?

I can’t seem to find an example of how to reference the key itself.

For reference, I’m looking at this example [https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#setting-api-keys-for-your-rest-api](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#setting-api-keys-for-your-rest-api)
