Hello JH,
Thank you for reaching out to Microsoft Support!
You can use the List users endpoint to list unlicensed users as follows:
However, other types of unlicensed OneDrive accounts are not listed, so it is recommended that you Get reports on unlicensed OneDrive accounts in the SharePoint admin center.
Reports can also be obtained through the Graph Api, but there is no endpoint to implement this functionality, see the documentation for details.
https://graph.microsoft.com/v1.0//users?$filter=assignedLicenses/$count eq 0&$count=true&$select=displayName,assignedLicenses
ConsistencyLevel: eventual
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.