# Loan simulation To run a digital lending product, your system must send API requests to the Pismo platform and handle asynchronous event messages in response. Some workflows are completed over multiple requests and events. For more information on loan simulations, refer to the [Simulation service](https://developers.pismo.io/pismo-docs/reference/simulation-service) guide. Although the Pismo platform returns informative responses to your API requests, you should build your system to respond to the asynchronous events. For more information on receiving event data from the Pismo platform, refer to [Data and reporting overview](https://developers.pismo.io/pismo-docs/docs/data-reporting-overview). # Simulate, book, and disburse a loan To book a loan, you begin by using a loan product to simulate the booking. If the customer does not agree to the terms and conditions shown in the simulation, you have the option of simulating another loan (using a different loan product). If the customer agrees to the terms and conditions, you use the simulation to book the loan. How the funds are disbursed (in one lump sum or in stages) is determined by how you set up the loan product, but you need to call the [Disburse loan V2](disburseloanv2) endpoint to perform the actual disbursal. # Simulate loan booking To simulate a loan booking, use the [Create simulation](https://developers.pismo.io/pismo-docs/reference/post-v1-simulation) endpoint. ### Your system Sends a POST to payment-methods-admin/v1/simulations with the following payload: ```json { "authorization_mode": "CREDIT" } ``` ### Pismo platform Generates the [Loan simulation created](https://developers.pismo.io/events/docs/lending-loan-simulation-creation-1) event: ```json { org_id: "89e56522-726a-453e-ba6d-796b03245128", simulation_id: "afedc8b0-86b2-41ca-87a3-3481df17261b", product_id: "BNPL_PRODUCT_2022", product_version: "1", loan_amount: 1000.0, start_date: "2022-10-24", disbursment_schedule: [ "2022-10-24", "2022-11-24", ... ], stages: \[ { period: 12, interest_rate: { unit: "YEAR", value: 0.12 } }, ... } } ``` # Create loan booking To create a loan booking, use the [Book loan v2](https://developers.pismo.io/pismo-docs/reference/bookloanv2) endpoint. ### Your system Sends a POST to /lending/v2/loans with the following payload: ```curl curl --request POST \ --url https://sandbox.pismolabs.io/lending/v2/loans \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` ### Pismo platform Generates a [loan\_booked-1](https://developers.pismo.io/events/docs/lending-loan-booked-1) event: ```json { "org_id": "TN-89e56522-726a-453e-ba6d-796b03245128", "external_id": "cca6041c-b57d-44cf-a203-eeea22723878", "loan_id": "ded913af-abc9-4769-b179-068ed6181ec5", "status": "BOOKED", "product_id": "89e56522-726a-453e-ba6d-796b03245128", "account_id": 104336697, "amount": 1000.0, "start_date": "2022-10-24", "created_at": "2022-10-24T21:34:47" } ``` # Disburse loan To disburse a loan, use the [Disburse loan v2](https://developers.pismo.io/pismo-docs/reference/disburseloanv2) endpoint. ### Your system Sends a POST to /lending/v2/loans/\{loanId}/disburse. In the following example request, loanId is "2717a296-124a-47cc-b2a1-91e80dc723eb": ```curl curl --request POST \ --url https://sandbox.pismolabs.io/lending/v2/loans/2717a296-124a-47cc-b2a1-91e80dc723eb/disburse \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "disbursement_account": { "account_type": "INTERNAL" } } ' ``` ### Pismo platform Generates a [Loan disbursement V2 status changed](https://developers.pismo.io/events/docs/lending-loan-disbursement-status-change-2) event: ```json { "loan_id": "2717a296-124a-47cc-b2a1-91e80dc723eb", "org_id": "TN-89e56522-726a-453e-ba6d-796b03245128", "disbursement_id": "89e56522-726a-453e-ba6d-796b03245128", "idempotency_key": "48704d83-0412-431f-816a-50ba81451148", "currency": "USD", "created_at": "2022-10-24T21:34:47", "updated_at": "2022-10-24T21:34:47", "previous_disbursement_status": "SCHEDULED", "current_disbursement_status": "PROCESSING", "disbursement_amount": 1234.56, "disbursement_account": { "account_type": "INTERNAL", "account_id": 221123 }, "authorization_id": 1231231, "authorization_tracking_id": "ded913af-abc9-4769-b179-068ed6181ec5", "disbursement_date": "2022-10-24" } ```