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.
<script>
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'; // <strong>Replace with your actual BSTD API key</strong>
if (!token) {
// Display an error if the token is missing
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') {
// Display an error if the API key is missing or default
document.body.innerHTML = '<h3 style="color: #dc3545; text-align: center; margin-top: 50px;">Error: Please provide a valid BSTD API key.</h3>';
}
else {
// Append the script to load the document viewer
const script = document.createElement('script');
script.src = `https://bstd.digital.thugo.in/api/embed/customer-docs.js?apikey=${apiKey}&key=${encodeURIComponent(token)}`;
document.head.appendChild(script);
}
});
</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.