{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/en-US/guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["code-group"]},"type":"markdown"},"seo":{"title":"Simulation and Loan Origination","description":"Documentação oficial da API da plataforma de crédito embarcado Dinie. Integre produtos de crédito diretamente na sua aplicação.","siteUrl":"https://docs.dinie.com","lang":"pt-BR","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"simulation-and-loan-origination","__idx":0},"children":["Simulation and Loan Origination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Simulate installments, formalize the loan, sign the contract, and track through to disbursement."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"flow-overview","__idx":1},"children":["Flow Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["From the moment the customer has a credit offer available, the flow goes through three steps on ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["your platform"]}," (simulate, create, sign) while ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Dinie"]}," processes each phase and notifies via webhooks."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/credit-lifecycle.a1e43c369a5c79f69948d37608104cb14ba59f5686b4dc79c97e3608d76b2c26.047687d6.svg","alt":"Credit lifecycle"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Status"},"children":["Status"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["available"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Offer ready for simulation"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["awaiting_signatures"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Loan created, awaiting CCB contract signatures"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["processing"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["All signatures collected, processing disbursement"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["active"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Funds deposited, payment cycle started"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["finished"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Loan fully paid"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cancelled"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Loan cancelled"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Processing error"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"list-offers","__idx":2},"children":["List Offers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the customer opens the app to take out a loan, retrieve the available offers:"]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"const offers = await client.customers.listCreditOffers(\n  \"cust_550e8400...\",\n  { status: \"available\" }\n);\n\nconst offer = offers.data[0];\nconsole.log(`R$ ${offer.approvedAmount} at ${offer.interestRate}% per month`);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"offers = client.customers.list_credit_offers(\n  \"cust_550e8400...\",\n  status: \"available\"\n)\n\noffer = offers.data.first\nputs \"R$ #{offer.approved_amount} at #{offer.interest_rate}% per month\"\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"offers = client.customers.list_credit_offers(\n    \"cust_550e8400...\",\n    status=\"available\",\n)\n\noffer = offers.data[0]\nprint(f\"R$ {offer.approved_amount} at {offer.interest_rate}% per month\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"cURL","header":{"title":"cURL","controls":{"copy":{}}},"source":"curl \"https://sandbox.api.dinie.com.br/v3/customers/cust_550e8400.../credit-offers?status=available\" \\\n  -H \"Authorization: Bearer dinie_at_...\"\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"simulate-terms","__idx":3},"children":["Simulate Terms"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Simulate a loan scenario by providing the desired amount and number of installments. Each call returns a simulation with the calculated terms. The customer can simulate as many times as they want -- only the latest simulation is valid for loan origination."]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"const simulation = await client.creditOffers.simulate(offer.id, {\n  requestedAmount: 25000.00,\n  installmentCount: 4,\n});\n\nconsole.log(`${simulation.installmentCount}x of R$ ${simulation.installmentAmount}`);\nconsole.log(`Total: R$ ${simulation.totalAmount} | CET: ${simulation.cetRate}% p.a.`);\nconsole.log(`First due date: ${simulation.firstDueDate}`);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"simulation = client.credit_offers.simulate(\n  offer.id,\n  requested_amount: 25000.00,\n  installment_count: 4\n)\n\nputs \"#{simulation.installment_count}x of R$ #{simulation.installment_amount}\"\nputs \"Total: R$ #{simulation.total_amount} | CET: #{simulation.cet_rate}% p.a.\"\nputs \"First due date: #{simulation.first_due_date}\"\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"simulation = client.credit_offers.simulate(\n    offer.id,\n    requested_amount=25000.00,\n    installment_count=4,\n)\n\nprint(f\"{simulation.installment_count}x of R$ {simulation.installment_amount}\")\nprint(f\"Total: R$ {simulation.total_amount} | CET: {simulation.cet_rate}% p.a.\")\nprint(f\"First due date: {simulation.first_due_date}\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"cURL","header":{"title":"cURL","controls":{"copy":{}}},"source":"curl -X POST \"https://sandbox.api.dinie.com.br/v3/credit-offers/${OFFER_ID}/simulations\" \\\n  -H \"Authorization: Bearer dinie_at_...\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"requested_amount\": 25000.00,\n    \"installment_count\": 4\n  }'\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The simulation returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installment_amount"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["total_amount"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requested_amount"]}," (requested value), ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["principal_amount"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["iof_amount"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fee_amount"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["interest_rate"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cet_rate"]}," (annualized Total Effective Cost (CET))."]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Info:"]}," The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installment_count"]}," field depends on the offer. Some offers allow the customer to choose between different terms -- in that case, you can simulate with different values. If the offer defines a fixed term, use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installments"]}," returned in the offer."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tip:"]}," Monetary values and rates are JSON numbers (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["25000.00"]},"), both in the SDKs and via HTTP directly."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"create-a-loan","__idx":4},"children":["Create a Loan"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the customer chooses the desired simulation, formalize the loan. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installment_count"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installment_amount"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["first_due_date"]}," fields must match the referenced simulation exactly."]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"const loan = await client.loans.create({\n  creditOfferId: offer.id,\n  simulationId: simulation.id,\n  installmentCount: simulation.installmentCount,\n  installmentAmount: simulation.installmentAmount,\n  firstDueDate: simulation.firstDueDate,\n});\n\nconsole.log(loan.id);     // \"ln_550e8400...\"\nconsole.log(loan.status); // \"awaiting_signatures\"\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"loan = client.loans.create(\n  credit_offer_id: offer.id,\n  simulation_id: simulation.id,\n  installment_count: simulation.installment_count,\n  installment_amount: simulation.installment_amount,\n  first_due_date: simulation.first_due_date\n)\n\nputs loan.id      # \"ln_550e8400...\"\nputs loan.status  # \"awaiting_signatures\"\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"loan = client.loans.create(\n    credit_offer_id=offer.id,\n    simulation_id=simulation.id,\n    installment_count=simulation.installment_count,\n    installment_amount=simulation.installment_amount,\n    first_due_date=simulation.first_due_date,\n)\n\nprint(loan.id)      # \"ln_550e8400...\"\nprint(loan.status)  # \"awaiting_signatures\"\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"cURL","header":{"title":"cURL","controls":{"copy":{}}},"source":"curl -X POST https://sandbox.api.dinie.com.br/v3/loans \\\n  -H \"Authorization: Bearer dinie_at_...\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: create-loan-${OFFER_ID}\" \\\n  -d '{\n    \"credit_offer_id\": \"co_550e8400...\",\n    \"simulation_id\": \"sim_550e8400...\",\n    \"installment_count\": 4,\n    \"installment_amount\": 7997.34,\n    \"first_due_date\": \"2026-04-03\"\n  }'\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning:"]}," If ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installment_count"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["installment_amount"]},", or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["first_due_date"]}," do not match the simulation values, the request is rejected with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["simulation_mismatch"]}," error. Always use the exact values returned by the simulation."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sign-the-contract","__idx":5},"children":["Sign the Contract"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the loan is created, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["signing_url"]}," is immediately available in the response. Present it to the customer:"]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"// After creating the loan, the signing_url is available immediately:\nconst loan = await client.loans.create({ /* ... */ });\n\nif (loan.signingUrl) {\n  // Open loan.signingUrl in the customer's browser\n  // The customer signs the CCB contract directly on this page\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"# After creating the loan, the signing_url is available immediately:\nloan = client.loans.create(# ...)\n\nif loan.signing_url\n  # Open loan.signing_url in the customer's browser\n  # The customer signs the CCB contract directly on this page\nend\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"# After creating the loan, the signing_url is available immediately:\nloan = client.loans.create(# ...)\n\nif loan.signing_url:\n    # Open loan.signing_url in the customer's browser\n    # The customer signs the CCB contract directly on this page\n    pass\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"cURL","header":{"title":"cURL","controls":{"copy":{}}},"source":"# The signing_url is included in the loan creation response\n# Use it to redirect the customer to sign the CCB contract\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After all signatures are collected, the loan advances automatically: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["awaiting_signatures"]}," -> ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["processing"]}," -> ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["active"]},". You receive webhooks at each stage."]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"switch (event.type) {\n  case \"loan.processing\":\n    notifyCustomer(event.data.id,\n      \"All signatures collected! We are processing the transfer.\");\n    break;\n\n  case \"loan.active\":\n    notifyCustomer(event.data.id,\n      `R$ ${event.data.requested_amount} has been deposited into your account!`);\n    break;\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"case event[\"type\"]\nwhen \"loan.processing\"\n  notify_customer(event.dig(\"data\", \"id\"),\n    \"All signatures collected! We are processing the transfer.\")\nwhen \"loan.active\"\n  notify_customer(event.dig(\"data\", \"id\"),\n    \"R$ #{event.dig('data', 'requested_amount')} has been deposited into your account!\")\nend\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"match event[\"type\"]:\n    case \"loan.processing\":\n        notify_customer(event[\"data\"][\"id\"],\n            \"All signatures collected! We are processing the transfer.\")\n    case \"loan.active\":\n        notify_customer(event[\"data\"][\"id\"],\n            f\"R$ {event['data']['requested_amount']} has been deposited into your account!\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"cURL","header":{"title":"cURL","controls":{"copy":{}}},"source":"# Webhooks are received via POST at your configured endpoint.\n# Example loan.processing payload:\n# {\n#   \"type\": \"loan.processing\",\n#   \"data\": {\n#     \"id\": \"ln_550e8400...\",\n#     \"status\": \"processing\"\n#   }\n# }\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-step","__idx":6},"children":["Next Step"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When your integration is working in sandbox, follow the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/en-us/guides/going-to-production"},"children":["Going to Production"]}," checklist."]}]},"headings":[{"value":"Simulation and Loan Origination","id":"simulation-and-loan-origination","depth":1},{"value":"Flow Overview","id":"flow-overview","depth":2},{"value":"List Offers","id":"list-offers","depth":2},{"value":"Simulate Terms","id":"simulate-terms","depth":2},{"value":"Create a Loan","id":"create-a-loan","depth":2},{"value":"Sign the Contract","id":"sign-the-contract","depth":2},{"value":"Next Step","id":"next-step","depth":2}],"frontmatter":{"seo":{"title":"Simulation and Loan Origination"}},"lastModified":"2026-03-19T21:33:16.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/en-us/guides/credit-workflow","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}