Enable for all customers

Enable it for all existing customers and disable it for upcoming customers without changing settings.

This is useful if you are migrating your subscriptions from another system and are not sure if those send invoices are correct.

Set global tenant settings

To set global tenant settings, execute the following api request:

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
            }
        ]
    }'

Enable for all existing customers

To enable manual invoice checks for all existing customers, execute the following api request:

  1. Get all customers
curl --request GET \
    --url https://coreapi.io/customers?limit=100 \
    --header 'Authorization : Bearer YOUR_API_KEY'
  1. Update each customer
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
    }'

Example script

A javascript example to enable manual invoice checks for all customers:

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();