Here, the headless channel ID is hard-coded, and I need to retrieve this value dynamically based on the context.
What is the context you are referring to?
Headless channels get this context based on the GraphQL query sent to the channel's API endpoint. If you are doing some background processing in the administration UI there is no current channel. You can use an Object Query to get a channel ID or name, but you need to decide which headless channel is the right one based on the "context".
I’m wondering if Kentico plans to make these APIs public at some point.
Those APIs (for headless and email content item management) are in .Internal namespaces to make them easier for us to use in the product and still have the flexibility to change them as needed for new features. We call these .Internal namespace but public class modifier types "pubternal". They're designed for the platform, not for consumption.
It requires a lot of planning and review when we make an API truly public and supported because it limits how we can evolve it in the future.
The API you found for headless items is an internal one in the CMS.Headless.Internal namespace, so it’s not recommended to use it.
Milan is right, we don't recommend using these APIs primarily because we might change them in a minor version update, without notice. Using them could put you in a situation where you can't apply a Refresh without losing functionality.
However, it might be worth it if you want the capabilities they enable! I use them in the Kentico Community Portal, and acknowledge the risk. I don't get special treatment just because I work for Kentico 😅.
If you have scenarios you need solved that these APIs support, give us feedback about them on our roadmap.