Learn how to enable manual invoice checks for all customers.
curl --request PATCH \ --url https://coreapi.io/settings \ --header 'Authorization : Bearer YOUR_API_KEY' \ --header 'Content-Type: application/merge-patch+json' \ --data '{ "settings": [ { "key": "requiresManualInvoiceApproval", "value": false } ] }'
curl --request GET \ --url https://coreapi.io/customers?limit=100 \ --header 'Authorization : Bearer YOUR_API_KEY'
curl --request PATCH \ --url https://coreapi.io/customers/{customerId}/settings/billing \ --header 'Authorization : Bearer YOUR_API_KEY' \ --header 'Content-Type: application/merge-patch+json' \ --data '{ "requiresManualInvoiceApproval": true }'
const apiKey = 'YOUR_API_KEY'; const getCustomers = async (page: number = 1) => { const customers = await fetch('https://coreapi.io/customers?limit=100&page=' + page, { headers: { Authorization: `Bearer ${apiKey}` } }).then(res => res.json()); return customers; }; const updateCustomer = async (customerId: string): void => { await fetch(`https://coreapi.io/customers/${customerId}/settings/billing`, { method: 'PATCH', headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/merge-patch+json' }, body: JSON.stringify({ requiresManualInvoiceApproval: true }) }); }; const enableManualInvoiceChecks = async () => { let page = 1; let customers = await getCustomers(page); while (customers.length > 0) { for (const customer of customers) { await updateCustomer(customer.id); } page++; customers = await getCustomers(page); } }; enableManualInvoiceChecks();
Was this page helpful?