WiFi Wan connection via device API

I am trying to make WiFi Wan connection available via device APIs. I am using /api/cmd.wifi.connect endpoint, when there is a saved security policy on that WAN, only providing the SSID and policy key is enough to make the connection, but for new SSIDs I get this error:

{"code":400,"message":"Wi-Fi profile does not exist","stat":"fail"}

Other endpoint /api/config.ssid.profile for SSID profiles only provides “update” action and I have no idea how I can create new profile for new network:

Hi!

Is your question if you can create an SSID with API, or just manage it?

Sorry if the OP was not clear. I am not going to make a SSID or AP

I am going to scan available WiFi networks and connect to any of them by setting the SSID and its password. So far I managed to get list of available networks by query the /api/cmd.wifi.scan

Now if I want to connect to any of these WiFi networks I should use /api/cmd.wifi.connect

According to the documentation when SSID profile is not defined (a new network) I should provide additional information. Here is my POST body for a wpa-psk network:

{"connId": 6 ,"ssid":"ShortCircuitF1", "securityPolicy":"wpa-psk", "password": "25292339509134880060913642" }

and I get this response:

{"code":400,"message":"Wi-Fi profile does not exist","stat":"fail"}

It seems there is no direct way to create SSID profiles and they get created when WAN interface get connected to that network for the first time, but as well I don’t see how to connect to wpa-psk network just by sending the password.