## TL;DR
The 422 means the goggles value is malformed, not that goggles are broken. A goggles parameter must be a valid goggles URL or a correctly formatted goggles definition, URL-encoded as a single parameter value. Test the query without goggles first, then re-add the parameter with exact encoding. If the goggles definition itself is invalid, the 422 will never clear until the definition is fixed.

```text
brave search api 422 invalid goggles parameter
```

## Use this when
- Adding `goggles` to a working query produces 422.
- The same goggles value fails on every query.
- You are passing a custom goggles definition inline.

## Not for this skill when
- The query 422s without goggles. Then the problem is elsewhere in the request.
- The error is 401. That is the subscription key.

## Steps
1. Remove the goggles parameter and rerun the exact query. Verify: 200 without goggles proves the parameter is the problem.
2. Check the goggles value format: it should be a full goggles URL (https scheme, reachable) or a valid definition string per the docs. Verify: the value matches the documented format exactly.
3. URL-encode the whole parameter value once, not twice. Double encoding is the most common cause. Verify: decoding your sent value once yields the clean goggles URL.
4. If using a hosted goggles URL, fetch it in a browser to confirm it loads. Verify: the URL is live and public.
5. If the definition is custom, validate it against the goggles spec line by line. Verify: a minimal valid definition passes, then build back up.

## Variant phrasings
### brave api goggles 422
The short search, same encoding diagnosis.
### brave search goggles parameter invalid
Wording variant, points at step 2.
### goggles url encoding brave api
Cause phrasing, lands on step 3.

Compatibility: Brave Search API with a Pro (AI) plan for goggles. The parameter is only valid on plans that include it.

## Why it happens
Goggles are fetched and parsed server-side, so the API validates the parameter strictly. A truncated URL, a definition with a syntax error, or double encoding all fail validation with the same unhelpful 422. The API cannot tell you which of the three it is, so you bisect: no goggles, then encoded URL, then definition.

## Edge cases / pitfalls
- Goggles require the paid plan tier. On a free key the parameter may 422 instead of 402. Check your plan.
- Some HTTP clients encode the parameter for you; encoding it yourself first double-encodes. Know your client.
- A goggles URL that requires login will 422. Goggles must be publicly fetchable.
- Cache the encoded value. Rebuilding it per request invites encoding drift.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_J371JpvJcTT4_CagJjPlEA
