> For the complete documentation index, see [llms.txt](https://api-docs.hengelending.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.hengelending.com/api/guides/errors.md). Agents can also search and read this documentation through its [MCP server](https://api-docs.hengelending.com/~gitbook/mcp).

# Errors

Read the status code first, then the body. `POST /oauth/token` has its own error shape. Every other endpoint answers with a problem body.

## The token endpoint

Failures use the OAuth shape:

```json
{ "error": "invalid_request", "error_description": "client_id and client_secret are required." }
```

| Cause                                                             | Status | `error`                                                  | What to do                                          |
| ----------------------------------------------------------------- | ------ | -------------------------------------------------------- | --------------------------------------------------- |
| `client_id` or `client_secret` missing                            | `400`  | `invalid_request`                                        | Fix the request.                                    |
| Malformed request                                                 | `400`  | set by the authorization server                          | Fix the request.                                    |
| Unknown client or wrong secret                                    | `401`  | `access_denied`, with `error_description` `Unauthorized` | Check the credentials. Do not retry in a loop.      |
| The client may not use the `client_credentials` grant or this API | `403`  | `unauthorized_client`                                    | Contact support.                                    |
| Too many token requests                                           | `429`  | set by the authorization server                          | Wait for `Retry-After` when it is sent, then retry. |
| The authorization server failed or did not answer                 | `502`  | `server_error`                                           | Retry with backoff.                                 |

Your secret is never echoed back or logged.

## Every other endpoint

Every error from every other endpoint comes back as `application/problem+json`, with the same members:

```json
{
  "status": 404,
  "title": "The requested loan application was not found.",
  "detail": "The requested loan application was not found.",
  "instance": "/loan-applications/6b1c0c0e-0000-0000-0000-000000000000",
  "code": "NotFound",
  "traceId": "4bf92f3577b34da6a3ce929d0e0e4736"
}
```

* `status`, `title`, `detail`, `instance`, `code` and `traceId` are on every error body, including a `401` for a missing or expired token, a `403` for a missing scope, a `404` for a route that does not exist and a `405` for a wrong method.
* `code` is stable. Branch on it, not on the text of `title` or `detail`. Every value is in the table below.
* `traceId` identifies the request. Quote it to support.
* A request that fails validation is a `400` with the code `ValidationFailed` and an `errors` object: each key names a field, and its value lists what is wrong with it.
* A refused submit or sign-off adds `blockers`, the list of what is missing. Its `code` is `LoanApplicationIncomplete`.
* A `403` for a token that lacks the endpoint's scope has the code `MissingScope` and adds `requiredScope`, the scope to ask for by its standard name, even when the endpoint also accepts an older name. See [Scopes](https://api-docs.hengelending.com/api/guides/scopes.md).

  ```json
  {
    "status": 403,
    "title": "The access token lacks the update:pricing scope. Ask your Henge contact to grant it to your credential.",
    "detail": "The access token lacks the update:pricing scope. Ask your Henge contact to grant it to your credential.",
    "instance": "/pricing/scenarios/6b1c0c0e-0000-0000-0000-000000000000/lock-request/cancel",
    "code": "MissingScope",
    "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
    "requiredScope": "update:pricing"
  }
  ```
* A `401` for a missing, bad or expired token also carries a `WWW-Authenticate: Bearer` header. When the token was rejected, the header says why (for example `error="invalid_token"` and that it expired). Other `401`s, such as a token not linked to a company, do not.
* A `401` or `503` can come before your request reaches an endpoint: when your token is not linked to a company, or when the identity service cannot confirm it. They have the same body. The `503` has the code `ServiceUnavailable` and a `Retry-After` header; retry with the same token.
* A `5xx` never carries the details of what failed. An unexpected failure says only `An unexpected error occurred.`, which is why the `traceId` matters.
* The token endpoint's body (above) is never a problem document. A `400` from `POST /loan-applications/import/mismo` or `PUT /loan-applications/{id}/mismo` can be either body: the import result with its list of errors (`application/json`) when the file was read but refused, or a problem document (`application/problem+json`) when the request itself was wrong, such as a missing or empty file. Check the `Content-Type` before you parse it.

## Status codes and what to do

| Status | Meaning                                                                                                                                                                                   | Usual `code`                                                                                           | What to do                                                                                                                                                                                                                    |
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | The request is malformed or fails validation. Also a loan that is not ready to submit, a rate float or lock on a loan that is not a TPO loan, and an uploaded file that needs a password. | `BadRequest`, `ValidationFailed`, `LoanApplicationIncomplete`, `NotTpo`, `document_password_protected` | Fix the request. For `ValidationFailed`, read `errors`. For `LoanApplicationIncomplete`, answer the `blockers` and try again. Do not retry unchanged.                                                                         |
| `401`  | No token, an expired token, a bad one, or a token not linked to a company or an acting user.                                                                                              | `Unauthorized`                                                                                         | Get a new token and retry once. If it fails again, check your credentials.                                                                                                                                                    |
| `403`  | Your token lacks the scope for this endpoint, or the acting user's role may not do this.                                                                                                  | `MissingScope` (with `requiredScope`), `Forbidden`, or a more specific code from the table below       | For `MissingScope`, ask your Henge contact to grant the scope `requiredScope` names, then get a new token. Otherwise read `detail`. Retrying unchanged does not help.                                                         |
| `404`  | Not found, or the record belongs to another company. The two look the same on purpose. Also a route that does not exist.                                                                  | `NotFound`                                                                                             | Check the id, the path, and the [identifier](https://api-docs.hengelending.com/api/guides/identifiers.md) you used.                                                                                                           |
| `405`  | The route exists but does not take this method.                                                                                                                                           | `MethodNotAllowed`                                                                                     | Check the method on the endpoint's reference page.                                                                                                                                                                            |
| `409`  | The record's state refuses the change. A lock that is already requested, a loan that is locked, the lock desk closed, a quote that is no longer available.                                | `Conflict`, or the reason: `LockAlreadyRequested`, `LoanLocked`, `LockDeskClosed`, `QuoteUnavailable`  | Read the loan, then decide. For `QuoteUnavailable`, price the loan again.                                                                                                                                                     |
| `413`  | The request body is over the size limit. The web server in front of the API refuses a body over its own limit before the API reads it, so that answer has no problem body.                | `PayloadTooLarge` when the API answers                                                                 | Send a smaller file. See [Limits](https://api-docs.hengelending.com/api/guides/limits-and-reliability.md#size-limits).                                                                                                        |
| `422`  | The request is valid but breaks a business rule. A loan already submitted, an e-sign package that is not a draft, a vendor that refused.                                                  | `BusinessRuleViolation`, or a more specific code from the table below                                  | Read `detail`. Retrying unchanged will fail the same way.                                                                                                                                                                     |
| `429`  | Too many requests.                                                                                                                                                                        | `RateLimited`, `PlaidRefreshThrottled`                                                                 | Wait for `Retry-After`, then retry. `PlaidRefreshThrottled` can mean a wait of hours: the body's `nextRefreshAt` says when. See [Limits](https://api-docs.hengelending.com/api/guides/limits-and-reliability.md#rate-limits). |
| `500`  | Something failed on our side. Also a loan create refused because the credential has no acting user or loan officer, or the property state is not two letters.                             | `InternalError`, `LoanCreateRefused`                                                                   | For `InternalError`, retry once after a short wait; if it repeats, contact support with the `traceId`. For `LoanCreateRefused`, fix the request or the credential.                                                            |
| `502`  | A service we depend on failed.                                                                                                                                                            | `UpstreamError`                                                                                        | Retry with backoff. For a billed call, read the state first. See [Limits](https://api-docs.hengelending.com/api/guides/limits-and-reliability.md#retrying-billed-calls).                                                      |
| `503`  | A service we depend on is throttling us, or the identity service could not confirm your token. `Retry-After` is 10 seconds.                                                               | `UpstreamThrottled`, `ServiceUnavailable`                                                              | Wait for `Retry-After`, then retry.                                                                                                                                                                                           |

Retry only `429`, `502`, `503` and, once, a `500` with `InternalError`. Never retry a `4xx` without changing something.

## Every code

These are all the values `code` can have. A new code is added here before the API returns it, and a published code never changes meaning.

| `code`                                | Status       | Meaning                                                                                                                                                                                                                            |
| ------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `BadRequest`                          | `400`        | The request is malformed or one of its values is refused. `detail` says which.                                                                                                                                                     |
| `ValidationFailed`                    | `400`        | The request body or a parameter failed validation. `errors` lists the problems by field.                                                                                                                                           |
| `LoanApplicationIncomplete`           | `400`, `422` | The loan is not ready to submit or sign off (`400`), or for a DU submission (`422`). `blockers` lists what is missing.                                                                                                             |
| `NotTpo`                              | `400`        | Rate float and lock are not available for this loan.                                                                                                                                                                               |
| `document_password_protected`         | `400`        | The uploaded file needs a password. Upload it without one.                                                                                                                                                                         |
| `InvalidAsset`                        | `400`        | An asset value is refused. `detail` says which.                                                                                                                                                                                    |
| `AppraisalRequestNotAvailable`        | `400`        | An appraisal cannot be requested on this loan yet. `detail` says why.                                                                                                                                                              |
| `TownshipRequired`                    | `400`        | The fee quote needs a township for this property. Send one of the townships listed.                                                                                                                                                |
| `Unauthorized`                        | `401`        | No token, an expired token, a bad token, or a token that is not linked to a company or an acting user.                                                                                                                             |
| `MissingScope`                        | `403`        | Your token lacks the scope this endpoint needs. `requiredScope` names it. Ask your Henge contact to grant it to your credential, then get a new token. Retrying with the same token does not help.                                 |
| `Forbidden`                           | `403`        | The acting user's role may not do this, or the request was refused with no more specific code.                                                                                                                                     |
| `PricingAgentNotLicensed`             | `403`        | The pricing agent is not licensed in the property's state, or the license is inactive or expired.                                                                                                                                  |
| `PrimaryPairOnly`                     | `403`        | Only the loan's primary borrower pair can do this on a loan with more than one pair.                                                                                                                                               |
| `OtherPair`                           | `403`        | The record belongs to another borrower pair on the loan.                                                                                                                                                                           |
| `TrustWriteForbidden`                 | `403`        | This change to the loan's trusts is not allowed. Nothing was saved.                                                                                                                                                                |
| `TrustAnswerForbidden`                | `403`        | Only the borrowers on the primary pair can say whether title will be held in a trust.                                                                                                                                              |
| `TrustEditForbidden`                  | `403`        | The acting user's role cannot change the loan's trusts or how title is held. Nothing was saved.                                                                                                                                    |
| `LoanEditOutOfScope`                  | `403`        | The acting user may not edit this loan.                                                                                                                                                                                            |
| `SubjectStreetAdminProcessorOnly`     | `403`        | Only an Admin or a Processor can change the subject property street.                                                                                                                                                               |
| `CreditCredentialForbidden`           | `403`        | The credit login named cannot be used on this loan.                                                                                                                                                                                |
| `AppraisalOrderForbidden`             | `403`        | Only an Admin or a Processor can order an appraisal.                                                                                                                                                                               |
| `NotFound`                            | `404`        | Not found, or the record belongs to another company. The two look the same on purpose.                                                                                                                                             |
| `MethodNotAllowed`                    | `405`        | The route exists but does not take this HTTP method.                                                                                                                                                                               |
| `NotAcceptable`                       | `406`        | The `Accept` header asks for a format the API does not serve. Accept `application/json`.                                                                                                                                           |
| `Conflict`                            | `409`        | The record's state refuses the change. Read it again, then decide.                                                                                                                                                                 |
| `LockAlreadyRequested`                | `409`        | A lock is already requested on this loan.                                                                                                                                                                                          |
| `LoanLocked`                          | `409`        | The loan is already locked.                                                                                                                                                                                                        |
| `LockDeskClosed`                      | `409`        | The lock desk is closed. Try again when it opens.                                                                                                                                                                                  |
| `LockDeskStatusUnavailable`           | `409`        | The lock desk's hours could not be read. Retry shortly.                                                                                                                                                                            |
| `QuoteUnavailable`                    | `409`        | The quote is no longer available. Price the loan again.                                                                                                                                                                            |
| `CreditOrderInProgress`               | `409`        | A credit report order for this task is already being placed. Read the task before retrying.                                                                                                                                        |
| `VendorCredentialsMissing`            | `409`        | No login is set up for the vendor. Contact support.                                                                                                                                                                                |
| `ScenarioNameTaken`                   | `409`        | A saved scenario with this name already exists on the loan.                                                                                                                                                                        |
| `ScenarioLimitReached`                | `409`        | The loan already holds the most saved scenarios it can. Delete one first.                                                                                                                                                          |
| `PreApprovalNoSoftPull`               | `409`        | The primary borrower has no soft credit pull, so a pre-approval cannot run.                                                                                                                                                        |
| `PreApprovalVerifiedApprovalComplete` | `409`        | The loan already has a verified approval.                                                                                                                                                                                          |
| `PreApprovalStatedIncomeSkipped`      | `409`        | The borrower skipped stated income, so a pre-approval cannot run.                                                                                                                                                                  |
| `PreApprovalDscrLoan`                 | `409`        | Pre-approval does not run on a DSCR loan.                                                                                                                                                                                          |
| `PreApprovalNoIssuedLetter`           | `409`        | No pre-approval letter has been issued on this loan.                                                                                                                                                                               |
| `PreApprovalLastRunDenied`            | `409`        | The last pre-approval run was denied.                                                                                                                                                                                              |
| `PreApprovalLoanClosedOut`            | `409`        | The loan is closed out.                                                                                                                                                                                                            |
| `PayloadTooLarge`                     | `413`        | The request body is over the size limit. Send a smaller file.                                                                                                                                                                      |
| `UnsupportedMediaType`                | `415`        | The request's `Content-Type` is not one the endpoint takes.                                                                                                                                                                        |
| `BusinessRuleViolation`               | `422`        | The request is valid but breaks a business rule. `detail` says which.                                                                                                                                                              |
| `AssetsLocked`                        | `422`        | The loan's assets can no longer be changed.                                                                                                                                                                                        |
| `LiabilitiesLocked`                   | `422`        | The loan's liabilities can no longer be changed.                                                                                                                                                                                   |
| `LoanNoLongerEditable`                | `422`        | The loan can no longer be edited in Henge.                                                                                                                                                                                         |
| `LoanStateUnconfirmed`                | `422`        | The loan's state could not be confirmed with the LOS, so nothing was saved. Retry shortly.                                                                                                                                         |
| `DocumentHeldInLos`                   | `422`        | The document has no file in Henge, so it cannot be opened or downloaded here.                                                                                                                                                      |
| `AppraisalOrderRefused`               | `422`        | The appraisal order was refused. `detail` says why.                                                                                                                                                                                |
| `PricingSearchExpired`                | `422`        | The pricing search has expired. Run the search again for a new search id.                                                                                                                                                          |
| `PricingSearchInvalid`                | `422`        | The pricing search id is not valid for this pricing agent, or has expired. Run the search again.                                                                                                                                   |
| `DuCasefileNotReleased`               | `422`        | The DU casefile is not released to Henge. Release it, then try again.                                                                                                                                                              |
| `RateLimited`                         | `429`        | Too many requests. Wait for `Retry-After`, then retry.                                                                                                                                                                             |
| `PlaidRefreshThrottled`               | `429`        | The loan's Plaid balances were refreshed too recently. `nextRefreshAt` says when you can refresh again.                                                                                                                            |
| `ClientError`                         | other `4xx`  | Any other 4xx with no more specific code. The status code says what kind.                                                                                                                                                          |
| `LoanCreateRefused`                   | `500`        | `POST /loan-applications` was refused: the credential has no acting user or loan officer, or the property state is not two letters. `detail` says which. Fix the request or the credential; retrying unchanged fails the same way. |
| `InternalError`                       | `500`        | Something failed on our side. Retry once; if it repeats, contact support with the `traceId`.                                                                                                                                       |
| `UpstreamError`                       | `502`        | A service we depend on failed. Retry with backoff.                                                                                                                                                                                 |
| `UpstreamThrottled`                   | `503`        | A service we depend on is throttling us. Wait for `Retry-After`, then retry.                                                                                                                                                       |
| `ServiceUnavailable`                  | `503`        | The identity service could not confirm your token. Wait for `Retry-After`, then retry with the same token.                                                                                                                         |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://api-docs.hengelending.com/api/guides/errors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
