# Error codes and recovery

Server error codes, recovery actions, reasons and SDK client errors.

[Web version](https://www.longplayai.com/docs/api/errors)

<a id="codes"></a>

## Server error codes

**Error codes**

| code | HTTP | Retryable | recovery | Meaning |
| --- | --- | --- | --- | --- |
| `INVALID_PROTOCOL_VERSION` | 400 | No | `fix_request` | The protocol header is malformed or disagrees with the SDK version header. |
| `UNSUPPORTED_PROTOCOL_VERSION` | 400 | No | `upgrade_sdk` | The protocol header is missing or unsupported. |
| `PROTOCOL_RETIRED` | 410 | No | `upgrade_sdk` | The protocol is retired; the request was not executed. |
| `UNAUTHENTICATED` | 401 | No | `authenticate` | The credential is missing, invalid, expired or revoked. |
| `FORBIDDEN` | 403 | No | `check_permissions` | The credential lacks the scope, the origin is not allowed, or a Customer credential selects another Customer. |
| `SCOPE_MISMATCH` | 403 | No | `check_scope` | The App or environment does not match the credential. |
| `INVALID_REQUEST` | 400 | No | `fix_request` | The body, fields or combination violate the contract. |
| `NOT_FOUND` | 404 | No | `fix_request` | The resource does not exist in this scope. |
| `CONFLICT` | 409 | No | `resolve_conflict` | State changed, an operation is in progress, or one ID was reused with different input. |
| `PAYLOAD_TOO_LARGE` | 413 | No | `fix_request` | The request body exceeds the limit. |
| `RATE_LIMITED` | 429 | Yes | `retry_same_request` | Rate limit exceeded; retry the same request after Retry-After. |
| `SERVICE_UNAVAILABLE` | 503 | Yes | `retry_same_request` | The service is temporarily unavailable; retry the same request. |
| `NOT_CONFIGURED` | 501 | No | `configure_integration` | A required integration, such as a payment account, is not configured. |
| `CAPABILITY_UNAVAILABLE` | 501 | No | `check_availability` | The capability or execution mode is unavailable on this service (HTTP 501). |
| `INTERNAL_ERROR` | 500 | No | `recover_operation` | The outcome is unknown; read or recover the original operation by its ID. |

`CONFLICT` can also arrive as 412 (reload state) or 425 (retry the same request later); `SERVICE_UNAVAILABLE` can be 408, 502, 503 or 504.

<a id="recovery"></a>

## Recovery actions

**Meaning of `error.recovery`**

| recovery | Next step |
| --- | --- |
| `fix_request` | Correct the request before sending again. |
| `authenticate` | Obtain a new credential: sign in again or issue a session. |
| `check_permissions` | Grant the Key the required scope or check the website origin. |
| `check_scope` | Check the App UUID, environment and Customer. |
| `resolve_conflict` | Read the latest state before deciding to retry. |
| `reload_state` | Reload the resource before acting. |
| `retry_same_request` | Retry the same request and ID after Retry-After. |
| `configure_integration` | Complete the integration configuration in Console. |
| `check_availability` | Check that the capability is available on this service. |
| `upgrade_sdk` | Upgrade to an SDK/protocol version the service supports. |
| `recover_operation` | Do not create a new request; read the original operation or replay its ID and input. |
| `contact_support` | Keep the X-Request-Id and contact us. |

<a id="reasons"></a>

## Reasons

**Optional `error.reason`**

| reason | Meaning |
| --- | --- |
| `CAPABILITY_NOT_ENABLED` | The capability is not enabled for this App/environment. |
| `INTEGRATION_MISSING` | A required integration is missing. |
| `PROVIDER_CREDENTIAL_REJECTED` | The payment provider rejected the configured credential. |
| `PRICE_BINDING_REQUIRED` | The Product lacks a price binding for this provider and currency. |
| `IDEMPOTENCY_CONFLICT` | One idempotency ID was used with different input. |
| `RESULT_UNKNOWN` | The outcome is unknown; recover the original operation instead of retrying. |
| `STATE_CHANGED` | The resource state changed. |
| `IDENTITY_CONTEXT_CHANGED` | The process identity changed before acceptance; settle the original request and reload the Run. |
| `CUSTOMER_BINDING_CONFLICT` | This Run is bound to another Customer; continue with the original account. |
| `RUN_CONTRACT_MISMATCH` | This Version uses a different execution contract; use its matching API. |
| `OPERATION_IN_PROGRESS` | The same operation is still in progress. |
| `FUNNEL_VERSION_RETIRED` | The pinned Funnel Version format is retired; publish a new Version. |
| `FUNNEL_PAUSED` | The Funnel is paused and accepts no new starts; started Runs continue. Show it as temporarily unavailable, not as a purchase problem. |

<a id="client"></a>

## SDK client errors

The SDKs raise these themselves; they are not error objects returned by the server. Network and timeout errors use `recover_operation`: a write may have committed, so read the original operation or replay its ID.

- The `recovery` column is the actual `error.recovery` value.
- Some server codes are also raised locally, such as `INVALID_REQUEST`, `SCOPE_MISMATCH` and `CONFLICT`; they mean the same as in the table above but have no HTTP status.

**Local error codes**

| code | recovery | Meaning |
| --- | --- | --- |
| `TIMEOUT` | `recover_operation` | The request timed out; a write may have committed. |
| `NETWORK_ERROR` | `recover_operation` | The network failed; a write may have committed. |
| `HTTP_ERROR` | `recover_operation` | An unrecognized error response arrived; a write may have committed. |
| `INVALID_RESPONSE` | `recover_operation` | The response did not match the contract. |
| `PROTOCOL_MISMATCH` | `upgrade_sdk` | The response declared a protocol other than the SDK's; upgrade the SDK. |
| `INVALID_URL` | `fix_request` | Invalid `baseUrl`: use HTTPS (HTTP only on localhost) without credentials, a query or a fragment. |
| `INVALID_TIMEOUT` | `fix_request` | `timeoutMs` is not between 1 and 120000. |
| `INVALID_TOKEN` | `authenticate` | A credential is missing: no Server Key, Customer Token or Run credential was given. |
| `SERVER_ONLY` | `fix_request` | A backend-only API was used in a browser, such as a Server Key, AI billing, a Campaign or a Funnel decision. |
| `NOT_IDENTIFIED` | `authenticate` | The browser client has not called `identify`. |
| `CUSTOMER_SESSION_REQUIRED` | `authenticate` | Recovering the original purchase requires a current Customer session; sign in as the same Customer and resume recovery. |
| `EXECUTION_POLICY_REFUSED` | `fix_request` | The current execution policy refuses this operation; correct the policy before continuing the original purchase. |
| `IDENTITY_CHANGED` | `reload_state` | `identify` or `reset` was called, or the view closed, while the request was in flight; the result was discarded, so read the state again. |
| `EVENT_QUEUE_FULL` | `retry_same_request` | 500 events are waiting; call `flush()` first. |
| `COMMAND_PENDING` | `recover_operation` | A previous Funnel or purchase command has no result yet; retry the original request before sending another. |
| `COMMAND_STORAGE_CONFLICT` | `resolve_conflict` | Another page changed the same Run's pending command. |
| `COMMAND_STORAGE_INVALID` | `fix_request` | The storage for pending commands is unavailable or invalid. |
| `PURCHASE_PENDING` | `recover_operation` | The original purchase is unresolved; recover its Start, Run or Operation before starting another purchase. |
| `PURCHASE_STORAGE_CONFLICT` | `resolve_conflict` | Another page changed the original purchase record; reread the shared record and resolve the conflict before continuing. |
| `PURCHASE_STORAGE_INVALID` | `recover_operation` | The original purchase record is missing, invalid or unavailable; retain the unknown outcome and recover the original operation before starting another purchase. |
| `DECISION_PENDING` | `recover_operation` | Waiting for a Funnel decision timed out (`FunnelDecisionTimeoutError`); read the same decision ID later or retry the original request ID. |
| `DECISION_ACCEPTANCE_UNKNOWN` | `recover_operation` | It is unknown whether the decision request was accepted; retry with the original request ID and input. |
| `DECISION_FAILED` | `contact_support` | The Funnel decision failed. |
| `EVALUATION_MODE` | `reload_state` | The call does not match the Funnel's evaluation mode, for example Local evaluation of a Remote Funnel. |
| `SERVER_REQUIRED` | `fix_request` | This Funnel needs server execution and cannot finish in the browser alone. |
| `FUNNEL_STOPPED` | `check_availability` | The Funnel is paused or unavailable. |
| `RUN_RECONCILIATION_REQUIRED` | `recover_operation` | The Run's control state changed, for example a pause or stop; read the original Run before continuing. |
| `CONFIGURATION_UNAVAILABLE` | `check_availability` | The public configuration that Local mode needs is unavailable. |
| `CONFIGURATION_EXPIRED` | `reload_state` | The Local rules expired; refresh them before using the result. |
| `CONFIGURATION_CHANGED` | `reload_state` | The public configuration changed while in use; refresh it before evaluating. |
| `CONFIGURATION_DISPOSED` | `reload_state` | The configuration manager was destroyed; create a new one. |
| `UNSUPPORTED_SCHEMA` | `upgrade_sdk` | The public configuration format is newer than this SDK; upgrade the SDK. |
| `STICKY_SAVE_FAILED` | `retry_same_request` | A sticky assignment was not saved, so this evaluation cannot be used. |
| `TRANSITION_LIMIT` | `resolve_conflict` | The Local Funnel exceeded its transition budget. |
| `PRECONDITION_FAILED` | `reload_state` | The Paywall visit, the purchase selection or the current screen changed during the action; read the current state and try again. |
| `PRODUCT_UNAVAILABLE` | `fix_request` | The selected Product is not available; choose an available one. |
| `COUPON_UNAVAILABLE` | `reload_state` | The Coupon bound to the purchase button is no longer available; read the Paywall again before purchasing. |
| `PAYWALL_UNAVAILABLE` | `check_availability` | The published Paywall is unavailable. |
| `ROUTE_UNAVAILABLE` | `check_availability` | This Funnel Version delivers no route; the Run started at the click still decides its first screen. |
| `PURCHASE_HANDLER_REQUIRED` | `fix_request` | No purchase handler (merchant or native) was provided. |
| `EVENT_HANDLER_REQUIRED` | `fix_request` | A required event handler was not provided. |
| `CLOSED` | `fix_request` | The Paywall or native host has closed. |
| `BRIDGE_UNAVAILABLE` | `check_availability` | The native bridge is unavailable. |
| `INVALID_CONFIGURATION` | `fix_request` | The native host's API origin or surface is invalid. |
| `INVALID_STATE` | `reload_state` | Installation credentials or local sequence state are invalid; reload and validate installation state through the trusted host. |
| `NATIVE_OPERATION_FAILED` | `contact_support` | A native operation did not finish. |
| `AI_PRICE_UNAVAILABLE` | `fix_request` | The model's published price is missing or too precise to use. |
| `AI_USAGE_UNAVAILABLE` | `recover_operation` | The provider's token usage is missing or inconsistent, so it cannot be billed. |
| `AI_PROVIDER_ERROR` | `check_availability` | The model provider returned an error. |
| `AI_BALANCE_REJECTED` | `resolve_conflict` | Usage was recorded, but the balance operation was rejected. |
