For non-empty requirement, we can do it via devices provisioned by schema v1.0. That is well-known. If you're not that in it, this is how amongst others.
Now, the problem of that if ApiName exists, FlowName does not and vice versa, it is known to be called co-occurrence constraints in the 10+ years of w3c schema literature. It is not a secret that v1.0 is not expressive enough to make such a constraint. Long time, this kind of constraints has to be done at the application level (ie, in the particular language of code, you do validation without the constraint and then in the code you check if they both exists etc...). Or else, you would have to use alternative schema such as Relaxng or Schematron.
Since some time already, you can now do it in a homogeneous platform of w3c schema with the use the schema v1.1, a development of v1.0. This is certain less well-known and supported. Xerce-j supports schema v1.1 such since or about v2.11.0... (in any case, use the latest version). To do that with w3c schema, you are then obliged to use v1.1 supported engine.
In schema v1.1, you can do it like this to give you an clear picture rather than just verbiage. However, you've have precised the content type of Api apart the attributes, let me support its content has a type apiBaseType. From it, you add the attributes with the constraint scripted like this.
If that is too involved, do thing at the application level as mentioned above.
ps Edition Original I just put [^\s]+. After reviewing the post, it is too restrictive. I edit the
pattern to allow a more reasonable and less restrictive value range.