> 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 user subscription

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

Create user subscription

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

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a Subscription.

- `events` (list of SubscriptionEvent, required)
- `channels` (list of string, required)
- `id` (string, optional)

## Response

### 200

Subscription created successfully

- `events` (list of SubscriptionEvent, required)
- `channels` (list of string, required)
- `id` (string, optional)

## 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)

### 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

### SubscriptionEvent

- `category` (string, required)
- `types` (list of string, required)

## Examples

**Request**

```json
{
  "events": [
    {
      "category": "cat1",
      "types": [
        "type1",
        "type2"
      ]
    },
    {
      "category": "cat2",
      "types": [
        "type3",
        "type4"
      ]
    }
  ],
  "channels": [
    "email",
    "email1"
  ],
  "id": "1234"
}
```

**Response**

```json
{
  "events": [
    {
      "category": "cat1",
      "types": [
        "type1",
        "type2"
      ]
    },
    {
      "category": "cat2",
      "types": [
        "type3",
        "type4"
      ]
    }
  ],
  "channels": [
    "email",
    "email1"
  ],
  "id": "1234"
}
```

**SDK Code**

```python
import requests

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

payload = {
    "events": [
        {
            "category": "cat1",
            "types": ["type1", "type2"]
        },
        {
            "category": "cat2",
            "types": ["type3", "type4"]
        }
    ],
    "channels": ["email", "email1"],
    "id": "1234"
}
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/subscriptions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"events":[{"category":"cat1","types":["type1","type2"]},{"category":"cat2","types":["type3","type4"]}],"channels":["email","email1"],"id":"1234"}'
};

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/subscriptions"

	payload := strings.NewReader("{\n  \"events\": [\n    {\n      \"category\": \"cat1\",\n      \"types\": [\n        \"type1\",\n        \"type2\"\n      ]\n    },\n    {\n      \"category\": \"cat2\",\n      \"types\": [\n        \"type3\",\n        \"type4\"\n      ]\n    }\n  ],\n  \"channels\": [\n    \"email\",\n    \"email1\"\n  ],\n  \"id\": \"1234\"\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/subscriptions")

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  \"events\": [\n    {\n      \"category\": \"cat1\",\n      \"types\": [\n        \"type1\",\n        \"type2\"\n      ]\n    },\n    {\n      \"category\": \"cat2\",\n      \"types\": [\n        \"type3\",\n        \"type4\"\n      ]\n    }\n  ],\n  \"channels\": [\n    \"email\",\n    \"email1\"\n  ],\n  \"id\": \"1234\"\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/subscriptions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"events\": [\n    {\n      \"category\": \"cat1\",\n      \"types\": [\n        \"type1\",\n        \"type2\"\n      ]\n    },\n    {\n      \"category\": \"cat2\",\n      \"types\": [\n        \"type3\",\n        \"type4\"\n      ]\n    }\n  ],\n  \"channels\": [\n    \"email\",\n    \"email1\"\n  ],\n  \"id\": \"1234\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/subscriptions', [
  'body' => '{
  "events": [
    {
      "category": "cat1",
      "types": [
        "type1",
        "type2"
      ]
    },
    {
      "category": "cat2",
      "types": [
        "type3",
        "type4"
      ]
    }
  ],
  "channels": [
    "email",
    "email1"
  ],
  "id": "1234"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/subscriptions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"events\": [\n    {\n      \"category\": \"cat1\",\n      \"types\": [\n        \"type1\",\n        \"type2\"\n      ]\n    },\n    {\n      \"category\": \"cat2\",\n      \"types\": [\n        \"type3\",\n        \"type4\"\n      ]\n    }\n  ],\n  \"channels\": [\n    \"email\",\n    \"email1\"\n  ],\n  \"id\": \"1234\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "events": [
    [
      "category": "cat1",
      "types": ["type1", "type2"]
    ],
    [
      "category": "cat2",
      "types": ["type3", "type4"]
    ]
  ],
  "channels": ["email", "email1"],
  "id": "1234"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/subscriptions")! 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()
```