How to set smtp properties in request body of "add realm" REST API?

Hello Everyone,
I am creating a realm using rest endpoint. I want to set smtp properties in a request body.
I have tried as shown below but it is throwing an error. Please help me.
Thankyou.

First, verify that your realm json works without the smtpServer section, to eliminate the possibility that the error is being produced by some other section. Beyond that, the smtpServer section looks like this:

  "smtpServer": {
    "from": "foo@bar.com",
    "fromDisplayName": "Foo Bar",
    "replyTo": "",
    "replyToDisplayName": "",
    "envelopeFrom": "",
    "host": "smtp.bar.com",
    "port": "587",
    "ssl": "false",
    "starttls": "true",
    "auth": "true",
    "user": "foo",
    "password": "****somepassword*****"
  }

Also, I don’t know where the sslEnable and authenticationEnable keys are coming from, as they’re not part of the smtpServer section, and they’re not in the realm spec.

@xgp Thanks. It worked.

Can you please also share the request body to add password policy in add realm api?

The best way to learn the correct request body is to go to the Keycloak Admin UI and execute the function you want with the developer tools “Network” tab open. This will show the correct request format.