Location Required
location_required422
This calculation needs a location. Provide either a location name, or latitude/longitude/timezone.
What this means
The endpoint requires location information to compute its result, and the request didn't provide enough. Asterwise accepts location in two forms: a named string (like "Mumbai" or "Brooklyn, NY") that we geocode for you, or an explicit latitude/longitude/timezone tuple. The request had neither, so the calculation couldn't proceed.
When you'll see this
- A request to a location-dependent endpoint omitted both the location name and the coordinate fields.
- A form had location fields disabled or hidden and they didn't get populated.
- A migration from a different API removed location handling without realizing Asterwise needs it.
- An automated pipeline lost location data somewhere upstream before reaching the API call.
Learn more about how this works
Many Asterwise calculations are location-dependent: natal charts need the birth location for house cusps, panchanga needs sunrise (which needs location), muhurta needs a target location, geocoding obviously needs a query. We accept location in two equivalent forms because both are legitimate — a name is easier to type, coordinates are more precise. Either works; neither is treated as second-class. But one of them must be present.
The most common gotcha: developers sometimes assume Asterwise has a "default location" for a user (like an account-level address). It doesn't. Each request stands alone — location must be in the payload of the specific call.
Example response
{
"success": false,
"error": "location_required",
"message": "A location is required for this calculation. Provide either a location name, or latitude, longitude, and timezone.",
"details": [],
"retry_after": null,
"doc_url": "https://docs.asterwise.com/reference/errors/location_required",
"request_id": "req_01HXYZABCDEFGH",
"timestamp": "2026-05-25T12:34:56Z"
}
- Add a location to the request: either
location: "Mumbai"(we'll geocode it) orlat: 19.076, lon: 72.8777, timezone: "Asia/Kolkata"(explicit coordinates). - If you have a user's location stored in your database, populate it into the request before calling.
- If you don't have a location at all, prompt the user to provide one before continuing.
This is a structural failure to provide required input — surface as a user-facing prompt for location, not as a generic error.
Python:
Production handler
- Python
- TypeScript
import httpx
class LocationRequiredError(Exception):
"""Endpoint needs location data that wasn't provided."""
def call_with_location(url, headers, payload):
response = httpx.post(url, headers=headers, json=payload, timeout=30)
if response.status_code == 422:
body = response.json()
if body.get("error") == "location_required":
raise LocationRequiredError(
"This calculation needs a location. "
"Provide a location name or lat/lon/timezone."
)
response.raise_for_status()
return response.json()
class LocationRequiredError extends Error {}
async function callWithLocation(url: string, headers: HeadersInit, payload: unknown) {
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload),
});
if (response.status === 422) {
const body = await response.json();
if (body.error === "location_required") {
throw new LocationRequiredError(
"This calculation needs a location. " +
"Provide a location name or lat/lon/timezone.",
);
}
}
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
Avoid this error by
- Validate location-dependent fields client-side before submitting. If your form has a location section, make it required.
- Store user locations as both name and coordinates after the first geocode. Either form can satisfy this requirement; having both gives you flexibility.
- For multi-user products, save each user's preferred location at signup so location-dependent calls have it available.
- Document clearly in your UI when a feature requires location data, so users don't try to skip the input.