How to create or delete Kibana index pattern using API

Display, search, create or delete Kibana index pattern using API.

Display index patterns.

$ curl --fail --user httpuser:httppass --header 'Content-Type: application/json' --header 'kbn-xsrf: this_is_required_header' 'https://kibana.example.org/api/saved_objects/_find?type=index-pattern&fields=title&fields=type&per_page=1000' | jq .
{
  "page": 1,
  "per_page": 1000,
  "total": 513,
  "saved_objects": [
    {
      "type": "index-pattern",
      "id": "solr-*",
      "attributes": {
        "title": "solr-*"
      },
      "version": "WzAsMV0="
    },
    {
      "type": "index-pattern",
      "id": "haproxy-*",
      "attributes": {
        "title": "haproxy-*"
      },
      "version": "WzEsMV0="
    },
[...]
    {
      "type": "index-pattern",
      "id": "system-*",
      "attributes": {
        "title": "system-*"
      },
      "version": "WzE0OTUsMl0="
    }
  ]
}

Search for index pattern with id apache-*.

$ curl --fail --user httpuser:httppass --header 'Content-Type: application/json' --header 'kbn-xsrf: this_is_required_header' 'https://kibana.example.org/api/saved_objects/_find?type=index-pattern&fields=title&fields=type&per_page=1000&search_fields=title&search=apache-\*'
{"page":1,"per_page":1000,"total":1,"saved_objects":[{"type":"index-pattern","id":"apache-*","attributes":{"title":"apache-*"},"version":"WzE0OTUsMl0="}]}

Create index pattern apache-*.

$ curl --fail --user httpuser:httppass --request POST --header 'Content-Type: application/json' --header 'kbn-xsrf: this_is_required_header' 'https://kibana.example.org/api/saved_objects/index-pattern/apache-*?overwrite=true' --data '{"attributes":{"title":"apache-*","timeFieldName":"@timestamp"}}' 'https://kibana.example.org/api/saved_objects/index-pattern/apache-*?overwrite=true' 
{"type":"index-pattern","id":"apache-*","attributes":{"title":"apache-*","timeFieldName":"@timestamp"},"migrationVersion":{"index-pattern":"6.5.0"},"updated_at":"2020-04-23T21:14:37.192Z","version":"WzE0ODgsMl0="}

Delete index pattern with id nginx-*.

$ curl --fail --user httpuser:httppass --request DELETE --header 'kbn-xsrf: this_is_required_header' 'https://kibana.example.org/api/saved_objects/index-pattern/index-*'
{}