mesh1 -> nCloth1 -> nComponent1 -> dynamicConstraint.ids[0]
mesh2 -> nCloth2 -> nComponent2 -> dynamicConstraint.ids[1]
Something I typically do when trying to figure out how to populate some undocumented data member is to look at how Maya Ascii does it.
For example..
...
createNode dynamicConstraint -n "dynamicConstraintShape1" -p "dynamicConstraint1";
...
connectAttr "dynamicConstraintShape1.evs" "nucleus1.is[0]";
connectAttr "dynamicConstraintShape1.evc" "nucleus1.ic[0]";
connectAttr "nComponent1.ocp" "dynamicConstraintShape1.cid[0]";
connectAttr "nComponent2.ocp" "dynamicConstraintShape1.cid[1]";
connectAttr ":time1.o" "dynamicConstraintShape1.cti";
This is everything related to the constraint itself, and..
...
createNode nComponent -n "nComponent1";
rename -uid "5CA944EE-46C7-5933-6EF2-70B733AACB38";
setAttr ".ct" 2;
setAttr ".el" 2;
...
connectAttr "nComponent1.ocp" "dynamicConstraintShape1.cid[0]";
...
connectAttr "nClothShape1.nuid" "nComponent1.obid";
...
// End of temp.ma
These are everything related to the nComponent. From here you might be able to figure out how to replicate this with API calls.