Notification
Get User Notifications
GET
https://api.stretch.com/api/v1/notifications
Get notified upon receiving any user request or interaction.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/notifications" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/notifications, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/notifications" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/notifications" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/notifications'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/notifications' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/notifications" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/notifications"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/notifications' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (200) Validation Error (422)
Notification
[{
"id" : "061e4365-ba03-48a3-a757-dfd641e2ebe9" ,
"type" : "string" ,
"contentType" : "string" ,
"contentId" : "d00f938c-d1d3-4022-ac0f-8dfa79a7cd8a" ,
"message" : "string" ,
"unread" : True ,
"createdAt" : "string"
},{
"id" : "a47370e5-6178-4171-a7f4-ccdfaf9139e6" ,
"type" : "string" ,
"contentType" : "string" ,
"contentId" : "166197bf-fb05-405f-8f9d-39045aec61bb" ,
"message" : "string" ,
"unread" : True ,
"createdAt" : "string"
}]
Put User Readed Notifications
PUT
https://api.stretch.com/api/v1/notifications
Update the status of the notification by changing the status from unread to read for easy filtration.
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
notifications
array
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X PUT \
--url "https://api.stretch.com/api/v1/notifications" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"notifications": []
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"notifications" : []
}
response = requests . put ( "https://api.stretch.com/api/v1/notifications" , headers = headers , json = payload )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/notifications" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"notifications" : []
}
);
$data_string = json_encode ( $payload );
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true ); curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , $data_string );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.io.OutputStream ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/notifications" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"notifications" : []
};
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "PUT" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
connection . setDoOutput ( true );
OutputStream outputStream = connection . getOutputStream ();
outputStream . write ( payload . getBytes ( "UTF-8" ));
outputStream . flush ();
outputStream . close ();
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/notifications'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"notifications" : []
} . to_json
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Put . new ( uri . request_uri , headers )
request . body = payload
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/notifications' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"notifications" : []
};
axios
. put ( url , payload , { headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
using System.Text ;
using System.Threading.Tasks ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" );
var payload = {
"notifications" : []
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PutAsync ( new Uri ( "https://api.stretch.com/api/v1/notifications" ), content );
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main () {
url := "https://api.stretch.com/api/v1/notifications"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"notifications" : []
}
jsonPayload , err := json . Marshal ( payload )
req , err := http . NewRequest ( "PUT" , url , bytes . NewBuffer ( jsonPayload ))
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/notifications' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
final payload = jsonEncode ( application / json );
try {
final response = await http . post ( Uri . parse ( url ), headers: headers , body: payload );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Notify Event
POST
https://api.stretch.com/api/v1/notification/event
Get notified upon receiving any user request or interaction.
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
notificationIds
array
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/notification/event" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"notificationIds": []
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"notificationIds" : []
}
response = requests . post ( "https://api.stretch.com/api/v1/notification/event" , headers = headers , json = payload )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/notification/event" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"notificationIds" : []
}
);
$data_string = json_encode ( $payload );
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true ); curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , $data_string );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.io.OutputStream ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/notification/event" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"notificationIds" : []
};
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
connection . setDoOutput ( true );
OutputStream outputStream = connection . getOutputStream ();
outputStream . write ( payload . getBytes ( "UTF-8" ));
outputStream . flush ();
outputStream . close ();
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/notification/event'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"notificationIds" : []
} . to_json
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
request . body = payload
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/notification/event' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"notificationIds" : []
};
axios
. post ( url , payload , { headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
using System.Text ;
using System.Threading.Tasks ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" );
var payload = {
"notificationIds" : []
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/notification/event" ), content );
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main () {
url := "https://api.stretch.com/api/v1/notification/event"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"notificationIds" : []
}
jsonPayload , err := json . Marshal ( payload )
req , err := http . NewRequest ( "POST" , url , bytes . NewBuffer ( jsonPayload ))
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/notification/event' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
final payload = jsonEncode ( application / json );
try {
final response = await http . post ( Uri . parse ( url ), headers: headers , body: payload );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Channel Event
POST
https://api.stretch.com/api/v1/notification/channel
Get notified upon receiving any user request or interaction.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/notification/channel" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . post ( "https://api.stretch.com/api/v1/notification/channel, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/notification/channel" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/notification/channel" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/notification/channel'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/notification/channel' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. post ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/notification/channel" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/notification/channel"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "POST" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/notification/channel' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . post ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Gmail Init
POST
https://api.stretch.com/api/v1/notification/channel/gmail-init
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/notification/channel/gmail-init" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . post ( "https://api.stretch.com/api/v1/notification/channel/gmail-init, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/notification/channel/gmail-init" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/notification/channel/gmail-init" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/notification/channel/gmail-init'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/notification/channel/gmail-init' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. post ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/notification/channel/gmail-init" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/notification/channel/gmail-init"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "POST" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/notification/channel/gmail-init' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . post ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Get Notifications
GET
https://api.stretch.com/manage/admin/notifications
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/manage/admin/notifications" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/manage/admin/notifications, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/manage/admin/notifications" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/manage/admin/notifications" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/manage/admin/notifications'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/manage/admin/notifications' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/manage/admin/notifications" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/manage/admin/notifications"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/manage/admin/notifications' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
View Notification Event
GET
https://api.stretch.com/manage/admin/notifications/{notification_id}
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/manage/admin/notifications/{notification_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/manage/admin/notifications/ {notification_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/manage/admin/notifications/{notification_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/manage/admin/notifications/{notification_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/manage/admin/notifications/{notification_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/manage/admin/notifications/{notification_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/manage/admin/notifications/{notification_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/manage/admin/notifications/{notification_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/manage/admin/notifications/{notification_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Get Notifications
GET
https://api.stretch.com/admin/notifications
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/admin/notifications" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/admin/notifications, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/admin/notifications" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/admin/notifications" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/admin/notifications'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/admin/notifications' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/admin/notifications" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/admin/notifications"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/admin/notifications' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
View Notification Event
GET
https://api.stretch.com/admin/notifications/{notification_id}
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/admin/notifications/{notification_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/admin/notifications/ {notification_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/admin/notifications/{notification_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/admin/notifications/{notification_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/admin/notifications/{notification_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/admin/notifications/{notification_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/admin/notifications/{notification_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/admin/notifications/{notification_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/admin/notifications/{notification_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response