How to query an index pattern from a Kibana's scripted fields? (Curl Command)

There's no officially supported way to interact with scripted fields through any sort of API. The UI is the only official way of creating on.

That said, if you really want to, a workaround is laid out in this thread: Scripted field with curl

If you'd like us to consider this feature, please file a feature request on Github. We do use community feedback to inform our roadmaps.