Document API
Use the Document API to securely embed and manage customer-specific documents such as invoices, agreements, contracts, or loading slips directly on your website. This allows your users to view, download, or even e-sign documents without leaving your platform.
document.addEventListener('DOMContentLoaded', () => {
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('key'); // Expects a secure token in the URL
const apiKey = 'YOUR_BSTD_API_KEY'; // Replace with your actual BSTD API key
if (!token) {
document.body.innerHTML = '<h3 style="color: #dc3545; text-align: center; margin-top: 50px;">Error: Missing document access token in URL.</h3>';
} else if (!apiKey || apiKey === 'YOUR_BSTD_API_KEY') {
document.body.innerHTML = '<h3 style="color: #dc3545; text-align: center; margin-top: 50px;">Error: Please provide a valid BSTD API key.</h3>';
} else {
const script = document.createElement('script');
script.src = `https://api.bstd.digital.thugo.in/api/embed/customer-docs.js?apikey=${apiKey}&key=${encodeURIComponent(token)}`;
document.head.appendChild(script);
}
});Important Tip: Ensure you pass the secure key (document token) dynamically in the URL (e.g., yourwebsite.com/docs?key=YOUR_DOCUMENT_TOKEN) to identify the customer and securely load their specific documents. Remember to replace 'YOUR_BSTD_API_KEY' with your unique API key obtained from your BSTD dashboard.