# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel


class ApiError(UncheckedBaseModel):
    """
    Standard error response format for all Extend API errors.

    See the [Error Codes documentation](https://docs.extend.ai/2026-02-09/developers/error-codes) for error handling recommendations.
    """

    code: str = pydantic.Field()
    """
    Error code for programmatic handling.
    """

    message: str = pydantic.Field()
    """
    Human-readable error message suitable for displaying to developers. 
    Do not rely on the exact text of this message as it may change.
    """

    retryable: bool = pydantic.Field()
    """
    Whether the request can be retried. When true, retry with exponential backoff.
    When false, fix the underlying issue before retrying.
    """

    request_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="requestId")] = pydantic.Field(
        alias="requestId", default=None
    )
    """
    Unique request identifier for support purposes. Always include this 
    when contacting Extend support about an error.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
