---
title: "Fastly Integration"
description: "Stream Fastly access logs to Airefs with an HTTPS log streaming endpoint. Works on all Fastly plans, no code changes to your service logic."
---

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

# Fastly Integration

Fastly’s real-time log streaming sends every request to Airefs, where bot traffic is classified and assets and error responses are dropped server-side. This powers [AI Impressions](/docs/impressions/); to also track [Clicks](/docs/clicks/), add the client-side tracking script from **Site Settings → Tracking Script**.

Your access token is in your Airefs account under **Site Settings → Access Token**.

## Setup

1.  In the Fastly control panel, open your service, click **Edit configuration**, and go to **Logging**.
2.  Create a new **HTTPS** endpoint with these settings:

| Setting | Value |
| --- | --- |
| URL | `https://api.getairefs.com/v1/logs/fastly` |
| Method | `POST` |
| Content type | `application/json` |
| Custom header name | `X-API-Key` |
| Custom header value | your Airefs access token |
| JSON log entry format | Array of JSON |
| Log line format | Blank |
| Format version | 2   |
| Maximum bytes per request | `5000000` (5 MB) |

3.  Set the log format to exactly this template:

```text
{"event_id":"%{req.xid}V","timestamp":"%{begin:%Y-%m-%dT%H:%M:%S%z}t","client_ip":"%{req.http.Fastly-Client-IP}V","hostname":"%{if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host)}V","request_path":"%{json.escape(req.url.path)}V","query_string":"%{json.escape(req.url.qs)}V","request_method":"%{json.escape(req.method)}V","status_code":%{resp.status}V,"content_type":"%{json.escape(resp.http.Content-Type)}V","user_agent":"%{json.escape(req.http.User-Agent)}V","referrer":"%{json.escape(req.http.Referer)}V","country_code":"%{client.geo.country_code}V"}
```

4.  Attach this response condition so shielded requests are logged only at the edge POP:

```text
fastly.ff.visits_this_service == 0
```

If the service fronts multiple domains, combine the shielding guard with your tracked hostname:

```text
fastly.ff.visits_this_service == 0 && req.http.host == "yourdomain.com"
```

5.  Activate the new service version.

Fastly validates log destination domains automatically against Airefs’s `/.well-known/fastly/logging/challenge` endpoint — there is nothing to configure for it.

## Verification

Visit a few pages served by Fastly. Events appear in your Airefs dashboard within a few minutes.

Outside dry-run mode, a successful response means Airefs stored every accepted record and reports why the rest were dropped. For a one-off test before going live, POST a sample record with `?dry_run=1` appended to the endpoint URL: Airefs returns a per-record verdict, including the bot classification it detected, without storing anything.

No events? Confirm the `X-API-Key` header value is your exact access token (a wrong token returns `401`, which Fastly does not surface prominently) and the log format matches the template exactly. Need help? Email [support@getairefs.com](mailto:support@getairefs.com).

Source: /docs/integrations/fastly/
