> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fynn.eu/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable manual invoice checks

> Learn how to enable manual invoice checks for all customers.

# Enable for all customers

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

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

## Set global tenant settings

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

```bash theme={null}
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

```bash theme={null}
curl --request GET \
    --url https://coreapi.io/customers?limit=100 \
    --header 'Authorization : Bearer YOUR_API_KEY'
```

2. Update each customer

```bash theme={null}
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:

```js theme={null}
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();
```
