Hi,
Hmm… I don’t know everything about the API, so others will know better than me… But the only likely API methods I can see are for SetFormula… Which seems to only be for Families and Global Parameters…
If that could work for you… Here’s an example for setting Global Parameters: Set a formula to a Global parameter
There are other examples for families if you search the forum…
Hope that helps, let us know how you get on
Mark