# Before request schema This is the function schema which defines all the middleware to be run before calling [sdk.request](/docs/chatlayer/actions/sdk-object) method. This will be the schema which will be used to inject middleware into your code. The before request middleware takes in 3 arguments: - [request](/docs/chatlayer/actions/sdk-object) - [sdk](/docs/chatlayer/actions/sdk-object) - [bundle](/docs/chatlayer/actions/bundle-object) ```javascript const includeApiKey = (request, sdk, bundle) => { if (bundle.authData.api_key) { request.headers = { ...request.headers, "Content-Type": "application/json", Authorization: `Bearer ${bundle.authData.api_key}`, }; } return request; }; module.exports { befores:[includeApiKey]; } ``` ```javascript const before = require("./src/before"); module.exports = { beforeRequest: [...before.befores], }; ``` In the above example we can see that on the app schema, beforeRequest property is an array of functions which includes a function that puts API key into the header of the request. Please note that beforeRequest method is called before each [sdk.request](/docs/chatlayer/actions/sdk-object) method is called.