# Deal applications

Complete a Deal's application, share it for review or editing, and submit it when ready.

Base URL: https://api.levr.ai/v1

Authentication: Bearer — Portal API key

[REST guide](https://docs.levr.ai/rest-api.md) · [OpenAPI specification](https://docs.levr.ai/generated/openapi.json)

OpenAPI defines exact REST schemas. Each record’s Application Contract defines its current questions and accepted answers.

## Complete the application

Each application has its own questions and document requirements. Start with the application linked to the business or deal you are working on. Your API key needs access to that application resource; business or deal access alone does not grant it.

1. Read the application and fetch its `contract_url`. The returned Application Contract defines its current questions, accepted values, required fields, repeated entries, and operation URLs.
2. Read the answers. Use the contract's `block_key` and `field_key` for updates, with the answers response's ETag in `If-Match`.
3. Complete repeated entries and attach documents using the operations described below. You can also use Autofill to prepare suggestions.
4. Read submission readiness and resolve the reported issues. Review the current answers before submitting.
5. Submit using the application's lifecycle ETag and the reviewed `expected_answers_revision`. Read the application afterward to confirm the result.

The application ETag protects lifecycle changes; the answers ETag protects answers. They are separate revisions. A submission receipt confirms the recorded submission, not lender acceptance, approval, or funding.

Fetch the contract again when its `contract_version` changes. A newly published form does not establish the questions in an existing application.

## Add repeated entries

The contract's `repeatable_groups` describe the allowed rows and their question keys. Use `operations.repeatable_items_url` to list or create rows. Use the returned `item_id` for updates, deletes, and answers inside that row. A row's position is not its ID.

These writes require the latest answers ETag and an `Idempotency-Key`. If answers change, read them again before retrying.

## Attach documents

File bytes never belong in JSON. Request an upload through `operations.file_uploads_url` with the file question's `block_key` and, for a repeated entry, its `item_id`.

The response gives an expiring `upload_url`, exact multipart field name, and size limit. Upload one `file` part with the required `If-Match` and `Idempotency-Key` headers. Read `operations.files_url` afterward to confirm the file and obtain download URLs. Delete files using their returned `file_id`.

Resolve relative download URLs against the API origin and use the documented authentication. Read fresh metadata when a download URL expires.

## Use Autofill to prepare answers

Autofill turns email text and documents into suggestions. It does not save application answers until you accept suggestions.

1. Read Autofill preparation, add email text, and optionally upload supporting files. Use the latest preparation ETag after each change.
2. Start a run with `expected_preparation_revision` set to the latest preparation revision. Keep its URL so you can resume monitoring.
3. Check the run while it is `pending` or `running`. When it settles, read its suggestions and any warnings or failures.
4. Review the proposed values, sources, and concerns. Accept only the suggestions you intend to save, using the latest answers revision.
5. Read the application answers to confirm what was saved.

Preparation’s `files` list shows each supporting document’s name and processing status. Check it after an upload, or if the upload response was lost, before uploading the document again. A document is `pending` while queued, `running` while being read, `success` when ready for Autofill, or `failed` when it needs attention. Read preparation again to check progress; processing updates do not change its revision.

For scalar suggestions, the suggested answer is `proposed_value.field_value`. Compound proposals contain `attributes`; repeated-entry proposals contain `list_items`; file proposals contain file-source metadata. Review the complete proposal, then use the suggestion's acceptance operation to save it. You do not need to reconstruct an answer update from the proposal.

Treat numeric proposal metadata as opaque context. Write answers using the keys and repeated-entry IDs returned by the Application Contract.

Review one pending suggestion's proposed value, evidence, and concerns. Read the current answers, then POST to the Run's suggestions_url plus {suggestion_id}/accept/ with no request body, the answer ETag in If-Match, and a unique Idempotency-Key. Levr checks the answer revision and target drift, applies the proposal, and records acceptance in one transaction. A 412 means the answers changed; reread and review before issuing a new command. A 409 suggestion_conflict means the suggestion is stale, superseded, or already resolved; refresh suggestions and review again. An identical retry must reuse the original precondition and key. Check the returned suggestion is accepted and verify the intended value through the answers read. Use the returned ETag for the next answer mutation. Do not copy proposal metadata into an answer-update request to accept a suggestion.

A settled webhook tells you the run has finished processing. Review and accept its suggestions before submitting the application. Set a polling deadline and keep the run URL so you can check again later. Check warnings and `can_retry` before using the returned `retry_url`.

## Record an application decision

Use [Decision options](https://docs.levr.ai/rest-api-reference/deal-applications/get-deal-application-decision-options.md) to read the actions available to your Portal, current recipients, and application revisions. Source and processing Portals can record outcomes; observers can only record submitted or not-submitted status when available.

Choose an action from the response: decline, mark funded, withdraw, mark timed out, reopen, or record submitted/not-submitted status. Send its URL a `POST` with the application ETag in `If-Match`, `expected_answers_revision`, a new `Idempotency-Key`, and `recipients`. Copy each selected recipient’s `email` and `origin` from the returned list, or send `[]` for no optional messages. Automatic notifications and stage automations still apply.

Before marking funded, complete the financing fields required by your Portal’s pipeline through [Update financing terms](https://docs.levr.ai/rest-api-reference/deals/update-deal-terms.md). You can include equipment details in `equipment_entries`: send the complete list you want to keep; `[]` clears it. Omit the field to preserve the existing list. If funding is confirmed before you have the funded amount, send `allow_missing_funded_amount: true` to [Mark funded](https://docs.levr.ai/rest-api-reference/deal-applications/fund-deal-application.md). It defaults to `false`. Other required fields and invalid amounts still block the action. Add the funded amount later through [Update financing terms](https://docs.levr.ai/rest-api-reference/deals/update-deal-terms.md).

Use reopen to return a closed application to submitted status.

A decision moves the Deal to the matching stage in your Portal, creating the default stage when needed. To choose a specific matching stage, supply `destination_stage_id`. Other Portals follow their stage synchronization preferences.

Marking funded may create commission obligations. Recording submitted status or reopening does not deliver the application; use [Submit](https://docs.levr.ai/rest-api-reference/deal-applications/submit-deal-application.md) to send it.

Check the returned status and revision. An identical retry returns the original result. If the application or answers have changed, read them again before deciding.


- [Decline a Deal application](https://docs.levr.ai/rest-api-reference/deal-applications/decline-deal-application.md): `POST /deal-applications/{application_id}/decline/`

- [Mark a Deal application funded](https://docs.levr.ai/rest-api-reference/deal-applications/fund-deal-application.md): `POST /deal-applications/{application_id}/fund/`

- [Mark a Deal application timed out](https://docs.levr.ai/rest-api-reference/deal-applications/timeout-deal-application.md): `POST /deal-applications/{application_id}/timeout/`

- [Record a Deal application as not submitted](https://docs.levr.ai/rest-api-reference/deal-applications/mark-not-submitted-deal-application.md): `POST /deal-applications/{application_id}/mark-not-submitted/`

- [Record a Deal application as submitted](https://docs.levr.ai/rest-api-reference/deal-applications/mark-submitted-deal-application.md): `POST /deal-applications/{application_id}/mark-submitted/`

- [Reopen a Deal application](https://docs.levr.ai/rest-api-reference/deal-applications/reopen-deal-application.md): `POST /deal-applications/{application_id}/reopen/`

- [Withdraw a Deal application](https://docs.levr.ai/rest-api-reference/deal-applications/withdraw-deal-application.md): `POST /deal-applications/{application_id}/withdraw/`

- [List available Deal application decisions](https://docs.levr.ai/rest-api-reference/deal-applications/get-deal-application-decision-options.md): `GET /deal-applications/{application_id}/decision-options/`

- [Retrieve a Deal Application](https://docs.levr.ai/rest-api-reference/deal-applications/retrieve-deal-application.md): `GET /deal-applications/{application_id}/`

- [Retrieve a Deal Application contract](https://docs.levr.ai/rest-api-reference/deal-applications/retrieve-deal-application-contract.md): `GET /deal-applications/{application_id}/contract/`

- [List Deal Application answers](https://docs.levr.ai/rest-api-reference/deal-applications/list-deal-application-answers.md): `GET /deal-applications/{application_id}/answers/`

- [Update Deal Application answers](https://docs.levr.ai/rest-api-reference/deal-applications/update-deal-application-answers.md): `PATCH /deal-applications/{application_id}/answers/`

- [List repeatable answer items](https://docs.levr.ai/rest-api-reference/deal-applications/list-deal-application-repeatable-items.md): `GET /deal-applications/{application_id}/answers/repeatable-items/`

- [Create a repeatable answer item](https://docs.levr.ai/rest-api-reference/deal-applications/create-deal-application-repeatable-item.md): `POST /deal-applications/{application_id}/answers/repeatable-items/`

- [Update a repeatable answer item](https://docs.levr.ai/rest-api-reference/deal-applications/update-deal-application-repeatable-item.md): `PATCH /deal-applications/{application_id}/answers/repeatable-items/`

- [Delete a repeatable answer item](https://docs.levr.ai/rest-api-reference/deal-applications/delete-deal-application-repeatable-item.md): `DELETE /deal-applications/{application_id}/answers/repeatable-items/`

- [List answer files](https://docs.levr.ai/rest-api-reference/deal-applications/list-deal-application-answer-files.md): `GET /deal-applications/{application_id}/answers/files/`

- [Request an answer-file upload](https://docs.levr.ai/rest-api-reference/deal-applications/create-deal-application-answer-file-upload.md): `POST /deal-applications/{application_id}/answers/files/`

- [Upload an answer file](https://docs.levr.ai/rest-api-reference/deal-applications/upload-deal-application-answer-file.md): `POST /deal-applications/{application_id}/answers/files/{upload_id}/`

- [Delete an answer file](https://docs.levr.ai/rest-api-reference/deal-applications/delete-deal-application-answer-file.md): `DELETE /deal-applications/{application_id}/answers/files/`

- [Get Deal Application autofill preparation](https://docs.levr.ai/rest-api-reference/deal-applications/get-deal-application-autofill-preparation.md): `GET /deal-applications/{application_id}/autofill-preparation/`

- [Start Deal Application autofill](https://docs.levr.ai/rest-api-reference/deal-applications/start-deal-application-autofill.md): `POST /deal-applications/{application_id}/autofill-runs/`

- [Update Deal Application autofill preparation](https://docs.levr.ai/rest-api-reference/deal-applications/update-deal-application-autofill-preparation.md): `PATCH /deal-applications/{application_id}/autofill-preparation/`

- [Upload a Deal Application autofill preparation file](https://docs.levr.ai/rest-api-reference/deal-applications/upload-deal-application-autofill-preparation-file.md): `POST /deal-applications/{application_id}/autofill-preparation/files/`

- [Get a Deal Application autofill run](https://docs.levr.ai/rest-api-reference/deal-applications/get-deal-application-autofill-run.md): `GET /deal-application-autofill-runs/{run_id}/`

- [List Deal Application autofill suggestions](https://docs.levr.ai/rest-api-reference/deal-applications/list-deal-application-autofill-suggestions.md): `GET /deal-application-autofill-runs/{run_id}/suggestions/`

- [Accept autofill suggestion](https://docs.levr.ai/rest-api-reference/deal-applications/accept-deal-application-autofill-suggestion.md): `POST /deal-application-autofill-runs/{run_id}/suggestions/{suggestion_id}/accept/`

- [Retry Deal Application autofill](https://docs.levr.ai/rest-api-reference/deal-applications/retry-deal-application-autofill.md): `POST /deal-application-autofill-runs/{run_id}/retry/`

- [Share a Deal Application with recipients by email](https://docs.levr.ai/rest-api-reference/deal-applications/share-deal-application.md): `POST /deal-applications/{application_id}/share/`

- [Check Deal Application submission readiness](https://docs.levr.ai/rest-api-reference/deal-applications/check-deal-application-submission-readiness.md): `GET /deal-applications/{application_id}/submission-readiness/`

- [Submit a Deal Application](https://docs.levr.ai/rest-api-reference/deal-applications/submit-deal-application.md): `POST /deal-applications/{application_id}/submit/`
