Files
netbird-docs/src/pages/ipa/resources/notifications.mdx
T

1734 lines
38 KiB
Plaintext

export const title = 'Notifications'
## List Notification Event Types {{ tag: 'GET' , label: '/api/integrations/notifications/types' }}
<Row>
<Col>
Returns a map of all supported activity event type codes to their
human-readable descriptions. Use these codes when configuring
`event_types` on notification channels.
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/api/integrations/notifications/types">
```bash {{ title: 'cURL' }}
curl -X GET https://api.netbird.io/api/integrations/notifications/types \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: '/api/integrations/notifications/types',
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/integrations/notifications/types"
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/integrations/notifications/types"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/integrations/notifications/types")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/integrations/notifications/types")
.method("GET")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/integrations/notifications/types',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"user.join": "User joined"
}
```
```json {{ title: 'Schema' }}
{
"type": "object",
"description": "A map of event type codes to their human-readable descriptions.",
"additionalProperties": "string",
"example": {
"user.join": "User joined"
}
}
```
</CodeGroup>
</Col>
</Row>
---
## List Notification Channels {{ tag: 'GET' , label: '/api/integrations/notifications/channels' }}
<Row>
<Col>
Retrieves all notification channels configured for the authenticated account.
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/api/integrations/notifications/channels">
```bash {{ title: 'cURL' }}
curl -X GET https://api.netbird.io/api/integrations/notifications/channels \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: '/api/integrations/notifications/channels',
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/integrations/notifications/channels"
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/integrations/notifications/channels"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/integrations/notifications/channels")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/integrations/notifications/channels")
.method("GET")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/integrations/notifications/channels',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
[
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}
]
```
```json {{ title: 'Schema' }}
[
{
"id": "string",
"type": "string",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"string"
]
},
{
"url": "string",
"headers": {
"type": "object",
"additionalProperties": "string",
"description": "Custom HTTP headers sent with each webhook request.\nValues are write-only; in GET responses all values are masked.\n",
"example": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
}
]
},
"event_types": [
"string"
],
"enabled": "boolean"
}
]
```
</CodeGroup>
</Col>
</Row>
---
## Create Notification Channel {{ tag: 'POST' , label: '/api/integrations/notifications/channels' }}
<Row>
<Col>
Creates a new notification channel for the authenticated account.
Supported channel types are `email` and `webhook`.
### Request-Body Parameters
<Properties><Property name="type" type="string" required={true} enumList={["email","webhook"]}>
The type of notification channel.
</Property>
<Property name="target" type="" required={false}>
Channel-specific target configuration. The shape depends on the `type` field:
\- `email`: requires an `EmailTarget` object
\- `webhook`: requires a `WebhookTarget` object
</Property>
<Property name="event_types" type="string[]" required={true}>
List of activity event type codes this channel subscribes to.
</Property>
<Property name="enabled" type="boolean" required={true}>
Whether this notification channel is active.
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup title="Request" tag="POST" label="/api/integrations/notifications/channels">
```bash {{ title: 'cURL' }}
curl -X POST https://api.netbird.io/api/integrations/notifications/channels \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}'
```
```js
const axios = require('axios');
let data = JSON.stringify({
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: '/api/integrations/notifications/channels',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Token <TOKEN>'
},
data : data
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/integrations/notifications/channels"
payload = json.dumps({
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/integrations/notifications/channels"
method := "POST"
payload := strings.NewReader(`{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/integrations/notifications/channels")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
})
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}');
Request request = new Request.Builder()
.url("https://api.netbird.io/api/integrations/notifications/channels")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/integrations/notifications/channels',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}
```
```json {{ title: 'Schema' }}
{
"id": "string",
"type": "string",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"string"
]
},
{
"url": "string",
"headers": {
"type": "object",
"additionalProperties": "string",
"description": "Custom HTTP headers sent with each webhook request.\nValues are write-only; in GET responses all values are masked.\n",
"example": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
}
]
},
"event_types": [
"string"
],
"enabled": "boolean"
}
```
</CodeGroup>
</Col>
</Row>
---
## Get Notification Channel {{ tag: 'GET' , label: '/api/integrations/notifications/channels/{channelId}' }}
<Row>
<Col>
Retrieves a specific notification channel by its ID.
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/api/integrations/notifications/channels/{channelId}">
```bash {{ title: 'cURL' }}
curl -X GET https://api.netbird.io/api/integrations/notifications/channels/{channelId} \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: '/api/integrations/notifications/channels/{channelId}',
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/integrations/notifications/channels/{channelId}"
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/integrations/notifications/channels/{channelId}"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/integrations/notifications/channels/{channelId}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/integrations/notifications/channels/{channelId}")
.method("GET")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/integrations/notifications/channels/{channelId}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}
```
```json {{ title: 'Schema' }}
{
"id": "string",
"type": "string",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"string"
]
},
{
"url": "string",
"headers": {
"type": "object",
"additionalProperties": "string",
"description": "Custom HTTP headers sent with each webhook request.\nValues are write-only; in GET responses all values are masked.\n",
"example": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
}
]
},
"event_types": [
"string"
],
"enabled": "boolean"
}
```
</CodeGroup>
</Col>
</Row>
---
## Update Notification Channel {{ tag: 'PUT' , label: '/api/integrations/notifications/channels/{channelId}' }}
<Row>
<Col>
Updates an existing notification channel.
### Request-Body Parameters
<Properties><Property name="type" type="string" required={true} enumList={["email","webhook"]}>
The type of notification channel.
</Property>
<Property name="target" type="" required={false}>
Channel-specific target configuration. The shape depends on the `type` field:
\- `email`: requires an `EmailTarget` object
\- `webhook`: requires a `WebhookTarget` object
</Property>
<Property name="event_types" type="string[]" required={true}>
List of activity event type codes this channel subscribes to.
</Property>
<Property name="enabled" type="boolean" required={true}>
Whether this notification channel is active.
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup title="Request" tag="PUT" label="/api/integrations/notifications/channels/{channelId}">
```bash {{ title: 'cURL' }}
curl -X PUT https://api.netbird.io/api/integrations/notifications/channels/{channelId} \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}'
```
```js
const axios = require('axios');
let data = JSON.stringify({
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
});
let config = {
method: 'put',
maxBodyLength: Infinity,
url: '/api/integrations/notifications/channels/{channelId}',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Token <TOKEN>'
},
data : data
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/integrations/notifications/channels/{channelId}"
payload = json.dumps({
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/integrations/notifications/channels/{channelId}"
method := "PUT"
payload := strings.NewReader(`{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/integrations/notifications/channels/{channelId}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
})
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}');
Request request = new Request.Builder()
.url("https://api.netbird.io/api/integrations/notifications/channels/{channelId}")
.method("PUT", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/integrations/notifications/channels/{channelId}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => '{
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: requires an `EmailTarget` object\n- `webhook`: requires a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"type": "email",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"admin@example.com",
"ops@example.com"
]
},
{
"url": "https://hooks.example.com/netbird",
"headers": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
]
},
"event_types": [
"user.join",
"peer.user.add",
"peer.login.expire"
],
"enabled": true
}
```
```json {{ title: 'Schema' }}
{
"id": "string",
"type": "string",
"target": {
"description": "Channel-specific target configuration. The shape depends on the `type` field:\n- `email`: an `EmailTarget` object\n- `webhook`: a `WebhookTarget` object\n",
"oneOf": [
{
"emails": [
"string"
]
},
{
"url": "string",
"headers": {
"type": "object",
"additionalProperties": "string",
"description": "Custom HTTP headers sent with each webhook request.\nValues are write-only; in GET responses all values are masked.\n",
"example": {
"Authorization": "Bearer token",
"X-Webhook-Secret": "secret"
}
}
}
]
},
"event_types": [
"string"
],
"enabled": "boolean"
}
```
</CodeGroup>
</Col>
</Row>
---
## Delete Notification Channel {{ tag: 'DELETE' , label: '/api/integrations/notifications/channels/{channelId}' }}
<Row>
<Col>
Deletes a notification channel by its ID.
</Col>
<Col sticky>
<CodeGroup title="Request" tag="DELETE" label="/api/integrations/notifications/channels/{channelId}">
```bash {{ title: 'cURL' }}
curl -X DELETE https://api.netbird.io/api/integrations/notifications/channels/{channelId} \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'delete',
maxBodyLength: Infinity,
url: '/api/integrations/notifications/channels/{channelId}',
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/integrations/notifications/channels/{channelId}"
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("DELETE", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/integrations/notifications/channels/{channelId}"
method := "DELETE"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/integrations/notifications/channels/{channelId}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/integrations/notifications/channels/{channelId}")
.method("DELETE")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/integrations/notifications/channels/{channelId}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{}
```
```json {{ title: 'Schema' }}
{
"type": "object",
"example": {}
}
```
</CodeGroup>
</Col>
</Row>
---