Looking to create index pattern for viewing the logs on dashboard using the api


In our env. We have an AWS OpenSearch integrated to multiple env. and it receive logs from hundreds of indices. Creating index pattern for each of them manually by going into stack-management and creating an index for the logs is getting a bit tedious. I have searched a lot of docs. but, couldn’t find any api’s for creating the index patterns. Could you help me here.

I found below info. from one of the post. Index is getting created with the below api call, Index pattern is getting created in discover tab but, when I check the index on index pattern page of stack-management, it is empty and it is not displaying any logs on discover tab.
And also, if I run the same command with different index name, previously created Index is missing.

POST .kibana/_doc/index-pattern:<index-name>
“type” : “index-pattern”,
“index-pattern” : {
“title”: “index-*”, —> pattern to match index
“timeFieldName”: “execution_time” —> Time field

I have also tried the below as mentioned at “amazon web services - How to create an index pattern in Opensearch using API? - Stack Overflow” but, it didn’t help me

POST api/index_patterns/<index-pattern>* 
  "index_pattern": {
  "title": "<index-pattern*",
  "timeFieldName": "@timestamp"


I noticed there was a thread here: Problem creating index pattern from CURL where people talked about doing it on Open Source Elastic and Kibana. I imagine some of the steps might be the same. Also, there’s a github issue talking about this briefly as well:

You might find some answers between those two threads. I’m still trying to recreate their steps.