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

# Google Cloud Functions

> Use an HTTP Cloud Function or Cloud Run function when your application traffic already enters through Google Cloud — putting Esper at a Google Cloud serverless boundary.

<Info>
  **Recipe Path**

  This guide corresponds to
  <a href="https://github.com/stonehedgelabs/esper/tree/main/recipes/google-cloud" target="_blank" rel="noopener noreferrer">`recipes/google-cloud`</a>.
</Info>

## What this integration does

The Google Cloud recipe extracts request context from the incoming HTTP
request, calls Esper at `POST /api/v1/runtime/mitigation`, and either returns a
mitigation response or forwards the request onward.

Example shape:

```js theme={null}
const mitigationPayload = {
  ip:
    req.headers["x-forwarded-for"]?.split(",")[0]?.trim() ||
    req.ip ||
    "127.0.0.1",
  user_agent: req.get("user-agent"),
  path: req.path,
  method: req.method,
  google_trace: req.get("x-cloud-trace-context"),
};
```

## Environment variables

* `ESPER_API_KEY`
* `ESPER_API_URL`

## Deploy

```bash theme={null}
cd recipes/google-cloud
gcloud functions deploy esperProxy \
  --gen2 \
  --runtime=nodejs20 \
  --region=us-central1 \
  --source=. \
  --entry-point=esperProxy \
  --trigger-http
```

<Info>
  **Operational Fit**

  This is the closest Google Cloud equivalent to the AWS Lambda recipe. It fits
  teams already running request handling at a serverless Google Cloud boundary
  and wanting Esper without introducing a separate always-on service.
</Info>

## Current behavior notes

* `Monitor` is the safest place to start.
* `Challenge` should return the Esper challenge payload or redirect URL from
  the runtime decision response.
* `Block` should return an immediate deny response from the function boundary.
