OpenBB-finance/OpenBB · error · UnauthorizedError

Unauthorized FMP request -> {error_message}

Error message

Unauthorized FMP request -> {error_message}

What it means

Raised in FMP's response_callback when the HTTP body is a JSON dict containing an 'Error Message'/'error' field whose text matches authorization keywords: upgrade, exclusive endpoint, special endpoint, premium query parameter, subscription, unauthorized, or premium. It signals the FMP plan does not cover the requested endpoint or parameter, as opposed to a bad key (which usually yields a non-200 handled by error 445).

Source

Thrown at openbb_platform/providers/fmp/openbb_fmp/utils/helpers.py:36

    data = await response.json()

    if isinstance(data, dict):
        error_message = data.get("Error Message", data.get("error"))

        if error_message is not None:
            conditions = (
                "upgrade" in error_message.lower()
                or "exclusive endpoint" in error_message.lower()
                or "special endpoint" in error_message.lower()
                or "premium query parameter" in error_message.lower()
                or "subscription" in error_message.lower()
                or "unauthorized" in error_message.lower()
                or "premium" in error_message.lower()
            )

            if conditions:
                raise UnauthorizedError(f"Unauthorized FMP request -> {error_message}")

            raise OpenBBError(
                f"FMP Error Message -> Status code: {response.status} -> {error_message}"
            )

    return data


async def get_data(url: str, **kwargs: Any) -> list | dict:
    """Get data from FMP endpoint."""
    # pylint: disable=import-outside-toplevel
    from openbb_core.provider.utils.helpers import amake_request

    return await amake_request(url, response_callback=response_callback, **kwargs)


async def get_data_urls(urls: list[str], **kwargs: Any) -> list | dict:
    """Get data from FMP for several urls."""

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Match the endpoint against FMP's current pricing page to see which tier includes it
  2. Upgrade the FMP subscription, or switch the OpenBB call to a provider whose coverage includes the data on your existing plan
  3. Remove premium-only query parameters from the call
  4. Confirm you are not accidentally using a different key than the one with the correct tier (multiple keys in env/credentials)

Example fix

# before
res = await obb.equity.estimates.analyst_estimates(symbol='AAPL', provider='fmp').await_to_list()  # premium

# after - use a provider that covers it on your plan
res = await obb.equity.estimates.analyst_estimates(symbol='AAPL', provider='benzinga').await_to_list()
Defensive patterns

Strategy: try-catch

Validate before calling

# FMP exposes plan limits in the profile response headers/body of a probe call
r = requests.get(f"https://financialmodelingprep.com/api/v3/profile/AAPL?apikey={key}")
body = r.json()
if isinstance(body, dict) and ('Error Message' in body or 'error' in body):
    raise RuntimeError(f'FMP plan issue: {body}')

Try / catch

from openbb_core.provider.utils.errors import UnauthorizedError
try:
    data = await fetcher.fetch_data(query, credentials)
except UnauthorizedError:
    data = await fallback_fetcher.fetch_data(query, other_credentials)  # different provider/plan

Prevention

When it happens

Trigger: Free or Starter FMP key calling endpoints like analyst estimates, insider trading, or passing premium-only query parameters; FMP returns HTTP 200 with {'Error Message': '...Upgrade your subscription...'} which the keyword scan then matches.

Common situations: Following code examples that use premium endpoints while holding a free key; FMP moving an endpoint from free to paid in a plan change; using a query parameter (e.g. short=true) reserved for higher tiers.

Understand the failure class

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/efa633e108fdb25f. Report an issue: GitHub.