Save SendGrid credentials
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"sendGridApiKey": "SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=",
"sendGridTemplateID": "d-8284bb9646a040499d5cfa28d272a094",
"sendGridUnsubscribeGroupID": "33832",
"senderName": "Emailer",
"senderEmail": "noreply@em123.example.com",
"allowEmailReplies": false,
"senderEmailForReplies": "reply@em123.example.com",
"isEnabled": true
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid"
payload = {
"sendGridApiKey": "SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=",
"sendGridTemplateID": "d-8284bb9646a040499d5cfa28d272a094",
"sendGridUnsubscribeGroupID": "33832",
"senderName": "Emailer",
"senderEmail": "noreply@em123.example.com",
"allowEmailReplies": False,
"senderEmailForReplies": "reply@em123.example.com",
"isEnabled": True
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sendGridApiKey: 'SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=',
sendGridTemplateID: 'd-8284bb9646a040499d5cfa28d272a094',
sendGridUnsubscribeGroupID: '33832',
senderName: 'Emailer',
senderEmail: 'noreply@em123.example.com',
allowEmailReplies: false,
senderEmailForReplies: 'reply@em123.example.com',
isEnabled: true
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sendGridApiKey' => 'SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=',
'sendGridTemplateID' => 'd-8284bb9646a040499d5cfa28d272a094',
'sendGridUnsubscribeGroupID' => '33832',
'senderName' => 'Emailer',
'senderEmail' => 'noreply@em123.example.com',
'allowEmailReplies' => false,
'senderEmailForReplies' => 'reply@em123.example.com',
'isEnabled' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid"
payload := strings.NewReader("{\n \"sendGridApiKey\": \"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=\",\n \"sendGridTemplateID\": \"d-8284bb9646a040499d5cfa28d272a094\",\n \"sendGridUnsubscribeGroupID\": \"33832\",\n \"senderName\": \"Emailer\",\n \"senderEmail\": \"noreply@em123.example.com\",\n \"allowEmailReplies\": false,\n \"senderEmailForReplies\": \"reply@em123.example.com\",\n \"isEnabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sendGridApiKey\": \"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=\",\n \"sendGridTemplateID\": \"d-8284bb9646a040499d5cfa28d272a094\",\n \"sendGridUnsubscribeGroupID\": \"33832\",\n \"senderName\": \"Emailer\",\n \"senderEmail\": \"noreply@em123.example.com\",\n \"allowEmailReplies\": false,\n \"senderEmailForReplies\": \"reply@em123.example.com\",\n \"isEnabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sendGridApiKey\": \"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=\",\n \"sendGridTemplateID\": \"d-8284bb9646a040499d5cfa28d272a094\",\n \"sendGridUnsubscribeGroupID\": \"33832\",\n \"senderName\": \"Emailer\",\n \"senderEmail\": \"noreply@em123.example.com\",\n \"allowEmailReplies\": false,\n \"senderEmailForReplies\": \"reply@em123.example.com\",\n \"isEnabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"allowEmailReplies": true,
"sendGridApiKey": "sendgrid_key",
"sendGridTemplateID": "template_id",
"sendGridUnsubscribeGroupID": "12312",
"senderEmail": "noreply@em123.example.com",
"senderEmailForReplies": "reply@em123.example.com",
"senderName": "Emailer",
"repliesWebhook": "https://notifications-us.cometchat.io/email/v1/sendgrid/replies?token=GY40_1kWlnc2Lo7Lk8vWWxiNJ6BmEEpV4eZsUeMr328"
}
}SendGrid Provider
Save SendGrid credentials
Store the SendGrid credentials for the given app.
POST
/
notifications
/
email
/
v1
/
providers
/
sendgrid
Save SendGrid credentials
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"sendGridApiKey": "SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=",
"sendGridTemplateID": "d-8284bb9646a040499d5cfa28d272a094",
"sendGridUnsubscribeGroupID": "33832",
"senderName": "Emailer",
"senderEmail": "noreply@em123.example.com",
"allowEmailReplies": false,
"senderEmailForReplies": "reply@em123.example.com",
"isEnabled": true
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid"
payload = {
"sendGridApiKey": "SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=",
"sendGridTemplateID": "d-8284bb9646a040499d5cfa28d272a094",
"sendGridUnsubscribeGroupID": "33832",
"senderName": "Emailer",
"senderEmail": "noreply@em123.example.com",
"allowEmailReplies": False,
"senderEmailForReplies": "reply@em123.example.com",
"isEnabled": True
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sendGridApiKey: 'SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=',
sendGridTemplateID: 'd-8284bb9646a040499d5cfa28d272a094',
sendGridUnsubscribeGroupID: '33832',
senderName: 'Emailer',
senderEmail: 'noreply@em123.example.com',
allowEmailReplies: false,
senderEmailForReplies: 'reply@em123.example.com',
isEnabled: true
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sendGridApiKey' => 'SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=',
'sendGridTemplateID' => 'd-8284bb9646a040499d5cfa28d272a094',
'sendGridUnsubscribeGroupID' => '33832',
'senderName' => 'Emailer',
'senderEmail' => 'noreply@em123.example.com',
'allowEmailReplies' => false,
'senderEmailForReplies' => 'reply@em123.example.com',
'isEnabled' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid"
payload := strings.NewReader("{\n \"sendGridApiKey\": \"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=\",\n \"sendGridTemplateID\": \"d-8284bb9646a040499d5cfa28d272a094\",\n \"sendGridUnsubscribeGroupID\": \"33832\",\n \"senderName\": \"Emailer\",\n \"senderEmail\": \"noreply@em123.example.com\",\n \"allowEmailReplies\": false,\n \"senderEmailForReplies\": \"reply@em123.example.com\",\n \"isEnabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sendGridApiKey\": \"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=\",\n \"sendGridTemplateID\": \"d-8284bb9646a040499d5cfa28d272a094\",\n \"sendGridUnsubscribeGroupID\": \"33832\",\n \"senderName\": \"Emailer\",\n \"senderEmail\": \"noreply@em123.example.com\",\n \"allowEmailReplies\": false,\n \"senderEmailForReplies\": \"reply@em123.example.com\",\n \"isEnabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/notifications/email/v1/providers/sendgrid")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sendGridApiKey\": \"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q=\",\n \"sendGridTemplateID\": \"d-8284bb9646a040499d5cfa28d272a094\",\n \"sendGridUnsubscribeGroupID\": \"33832\",\n \"senderName\": \"Emailer\",\n \"senderEmail\": \"noreply@em123.example.com\",\n \"allowEmailReplies\": false,\n \"senderEmailForReplies\": \"reply@em123.example.com\",\n \"isEnabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"allowEmailReplies": true,
"sendGridApiKey": "sendgrid_key",
"sendGridTemplateID": "template_id",
"sendGridUnsubscribeGroupID": "12312",
"senderEmail": "noreply@em123.example.com",
"senderEmailForReplies": "reply@em123.example.com",
"senderName": "Emailer",
"repliesWebhook": "https://notifications-us.cometchat.io/email/v1/sendgrid/replies?token=GY40_1kWlnc2Lo7Lk8vWWxiNJ6BmEEpV4eZsUeMr328"
}
}For the complete error reference, see Error Guide.
Authorizations
API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Body
application/json
The SendGrid API key
Example:
"SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q="
The SendGrid template ID
Example:
"d-8284bb9646a040499d5cfa28d272a094"
The SendGrid unsubscribe group ID
Example:
"33832"
The name of the sender
Example:
"Emailer"
The email address of the sender
Example:
"noreply@em123.example.com"
The email address when replies are enabled (optional)
Example:
"reply@em123.example.com"
Enable SendGrid
Was this page helpful?
⌘I