Unified alerting HTTP API in Grafana?

Is there any documentation for the unified alerting HTTP API? Aka, how can I register a new rule by posting the rule yaml payload to an endpoint, same question for the AlertManager configuration.

You can view the specification https://editor.swagger.io/?url=https://raw.githubusercontent.com/grafana/grafana/main/pkg/services/ngalert/api/tooling/post.json|here
<grafana/ruler-grafana-recipient.http at 5e534d212ca291a44ae195c19cc6eb9c1d501ffc · grafana/grafana · GitHub example> for creating a grafana-managed rule querying a prometheus datasource and having 2 expressions reduce and math (the math expression is the rule condition)
the namespace URL parameter should point to an existing folder (under which the rule will be created)

And an https://github.com/grafana/grafana/blob/5e534d212ca291a44ae195c19cc6eb9c1d501ffc/pkg/services/ngalert/api/test-data/am-grafana-recipient.http#L5|example for POSTing an alertmanager configuration

Could I ask if there is a way to drop in prometheus rules yaml into one of these endpoints? Or the rules need to be in specific format that is specicifc to Grafana?

If you use cortex as prometheus datasource you can use POST​ /api​/ruler​/{Recipient}​/api​/v1​/rules​/{Namespace} where the Recipient should be the datasource id but this route expects JSON (not YAML).
An example payload is:

    "name": "group42",
    "rules": [
        {
            "alert": "prom",
            "expr": "(node_filesystem_avail_bytes{job=\"integrations/node_exporter\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"integrations/node_exporter\",fstype!=\"\"} * 100 &lt; 5 and node_filesystem_readonly{job=\"integrations/node_exporter\",fstype!=\"\"} == 0)",
            "for": "1m"
        }
    ]
}```

In that case grafana proxies the request to https://cortexmetrics.io/docs/api/#set-rule-group|this route