This capability does not currently exist for Confluence.
There is an jira ticket you can vote for, but until enough end users show interest, Atlassian will not provide this API.
You can see what they have done for APIs for databases in this ticket, as well as vote for it here: https://jira.atlassian.com/browse/CONFCLOUD-77328
Using this link, when the capability is available, it will be reflected in this ticket and then we should post a better answer.