Skip to main content

Forward Your End User's IP and User Agent

When your server calls the Weave API on behalf of one of your users, such as a shopper updating their profile in your app, the API sees your server's address. Forward the user's own IP address and user agent so the audit log records who actually acted. That record is what you and Loom Loyalty use to review fraud, such as one person running many accounts or a burst of redemptions from one address.

Headers to send​

HeaderValue
X-Forwarded-ForYour end user's IP address, IPv4 or IPv6, with no port
User-AgentYour end user's user agent, as their browser or app sent it
curl -X POST https://api.loomloyalty.com/customers \
-H "Authorization: Bearer llk_<keyId>_<secret>" \
-H "Content-Type: application/json" \
-H "X-Forwarded-For: 203.0.113.7" \
-H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)" \
-d '{ ... }'
// In your server's request handler: `req` is the incoming request from your user.
const response = await fetch("https://api.loomloyalty.com/customers", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LOOM_API_KEY}`,
"Content-Type": "application/json",
"X-Forwarded-For": clientIpOf(req),
"User-Agent": req.headers["user-agent"] ?? "",
},
body: JSON.stringify(payload),
});

Take the user's IP from wherever your own hosting puts it. Behind Cloudflare, that's CF-Connecting-IP. Behind most load balancers, it's the last X-Forwarded-For entry your own proxy added. Don't copy an X-Forwarded-For that the user's device sent you, because the device can write anything there.

What the API records​

  • Source IP: the first entry in X-Forwarded-For. If you send a list, put your user's address first. Anything appended after it is ignored.
  • Fallback: send a bare IPv4 or IPv6 address. The check is a shape check, not a lookup. If X-Forwarded-For is missing, or its first entry isn't shaped like an IP address (for example an address with a port, a value with spaces or dots in the wrong places, or anything longer than 64 characters), the API records the address your request came from instead.
  • User agent: the User-Agent header, with control characters removed and cut to 512 characters.
  • Where it shows: both values appear on the audit log, as the event's source IP and user agent, and on GET /audit-events as context.sourceIp and context.userAgent.
  • What doesn't change: rate limits are counted per environment and by Loom Loyalty's own view of the caller, never by X-Forwarded-For, so forwarding an address doesn't change your rate limits.

Privacy​

An IP address and a user agent are personal data under GDPR and similar laws. Forward them only where your privacy notice and your agreement with your users allow you to share them with Loom Loyalty for security and fraud prevention.