> This page is for Self-Hosted, version v3.0 (default).
> For other versions, use one of these documentation indexes:
> - v3.0 (default): https://docs.nvidia.com/run-ai/self-hosted/v3.0/llms.txt
> - v2.26: https://docs.nvidia.com/run-ai/self-hosted/v2.26/llms.txt
> - v2.25: https://docs.nvidia.com/run-ai/self-hosted/v2.25/llms.txt
> - v2.24: https://docs.nvidia.com/run-ai/self-hosted/v2.24/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/run-ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/run-ai/_mcp/server.

# Create email notification channel

POST http://localhost:8080/api/v1/email
Content-Type: application/json

Create email notification channel

Reference: https://docs.nvidia.com/run-ai/self-hosted/reference/rest-api/endpoints/notifications/email/create-email

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication

## Request

### Body (application/json)

This endpoint expects an EmailChannel.

- `config` (EmailChannelConfig, required)

## Response

### 200

Email notification channel created

- `config` (EmailChannelConfig, required)

## Errors

### 400 Bad Request Error

Bad request.

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 401 Unauthorized Error

Unauthorized

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 403 Forbidden Error

Forbidden

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 404 Not Found Error

The specified resource was not found

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 409 Conflict Error

The specified resource already exists

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 500 Internal Server Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 501 Not Implemented Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 503 Service Unavailable Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

## Types

### EmailChannelConfig

- `smtpHost` (string, required)
- `username` (string, optional)
- `password` (string, optional)
- `from` (string, optional)
- `smtpPort` (integer, optional, default: 587)
- `authType` (enum, optional, default: auth_login)
  - Allowed values: `auth_login`, `auth_plain`, `auth_none`, ``
- `smtpTlsEnabled` (boolean, optional, nullable)
- `recipients` (list of string, optional, default: [])
- `fromDisplayName` (string, optional, default: Run:ai)
- `directNotifications` (boolean, optional, nullable)
- `useAttachments` (boolean, optional, nullable)
- `subject` (string, optional, default: Run:ai notification - {{ .category }} {{ .reason }})

## Examples

**Request**

```json
{
  "config": {
    "smtpHost": "smtp.gmail.com",
    "username": "email@gmail.com",
    "password": "123456",
    "from": "email@gmail.com",
    "subject": "My subject"
  }
}
```

**Response**

```json
{
  "config": {
    "smtpHost": "smtp.gmail.com",
    "username": "email@gmail.com",
    "password": "123456",
    "from": "email@gmail.com",
    "subject": "My subject"
  }
}
```

**SDK Code**

```python
import requests

url = "http://localhost:8080/api/v1/email"

payload = { "config": {
        "smtpHost": "smtp.gmail.com",
        "username": "email@gmail.com",
        "password": "123456",
        "from": "email@gmail.com",
        "subject": "My subject"
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'http://localhost:8080/api/v1/email';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"config":{"smtpHost":"smtp.gmail.com","username":"email@gmail.com","password":"123456","from":"email@gmail.com","subject":"My subject"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:8080/api/v1/email"

	payload := strings.NewReader("{\n  \"config\": {\n    \"smtpHost\": \"smtp.gmail.com\",\n    \"username\": \"email@gmail.com\",\n    \"password\": \"123456\",\n    \"from\": \"email@gmail.com\",\n    \"subject\": \"My subject\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("http://localhost:8080/api/v1/email")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"config\": {\n    \"smtpHost\": \"smtp.gmail.com\",\n    \"username\": \"email@gmail.com\",\n    \"password\": \"123456\",\n    \"from\": \"email@gmail.com\",\n    \"subject\": \"My subject\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/email")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"config\": {\n    \"smtpHost\": \"smtp.gmail.com\",\n    \"username\": \"email@gmail.com\",\n    \"password\": \"123456\",\n    \"from\": \"email@gmail.com\",\n    \"subject\": \"My subject\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/email', [
  'body' => '{
  "config": {
    "smtpHost": "smtp.gmail.com",
    "username": "email@gmail.com",
    "password": "123456",
    "from": "email@gmail.com",
    "subject": "My subject"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/email");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"config\": {\n    \"smtpHost\": \"smtp.gmail.com\",\n    \"username\": \"email@gmail.com\",\n    \"password\": \"123456\",\n    \"from\": \"email@gmail.com\",\n    \"subject\": \"My subject\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["config": [
    "smtpHost": "smtp.gmail.com",
    "username": "email@gmail.com",
    "password": "123456",
    "from": "email@gmail.com",
    "subject": "My subject"
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/email")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```