You can add the role to the Access Token as a custom claim. Here is an example of that in our docs: Sample Use Cases: Rules with Authorization
This will work for users. However, for the machine-to-machine exchange (the rule calling your API), you won’t be able to add the role since roles are only assigned to users, not non-interactive clients.
You can however use the Client Credentials Exchange hook to modify the Access Token that your API receives. You could add a custom claim that indicates that it is the rule: