### Get All Suppliers Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of all suppliers for a specific company, with pagination options. ```bash curl -X POST https://api.moloni.pt/v1/suppliers/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "offset=0" \ -d "qty=50" ``` -------------------------------- ### Get Product Stock Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve the stock information for a specific product across all warehouses or for a specific warehouse. ```bash curl -X POST https://api.moloni.pt/v1/productStocks/getStockMovement/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "product_id=PRODUCT_ID" \ -d "warehouse_id=WAREHOUSE_ID" ``` -------------------------------- ### Get All Measurement Units Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of measurement units that can be assigned to products in a specific company. ```bash curl -X POST https://api.moloni.pt/v1/measurementUnits/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" ``` -------------------------------- ### Get All Suppliers - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of suppliers for a specific company. You can paginate the results using offset and qty parameters. ```bash curl -X POST https://api.moloni.pt/v1/productCategories/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "parent_id=PARENT_CATEGORY_ID" \ -d "offset=0" \ -d "qty=50" ``` -------------------------------- ### Create New Product - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Example JavaScript object structure for a new product payload and the fetch call to create it via the Moloni API. ```javascript { stock: "100", taxes: [ { tax_id: 12345, order: 0, cumulative: 0 } ] }; ``` ```javascript fetch('https://api.moloni.pt/v1/products/insert/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(newProduct) }) .then(response => response.json()) .then(data => console.log('New Product Created:', data)) .catch(error => console.error('Error Creating Product:', error)); ``` -------------------------------- ### Get All Maturity Dates Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of maturity date options configured in a specific company. These options define payment deadlines that can be applied to documents. ```bash curl -X POST https://api.moloni.pt/v1/maturityDates/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" ``` -------------------------------- ### Get All Warehouses Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of warehouses for a specific company. This information is useful when managing product stock across multiple locations. ```bash curl -X POST https://api.moloni.pt/v1/warehouses/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" ``` -------------------------------- ### Example Invoice Payload Structure Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Provides a sample JSON object structure used as the request body for creating a new invoice via the Moloni API. ```json { "company_id": 123456, "customer_id": 654321, "date": "2023-07-01", "expiration_date": "2023-08-01", "document_set_id": 12345, "products": [ { "product_id": 123456, "qty": 2, "price": 10.99, "discount": 0 }, { "product_id": 654321, "qty": 1, "price": 24.99, "discount": 5 } ], "status": 1 } ``` -------------------------------- ### Get All Customers - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of customers for a specific company. You can filter the results by various parameters and paginate the results using the offset and qty parameters. ```bash curl -X POST https://api.moloni.pt/v1/customers/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "offset=0" \ -d "qty=50" ``` ```javascript const companyId = 123456; // Replace with your company ID fetch('https://api.moloni.pt/v1/customers/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, offset: 0, qty: 50 }) }) .then(response => response.json()) .then(data => console.log('Customers:', data)) .catch(error => console.error('Error Fetching Customers:', error)); ``` -------------------------------- ### Get All Tax Rates Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of available tax rates for a specific company. This information is required when creating products that need tax information. ```bash curl -X POST https://api.moloni.pt/v1/taxes/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" ``` -------------------------------- ### Get Available Payment Methods Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of available payment methods for a specific company. This information is useful when creating documents that require payment method selection. ```bash curl -X POST https://api.moloni.pt/v1/paymentMethods/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" ``` -------------------------------- ### Get Document PDF Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Generate and retrieve a PDF version of a specific document. This endpoint returns a base64-encoded string of the PDF file. ```bash curl -X POST https://api.moloni.pt/v1/documents/getPDF/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "document_id=DOCUMENT_ID" ``` -------------------------------- ### Get All Products Moloni API Bash Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This Bash snippet uses curl to retrieve a list of products from the Moloni API. It sends a POST request with the company ID and optional filtering/pagination parameters (category_id, offset, qty) as form data. An access token is required for authorization. ```bash curl -X POST https://api.moloni.pt/v1/products/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "category_id=CATEGORY_ID" \ -d "offset=0" \ -d "qty=50" ``` -------------------------------- ### Get All Maturity Dates Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of maturity date options configured in a specific company. These options define payment deadlines that can be applied to documents. ```javascript const companyId = 123456; // Replace with your company ID fetch('https://api.moloni.pt/v1/maturityDates/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId }) }) .then(response => response.json()) .then(data => console.log('Maturity Dates:', data)) .catch(error => console.error('Error Fetching Maturity Dates:', error)); ``` -------------------------------- ### Get Available Document Sets Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of document series (sets) for a specific company and document type. This information is required when creating invoices and other documents. ```bash curl -X POST https://api.moloni.pt/v1/documentSets/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "document_type_id=DOCUMENT_TYPE_ID" ``` -------------------------------- ### Get Sales Analysis by Product Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve sales analysis data grouped by product for a specific company. This endpoint provides insights into product performance and sales trends. ```bash curl -X POST https://api.moloni.pt/v1/documents/getSalesByProduct/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "start_date=START_DATE" \ -d "end_date=END_DATE" ``` -------------------------------- ### Get All Products Moloni API JavaScript Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JavaScript snippet uses the fetch API to retrieve a list of products for a specific company from the Moloni API. It sends a POST request with the company ID and optional category, offset, and quantity parameters in the JSON request body. An access token is needed for authentication. ```javascript const companyId = 123456; // Replace with your company ID const categoryId = 12345; // Replace with your category ID fetch('https://api.moloni.pt/v1/products/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, category_id: categoryId, offset: 0, qty: 50 }) }) .then(response => response.json()) .then(data => console.log('Products:', data)) .catch(error => console.error('Error Fetching Products:', error)); ``` -------------------------------- ### Get Customer by ID - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve detailed information about a specific customer by providing their unique customer ID and the company ID they belong to. ```bash curl -X POST https://api.moloni.pt/v1/customers/getOne/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "customer_id=CUSTOMER_ID" ``` ```javascript const companyId = 123456; // Replace with your company ID const customerId = 789012; // Replace with your customer ID fetch('https://api.moloni.pt/v1/customers/getOne/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, customer_id: customerId }) }) .then(response => response.json()) .then(data => console.log('Customer Details:', data)) .catch(error => console.error('Error Fetching Customer Details:', error)); ``` -------------------------------- ### Get All Product Categories - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of product categories for a specific company. You can filter by parent category ID and paginate the results. ```bash curl -X POST https://api.moloni.pt/v1/productCategories/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "parent_id=PARENT_CATEGORY_ID" \ -d "offset=0" \ -d "qty=50" ``` ```javascript const companyId = 123456; // Replace with your company ID const parentId = 0; // 0 for top-level categories or a parent ID fetch('https://api.moloni.pt/v1/productCategories/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, parent_id: parentId, offset: 0, qty: 50 }) }) .then(response => response.json()) .then(data => console.log('Product Categories:', data)) .catch(error => console.error('Error Fetching Product Categories:', error)); ``` -------------------------------- ### Get Document PDF (JS Fragment) Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Fragment of a JavaScript fetch request to generate and retrieve a PDF version of a specific document. ```javascript const companyId = 123456; // Replace with your company ID const documentId = 901234; // Replace with your document ID fetch('https://api.moloni.pt/v1/documents/getPDF/', { method: 'POST', headers: { ``` -------------------------------- ### Get Sales Analysis by Product Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve sales analysis data grouped by product for a specific company. This endpoint provides insights into product performance and sales trends. ```javascript const companyId = 123456; // Replace with your company ID const startDate = "2023-01-01"; const endDate = "2023-12-31"; fetch('https://api.moloni.pt/v1/documents/getSalesByProduct/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, start_date: startDate, end_date: endDate }) }) .then(response => response.json()) .then(data => console.log('Sales Analysis by Product:', data)) .catch(error => console.error('Error Fetching Product Sales Analysis:', error)); ``` -------------------------------- ### Getting All Moloni API Companies Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of all companies associated with the authenticated user. This endpoint provides basic information about each company including ID, name, and VAT number. ```bash curl -X POST https://api.moloni.pt/v1/companies/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ```javascript fetch('https://api.moloni.pt/v1/companies/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log('Companies:', data)) .catch(error => console.error('Error Fetching Companies:', error)); ``` -------------------------------- ### Get All Currencies - Moloni API - multiple Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of currencies available in the Moloni platform. This information is useful when configuring company settings or creating documents with specific currency requirements. Snippets show how to fetch the data using bash (curl) and JavaScript (fetch). ```bash curl -X POST https://api.moloni.pt/v1/currencies/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ```javascript fetch('https://api.moloni.pt/v1/currencies/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log('Currencies:', data)) .catch(error => console.error('Error Fetching Currencies:', error)); ``` -------------------------------- ### Getting Moloni API User Information (agentMe) Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve information about the currently authenticated user. This endpoint provides details about the user account that is accessing the Moloni platform through the API. ```bash curl -X POST https://api.moloni.pt/v1/agentMe/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ```javascript fetch('https://api.moloni.pt/v1/agentMe/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log('User Information:', data)) .catch(error => console.error('Error Fetching User Info:', error)); ``` -------------------------------- ### Getting Moloni API Company Details Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve detailed information about a specific company by providing its ID. The response includes comprehensive company data, including contact information, fiscal details, and settings. ```bash curl -X POST https://api.moloni.pt/v1/companies/getOne/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" ``` ```javascript const companyId = 123456; // Replace with your company ID fetch('https://api.moloni.pt/v1/companies/getOne/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId }) }) .then(response => response.json()) .then(data => console.log('Company Details:', data)) .catch(error => console.error('Error Fetching Company Details:', error)); ``` -------------------------------- ### Get Product by ID Moloni API Bash Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This Bash snippet uses curl to fetch detailed information for a single product from the Moloni API. It sends a POST request with the required company ID and product ID as form data parameters. Authorization is handled via a Bearer token. ```bash curl -X POST https://api.moloni.pt/v1/products/getOne/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "product_id=PRODUCT_ID" ``` -------------------------------- ### Get Invoice by ID - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve detailed information about a specific invoice by providing its unique document ID and the company ID it belongs to. ```bash curl -X POST https://api.moloni.pt/v1/invoices/getOne/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "document_id=DOCUMENT_ID" ``` ```javascript const companyId = 123456; // Replace with your company ID const documentId = 901234; // Replace with your document ID fetch('https://api.moloni.pt/v1/invoices/getOne/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, document_id: documentId }) }) .then(response => response.json()) .then(data => console.log('Invoice Details:', data)) .catch(error => console.error('Error Fetching Invoice Details:', error)); ``` -------------------------------- ### Get Product Stock Totals - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve the current stock levels for products in a specific company. This endpoint provides a summary of available inventory across all warehouses or filtered by specific criteria. ```bash curl -X POST https://api.moloni.pt/v1/productStocks/getTotals/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "category_id=CATEGORY_ID" \ -d "warehouse_id=WAREHOUSE_ID" \ -d "offset=0" \ -d "qty=50" ``` ```javascript const companyId = 123456; // Replace with your company ID const categoryId = 0; // 0 for all categories or specify a category ID const warehouseId = 0; // 0 for all warehouses or specify a warehouse ID fetch('https://api.moloni.pt/v1/productStocks/getTotals/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, category_id: categoryId, warehouse_id: warehouseId, offset: 0, qty: 50 }) }) .then(response => response.json()) .then(data => console.log('Product Stock Totals:', data)) .catch(error => console.error('Error Fetching Stock Totals:', error)); ``` -------------------------------- ### Get All Languages - Moloni API - multiple Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of languages available in the Moloni platform. This information is useful when configuring document templates and communication preferences. Snippets show how to fetch the data using bash (curl) and JavaScript (fetch). ```bash curl -X POST https://api.moloni.pt/v1/languages/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ```javascript fetch('https://api.moloni.pt/v1/languages/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log('Languages:', data)) .catch(error => console.error('Error Fetching Languages:', error)); ``` -------------------------------- ### Get Sales Analysis by Date (JS Fragment) Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Fragment of a JavaScript fetch request to retrieve sales analysis data grouped by date for a specific company. ```javascript 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, start_date: startDate, end_date: endDate }) }) .then(response => response.json()) .then(data => console.log('Sales Analysis by Date:', data)) .catch(error => console.error('Error Fetching Sales Analysis:', error)); ``` -------------------------------- ### Get Stock Movements Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of stock movements for products in a specific company. This endpoint allows tracking inventory changes over time with details about the type of movement, quantity, and related documents. ```bash curl -X POST https://api.moloni.pt/v1/productStocks/getMovements/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "product_id=PRODUCT_ID" \ -d "offset=0" \ -d "qty=50" ``` ```javascript const companyId = 123456; // Replace with your company ID const productId = 345678; // Replace with your product ID fetch('https://api.moloni.pt/v1/productStocks/getMovements/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, product_id: productId, offset: 0, qty: 50 }) }) .then(response => response.json()) .then(data => console.log('Stock Movements:', data)) .catch(error => console.error('Error Fetching Stock Movements:', error)); ``` -------------------------------- ### Get All Invoices - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of invoices for a specific company. You can filter by customer ID, date range, and document set ID, as well as paginate the results. ```bash curl -X POST https://api.moloni.pt/v1/invoices/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "customer_id=CUSTOMER_ID" \ -d "offset=0" \ -d "qty=50" ``` ```javascript const companyId = 123456; // Replace with your company ID const customerId = 789012; // Replace with your customer ID (optional) fetch('https://api.moloni.pt/v1/invoices/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, customer_id: customerId, offset: 0, qty: 50 }) }) .then(response => response.json()) .then(data => console.log('Invoices:', data)) .catch(error => console.error('Error Fetching Invoices:', error)); ``` -------------------------------- ### Get Document PDF - Moloni API - bash Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Generate and retrieve a PDF version of a specific document from the Moloni API. This endpoint returns a base64-encoded string of the PDF file. This snippet shows how to call the endpoint using curl. ```bash curl -X POST https://api.moloni.pt/v1/documents/getPDF/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "document_id=DOCUMENT_ID" ``` -------------------------------- ### Get Product by ID Moloni API JavaScript Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JavaScript snippet uses the fetch API to retrieve details for a specific product from the Moloni API. It sends a POST request including the company ID and product ID in the JSON request body. A valid access token is required for the request. ```javascript const companyId = 123456; // Replace with your company ID const productId = 345678; // Replace with your product ID fetch('https://api.moloni.pt/v1/products/getOne/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, product_id: productId }) }) .then(response => response.json()) .then(data => console.log('Product Details:', data)) .catch(error => console.error('Error Fetching Product Details:', error)); ``` -------------------------------- ### Get All Countries - Moloni API - multiple Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve a list of countries available in the Moloni platform. This information is useful when creating or updating entities like customers, suppliers, or company details. Snippets show how to fetch the data using bash (curl) and JavaScript (fetch). ```bash curl -X POST https://api.moloni.pt/v1/countries/getAll/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ```javascript fetch('https://api.moloni.pt/v1/countries/getAll/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log('Countries:', data)) .catch(error => console.error('Error Fetching Countries:', error)); ``` -------------------------------- ### Get Sales Analysis by Date - Moloni API - multiple Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Retrieve sales analysis data grouped by date for a specific company using the Moloni API. This endpoint provides summarized sales information for reporting and business analysis. Snippets show how to fetch the data using bash (curl) and JavaScript (fetch). ```bash curl -X POST https://api.moloni.pt/v1/documents/getSalesByDate/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "start_date=START_DATE" \ -d "end_date=END_DATE" ``` ```javascript const companyId = 123456; // Replace with your company ID const startDate = "2023-01-01"; const endDate = "2023-12-31"; fetch('https://api.moloni.pt/v1/documents/getSalesByDate/', { method: 'POST', headers: { ``` -------------------------------- ### Insert Product Stock Movement - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a manual stock entry movement for a product in a specific company. This endpoint allows adjusting stock levels directly without the need for a document. ```bash curl -X POST https://api.moloni.pt/v1/productStocks/insert/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "product_id=PRODUCT_ID" \ -d "warehouse_id=WAREHOUSE_ID" \ -d "stock=STOCK_AMOUNT" \ -d "notes=NOTES" ``` ```javascript const companyId = 123456; // Replace with your company ID const productId = 345678; // Replace with your product ID const warehouseId = 56789; // Replace with your warehouse ID const newStockMovement = { company_id: companyId, product_id: productId, warehouse_id: warehouseId, stock: 10, notes: "Manual stock adjustment" }; fetch('https://api.moloni.pt/v1/productStocks/insert/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(newStockMovement) }) .then(response => response.json()) .then(data => console.log('Stock Movement Created:', data)) .catch(error => console.error('Error Creating Stock Movement:', error)); ``` -------------------------------- ### Insert New Product Moloni API JavaScript Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JavaScript snippet uses the fetch API to send a POST request to the Moloni product insert endpoint. It requires a valid access token and a JSON payload containing the details of the new product to be created, including company ID and product attributes. ```javascript const companyId = 123456; // Replace with your company ID const newProduct = { company_id: companyId, category_id: 123456, type: "1", name: "Sample Product", reference: "PROD001", price: "10.99", unit_id: 12345, has_stock: "1", ``` -------------------------------- ### Create Invoice using JavaScript Fetch Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Demonstrates how to create a new invoice using the Moloni API v1 invoices/insert endpoint with JavaScript's fetch API. It sends a POST request with the invoice data in JSON format. ```javascript const companyId = 123456; // Replace with your company ID const customerId = 654321; // Replace with your customer ID const newInvoice = { company_id: companyId, customer_id: customerId, date: "2023-07-01", expiration_date: "2023-08-01", document_set_id: 12345, products: [ { product_id: 123456, qty: 2, price: 10.99, discount: 0 }, { product_id: 654321, qty: 1, price: 24.99, discount: 5 } ], status: 1 }; fetch('https://api.moloni.pt/v1/invoices/insert/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(newInvoice) }) .then(response => response.json()) .then(data => console.log('New Invoice Created:', data)) .catch(error => console.error('Error Creating Invoice:', error)); ``` -------------------------------- ### Insert New Customer - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a new customer in a specific company. The endpoint requires various customer details like name, VAT number, email, and address information. ```json { "company_id": 123456, "vat": "123456789", "number": "CLIENT001", "name": "Sample Client", "language_id": 1, "address": "Sample Street, 123", "zip_code": "1234-567", "city": "Sample City", "country_id": 1, "email": "client@example.com", "phone": "123456789", "website": "https://www.example.com", "payment_method_id": 1234, "maturity_date_id": 1234, "salesman_id": 1234, "copies": 1 } ``` ```javascript const companyId = 123456; // Replace with your company ID const newCustomer = { company_id: companyId, vat: "123456789", number: "CLIENT001", name: "Sample Client", language_id: 1, address: "Sample Street, 123", zip_code: "1234-567", city: "Sample City", country_id: 1, email: "client@example.com", phone: "123456789", website: "https://www.example.com", payment_method_id: 1234, maturity_date_id: 1234, salesman_id: 1234, copies: 1 }; fetch('https://api.moloni.pt/v1/customers/insert/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(newCustomer) }) .then(response => response.json()) .then(data => console.log('New Customer Created:', data)) .catch(error => console.error('Error Creating Customer:', error)); ``` -------------------------------- ### Create Purchase Order - Moloni API - JSON Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a purchase order for a specific company using the Moloni API. Purchase orders are documents sent to suppliers to request products or services. This snippet shows the required JSON payload. ```json { "company_id": 123456, "supplier_id": 654321, "date": "2023-07-01", "expiration_date": "2023-08-01", "document_set_id": 12345, "products": [ { "product_id": 123456, "qty": 10, "price": 8.99, "discount": 0 } ], "notes": "Please deliver as soon as possible", "status": 1 } ``` -------------------------------- ### Authenticating with Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Authenticate with the Moloni API using OAuth2 flow to obtain an access token. The API requires a client ID and client secret, which you can obtain by creating an API client in your Moloni account settings. ```bash curl -X POST https://api.moloni.pt/v1/grant/ \ -d "grant_type=password" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "username=YOUR_USERNAME" \ -d "password=YOUR_PASSWORD" ``` ```javascript const authData = { grant_type: "password", client_id: "YOUR_CLIENT_ID", client_secret: "YOUR_CLIENT_SECRET", username: "YOUR_USERNAME", password: "YOUR_PASSWORD" }; fetch('https://api.moloni.pt/v1/grant/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(authData) }) .then(response => response.json()) .then(data => { // Store the access token for future requests const accessToken = data.access_token; console.log('Authentication successful:', data); }) .catch(error => console.error('Authentication Error:', error)); ``` -------------------------------- ### Insert New Product Data Structure Moloni API JSON Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JSON object defines the structure and required fields for creating a new product via the Moloni API. It includes details such as company and category IDs, product type, name, reference, price, unit, stock information, and tax details. ```json { "company_id": 123456, "category_id": 123456, "type": "1", "name": "Sample Product", "reference": "PROD001", "price": "10.99", "unit_id": 12345, "has_stock": "1", "stock": "100", "taxes": [ { "tax_id": 12345, "order": 0, "cumulative": 0 } ] } ``` -------------------------------- ### Create Simplified Invoice Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a simplified invoice for a specific company. This document type is often used for smaller transactions and has fewer required fields than a full invoice. ```json { "company_id": 123456, "customer_id": 654321, "date": "2023-07-01", "document_set_id": 12345, "products": [ { "product_id": 123456, "qty": 1, "price": 10.99, "discount": 0 } ], "status": 1 } ``` -------------------------------- ### Create Delivery Note - Moloni API - JSON Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a delivery note for a specific company using the Moloni API. Delivery notes are documents that accompany goods being delivered to customers. This snippet shows the required JSON payload. ```json { "company_id": 123456, "customer_id": 654321, "date": "2023-07-01", "document_set_id": 12345, "products": [ { "product_id": 123456, "qty": 2, "price": 10.99, "discount": 0 } ], "delivery_method_id": 12345, "delivery_datetime": "2023-07-02 14:00:00", "status": 1 } ``` -------------------------------- ### Insert New Supplier Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a new supplier in a specific company. The endpoint requires similar details as the customer insertion endpoint. ```json { "company_id": 123456, "vat": "123456789", "number": "SUPP001", "name": "Sample Supplier", "language_id": 1, "address": "Sample Street, 123", "zip_code": "1234-567", "city": "Sample City", "country_id": 1, "email": "supplier@example.com", "phone": "123456789", "payment_method_id": 1234, "maturity_date_id": 1234 } ``` -------------------------------- ### Update Product - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Update an existing product's information in a specific company by providing the product ID and the fields to be updated. ```json { "company_id": 123456, "product_id": 654321, "name": "Updated Product Name", "price": "12.99", "stock": "75" } ``` ```javascript const companyId = 123456; // Replace with your company ID const productId = 654321; // Replace with your product ID const updateData = { company_id: companyId, product_id: productId, name: "Updated Product Name", price: "12.99", stock: "75" }; fetch('https://api.moloni.pt/v1/products/update/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(updateData) }) .then(response => response.json()) .then(data => console.log('Product Update Result:', data)) .catch(error => console.error('Error Updating Product:', error)); ``` -------------------------------- ### Create Maturity Date Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a new maturity date option in a specific company. This endpoint allows defining custom payment deadline options for invoices and other documents. ```bash curl -X POST https://api.moloni.pt/v1/maturityDates/insert/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "name=NAME" \ -d "value=VALUE" ``` -------------------------------- ### Create Credit Note Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a credit note for a specific company. Credit notes are used to refund or correct invoices that have already been issued. ```json { "company_id": 123456, "customer_id": 654321, "date": "2023-07-01", "document_set_id": 12345, "associated_documents": [ { "document_id": 987654, "id": 1 } ] } ``` -------------------------------- ### Updating Customer Moloni API JavaScript Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JavaScript snippet uses the fetch API to send a POST request to the Moloni customer update endpoint. It requires a valid access token and the customer data payload, including company and customer IDs, formatted as JSON. ```javascript const companyId = 123456; // Replace with your company ID const customerId = 654321; // Replace with your customer ID const updateData = { company_id: companyId, customer_id: customerId, name: "Updated Client Name", email: "updated_email@example.com", address: "Updated Street, 456", zip_code: "7654-321", city: "Updated City" }; fetch('https://api.moloni.pt/v1/customers/update/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(updateData) }) .then(response => response.json()) .then(data => console.log('Customer Update Result:', data)) .catch(error => console.error('Error Updating Customer:', error)); ``` -------------------------------- ### Insert Product Category - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a new product category in a specific company. The endpoint requires a name for the category and optionally a parent category ID. ```json { "company_id": 123456, "parent_id": 0, "name": "New Category" } ``` ```javascript const companyId = 123456; // Replace with your company ID const newCategory = { company_id: companyId, parent_id: 0, // 0 for top-level category or a parent ID name: "New Category" }; fetch('https://api.moloni.pt/v1/productCategories/insert/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(newCategory) }) .then(response => response.json()) .then(data => console.log('New Category Created:', data)) .catch(error => console.error('Error Creating Category:', error)); ``` -------------------------------- ### Update Product Stock Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Adjust the stock level for a specific product in a specific warehouse. This endpoint allows you to increase or decrease stock and provide a reason for the adjustment. ```json { "company_id": 123456, "product_id": 654321, "warehouse_id": 12345, "stock": 10, "notes": "Stock adjustment - inventory count" } ``` -------------------------------- ### Fetching PDF Token using JavaScript Fetch Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This snippet uses the browser's `fetch` API to send a POST request to an API endpoint. It includes necessary headers for content type and authorization (using a bearer token). The request body contains the company and document IDs. It processes the JSON response, logs the PDF token, and handles potential errors. ```JavaScript 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, document_id: documentId }) }) .then(response => response.json()) .then(data => { // PDF data is returned as base64 string console.log('PDF Token:', data); // You can convert it to a downloadable PDF or embed it }) .catch(error => console.error('Error Getting PDF:', error)); ``` -------------------------------- ### Send Invoice by Email Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Send a specific invoice to a customer by email. This endpoint allows sending the invoice as a PDF attachment with a customizable message. ```bash curl -X POST https://api.moloni.pt/v1/invoices/sendEmail/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "document_id=DOCUMENT_ID" \ -d "email=RECIPIENT_EMAIL" \ -d "subject=EMAIL_SUBJECT" \ -d "message=EMAIL_MESSAGE" ``` ```javascript const companyId = 123456; // Replace with your company ID const documentId = 901234; // Replace with your document ID const emailData = { company_id: companyId, document_id: documentId, email: "customer@example.com", subject: "Your Invoice #123", message: "Please find attached your invoice. Thank you for your business." }; fetch('https://api.moloni.pt/v1/invoices/sendEmail/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(emailData) }) .then(response => response.json()) .then(data => console.log('Email Send Result:', data)) .catch(error => console.error('Error Sending Invoice Email:', error)); ``` -------------------------------- ### Check if Database Needs Update Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Check if the database needs to be updated or if maintenance is required. This endpoint helps determine if the API is available for normal operations. ```bash curl -X POST https://api.moloni.pt/v1/isAllowed/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` -------------------------------- ### Create Maturity Date Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Create a new maturity date option in a specific company. This endpoint allows defining custom payment deadline options for invoices and other documents. ```javascript const companyId = 123456; // Replace with your company ID const newMaturityDate = { company_id: companyId, name: "Net 60", value: 60 }; fetch('https://api.moloni.pt/v1/maturityDates/insert/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(newMaturityDate) }) .then(response => response.json()) .then(data => console.log('New Maturity Date Created:', data)) .catch(error => console.error('Error Creating Maturity Date:', error)); ``` -------------------------------- ### Refreshing Moloni API Token Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Refresh your Moloni API access token using a refresh token. This endpoint allows you to obtain a new access token without requiring the user to log in again. ```bash curl -X POST https://api.moloni.pt/v1/grant/ \ -d "grant_type=refresh_token" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "refresh_token=YOUR_REFRESH_TOKEN" ``` ```javascript const refreshData = { grant_type: "refresh_token", client_id: "YOUR_CLIENT_ID", client_secret: "YOUR_CLIENT_SECRET", refresh_token: "YOUR_REFRESH_TOKEN" }; fetch('https://api.moloni.pt/v1/grant/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(refreshData) }) .then(response => response.json()) .then(data => { // Store the new access token const accessToken = data.access_token; console.log('Token refresh successful:', data); }) .catch(error => console.error('Token Refresh Error:', error)); ``` -------------------------------- ### Delete Customer Moloni API Bash Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This Bash snippet uses curl to send a POST request to the Moloni customer delete endpoint. It requires a valid access token and the company and customer IDs passed as form data parameters. This action is irreversible. ```bash curl -X POST https://api.moloni.pt/v1/customers/delete/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "customer_id=CUSTOMER_ID" ``` -------------------------------- ### Check if Database Needs Update Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Check if the database needs to be updated or if maintenance is required. This endpoint helps determine if the API is available for normal operations. ```javascript fetch('https://api.moloni.pt/v1/isAllowed/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log('API Status:', data)) .catch(error => console.error('Error Checking API Status:', error)); ``` -------------------------------- ### Customer Update Data Structure Moloni API JSON Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JSON object represents the data structure required to update an existing customer in the Moloni API. It includes the mandatory company and customer IDs, along with optional fields like name, email, address, zip code, and city. ```json { "company_id": 123456, "customer_id": 654321, "name": "Updated Client Name", "email": "updated_email@example.com", "address": "Updated Street, 456", "zip_code": "7654-321", "city": "Updated City" } ``` -------------------------------- ### Update Company Details - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Update the details of a specific company by providing its ID and the fields to be updated. This endpoint allows modification of company information such as name, address, and contact details. ```bash curl -X POST https://api.moloni.pt/v1/companies/update/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "name=UPDATED_NAME" \ -d "address=UPDATED_ADDRESS" ``` ```javascript const companyId = 123456; // Replace with your company ID const updateData = { company_id: companyId, name: "Updated Company Name", address: "New Company Address", zip_code: "12345-678", city: "New City" }; fetch('https://api.moloni.pt/v1/companies/update/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify(updateData) }) .then(response => response.json()) .then(data => console.log('Company Update Result:', data)) .catch(error => console.error('Error Updating Company:', error)); ``` -------------------------------- ### Delete Product - Moloni API Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Remove a product from a specific company by providing the company ID and product ID. This operation cannot be undone. ```bash curl -X POST https://api.moloni.pt/v1/products/delete/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "product_id=PRODUCT_ID" ``` ```javascript const companyId = 123456; // Replace with your company ID const productId = 654321; // Replace with your product ID fetch('https://api.moloni.pt/v1/products/delete/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, product_id: productId }) }) .then(response => response.json()) .then(data => console.log('Product Delete Result:', data)) .catch(error => console.error('Error Deleting Product:', error)); ``` -------------------------------- ### Delete Customer Moloni API JavaScript Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md This JavaScript snippet uses the fetch API to send a POST request to the Moloni customer delete endpoint. It requires a valid access token and the company and customer IDs provided in the request body as JSON. This operation permanently removes the customer. ```javascript const companyId = 123456; // Replace with your company ID const customerId = 654321; // Replace with your customer ID fetch('https://api.moloni.pt/v1/customers/delete/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, customer_id: customerId }) }) .then(response => response.json()) .then(data => console.log('Customer Delete Result:', data)) .catch(error => console.error('Error Deleting Customer:', error)); ``` -------------------------------- ### Delete Invoice Source: https://github.com/sriem/moloni-api-context-for-mcp/blob/main/context.md Remove an invoice from a specific company by providing the company ID and document ID. This operation cannot be undone and may be restricted if the invoice is already certified. ```bash curl -X POST https://api.moloni.pt/v1/invoices/delete/ \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d "company_id=COMPANY_ID" \ -d "document_id=DOCUMENT_ID" ``` ```javascript const companyId = 123456; // Replace with your company ID const documentId = 901234; // Replace with your document ID fetch('https://api.moloni.pt/v1/invoices/delete/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ company_id: companyId, document_id: documentId }) }) .then(response => response.json()) .then(data => console.log('Invoice Delete Result:', data)) .catch(error => console.error('Error Deleting Invoice:', error)); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.