Create or update SMTP configuration
const url = 'http://localhost:8000/clusters/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/realms/customer-portal/smtp';
const options = {
method: 'PUT',
headers: {
'API-Version': '2026-06-01.beta',
'API-Key': '<API-Key>',
'Content-Type': 'application/json'
},
body: '{"host":"smtp.sendgrid.net","port":587,"encryption":"none","from_email":"hello@example.com","from_name":"example","auth_type":"basic","username":"example","password":"example","token_url":"https://example.com","token_scope":"example","client_id":"example","client_secret":"example"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}curl --request PUT \
--url http://localhost:8000/clusters/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/realms/customer-portal/smtp \
--header 'API-Key: <API-Key>' \
--header 'API-Version: 2026-06-01.beta' \
--header 'Content-Type: application/json' \
--data '{ "host": "smtp.sendgrid.net", "port": 587, "encryption": "none", "from_email": "hello@example.com", "from_name": "example", "auth_type": "basic", "username": "example", "password": "example", "token_url": "https://example.com", "token_scope": "example", "client_id": "example", "client_secret": "example" }'Creates or replaces the SMTP configuration for a realm. Credentials (password, client secret) are write-only; omit them to retain the existing value.
Required scope: smtp:write
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Keycloak realm name (not ID). Must start with a letter; allows letters, digits, and hyphens.
Example
customer-portalHeader Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Example
587Encryption mode. Defaults to none.
Sender email address.
Required when auth_type is basic.
Required when auth_type is basic and no password is currently stored. Omit to retain the existing password.
Required when auth_type is oauth2.
Required when auth_type is oauth2.
Required when auth_type is oauth2.
Required when auth_type is oauth2 and no client secret is stored. Omit to retain the existing secret.
Responses
Section titled “Responses”The request has succeeded.
SMTP email delivery configuration for a realm.
object
Keycloak realm name (not ID). Must start with a letter; allows letters, digits, and hyphens.
Sender email address.
SMTP username. Present when auth_type is basic.
true when a password is stored for this configuration.
OAuth 2.0 token endpoint URL. Present when auth_type is oauth2.
OAuth 2.0 token scope. Present when auth_type is oauth2.
OAuth 2.0 client ID. Present when auth_type is oauth2.
true when a client secret is stored for this configuration.
Timestamp of the last connection test.
Example
{
"realm": "customer-portal",
"host": "smtp.sendgrid.net",
"port": 587,
"encryption": "none",
"from_email": "noreply@mycompany.com",
"from_name": "MyCompany",
"auth_type": "basic",
"status": "configured"
}The server could not understand the request due to invalid syntax.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Access is unauthorized.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Access is forbidden.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}The server cannot find the requested resource.
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Client error
object
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com",
"errors": [
{
"field": "example",
"detail": "example",
"code": "example",
"value": "example"
}
]
}Client error
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Headers
Section titled “Headers”Server error
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}Server error
RFC 9457 Problem Details object.
object
Example generated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "https://example.com"
}