Actually, that not generally possible since app infrastructure can be shared between several apps. (at least for host unit licenses).
For RUM I can imagine this is doable (sum of user sessions), but I;m not sure this metric is exposed using API.
For synthetic it is simple math.
Currently, the best approach would be to have separate environment per application.
I have the same issue.
Speaking about licences consumed by hosts, you can use this API https://www.dynatrace.com/support/help/dynatrace-a... , collecting the attribute "consumedHostUnits" .
But, for sessions consumed per tenant or application, no API exists. I have so created a RFE to which you can subscribe https://answers.dynatrace.com/spaces/482/dynatrace...
. So it may be available before the end of this year.