Yes, you can, and the workflow JSON format has a reduced "API form" that discards visual/UI related information.
Also, if you are using Python, you could do your automation in Comfy (as custom nodes) instead of outside, too.
I'm positive this can be done w/ Comfy too.