Availability
Get Coach Availability Calendar
GET
https://api.stretch.com/api/v1/coach/availability/calendar
Get coach's availability from date and choose from list of slots.
Returns the available slot from the start date till the end date.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/coach/availability/calendar" \
-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/coach/availability/calendar, 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/coach/availability/calendar" ;
$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/coach/availability/calendar" ;
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/coach/availability/calendar'
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/coach/availability/calendar' ;
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/coach/availability/calendar" )
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/coach/availability/calendar"
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/coach/availability/calendar' ;
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 Coach Availability Calendar2
GET
https://api.stretch.com/api/v1/coach/availability/calendar2
Get coach's availability from date and choose from list of slots.
Returns the available slot from the start date till the end date.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/coach/availability/calendar2" \
-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/coach/availability/calendar2, 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/coach/availability/calendar2" ;
$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/coach/availability/calendar2" ;
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/coach/availability/calendar2'
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/coach/availability/calendar2' ;
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/coach/availability/calendar2" )
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/coach/availability/calendar2"
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/coach/availability/calendar2' ;
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
Bad Request (400) Validation Error (422)
ErrorResponse
{
"code" : 400
"error" : "coach_availability_input_wrong"
"message" : "Availability input values wrong"
}
ErrorResponse:
error string
message string
code integer
Get Coach Availability
GET
https://api.stretch.com/api/v1/coach/availability
Get coach's availability from date and choose from list of slots.
Returns the available slot from the start date till the end date.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/coach/availability" \
-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/coach/availability, 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/coach/availability" ;
$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/coach/availability" ;
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/coach/availability'
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/coach/availability' ;
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/coach/availability" )
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/coach/availability"
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/coach/availability' ;
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) Bad Request (400) Validation Error (422)
Availability
[{
"id" : "90bc922a-8792-4756-8f7b-80e385e66a60" ,
"title" : "string" ,
"slotType" : "daily" ,
"slotState" : "available" ,
"enable" : True ,
"client" : "string"
},{
"id" : "784b1136-ad05-43c0-99d0-17973f5f583b" ,
"title" : "string" ,
"slotType" : "daily" ,
"slotState" : "available" ,
"enable" : True ,
"client" : "string"
}]
ErrorResponse
{
"code" : 400
"error" : "coach_availability_input_wrong"
"message" : "Availability input values wrong"
}
ErrorResponse:
error string
message string
code integer
Create Time Slot Availability
POST
https://api.stretch.com/api/v1/coach/availability
Creates a time slot availability to record available times for the coaches and
to ensure there is no coinciding session stacking.
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
title
string
start
string (date-time)
Start date when slot is working
2023-06-12
end
string (date-time)
End date when slot is working
enable
boolean default: _True_
True
slotStart
string (time)
10:15
slotEnd
string (time)
16:30
slotType
default: _none_
none
slotState
default: _available_
available
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/coach/availability" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"title": "string",
"start": "2023-06-12",
"end": "string",
"enable": True,
"slotStart": "10:15",
"slotEnd": "16:30",
"slotType": "daily",
"slotState": "available"
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
response = requests . post ( "https://api.stretch.com/api/v1/coach/availability" , 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/coach/availability" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
);
$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/coach/availability" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
};
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/coach/availability'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
} . 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/coach/availability' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
};
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 = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/coach/availability" ), 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/coach/availability"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
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/coach/availability' ;
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
Get Time Slot Availability
GET
https://api.stretch.com/api/v1/coach/availability/{availability_id}
Get the availability time for coaches if there is a current time schedule or returns null if unavailable.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/coach/availability/{availability_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/api/v1/coach/availability/ {availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_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
Update Time Slot Availability
PUT
https://api.stretch.com/api/v1/coach/availability/{availability_id}
Update the current time availability for the specified coach using the availability id and returns
the information updated.
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
title
string
start
string (date)
2023-06-12
end
string (date-time)
End date when slot is working
enable
boolean default: _True_
True
slotStart
string (time)
10:15
slotEnd
string (time)
16:30
slotType
default: _none_
none
slotState
default: _available_
available
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X PUT \
--url "https://api.stretch.com/api/v1/coach/availability/{availability_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"title": "string",
"start": "2023-06-12",
"end": "string",
"enable": True,
"slotStart": "10:15",
"slotEnd": "16:30",
"slotType": "daily",
"slotState": "available"
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
response = requests . put ( "https://api.stretch.com/api/v1/coach/availability/ {availability_id} " , 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/coach/availability/{availability_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
);
$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/coach/availability/{availability_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
};
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/coach/availability/{availability_id}'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
} . 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/coach/availability/{availability_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
};
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 = {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PutAsync ( new Uri ( "https://api.stretch.com/api/v1/coach/availability/{availability_id}" ), 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/coach/availability/{availability_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"title" : "string" ,
"start" : "2023-06-12" ,
"end" : "string" ,
"enable" : True ,
"slotStart" : "10:15" ,
"slotEnd" : "16:30" ,
"slotType" : "daily" ,
"slotState" : "available"
}
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/coach/availability/{availability_id}' ;
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
Successful Response (200) Bad Request (400) Bad Request (404) Validation Error (422)
Availability
{
"id" : "d6df4fec-ea74-4914-9e8d-bae6d24b2408" ,
"title" : "string" ,
"slotType" : "daily" ,
"slotState" : "available" ,
"enable" : True ,
"client" : "string"
}
ErrorResponse
{
"code" : 400
"error" : "coach_availability_input_wrong"
"message" : "Availability input values wrong"
}
{
"code" : 400
"error" : "coach_availability_none_end_date"
"message" : "Availability input values wrong. End date for none must be null"
}
ErrorResponse:
error string
message string
code integer
ErrorResponse
{
"code" : 404
"error" : "coach_availability_not_found"
"message" : "Availability not found"
}
ErrorResponse:
error string
message string
code integer
Remove Slot Availability
DELETE
https://api.stretch.com/api/v1/coach/availability/{availability_id}
Remove the time schedule for the allotted time for the coach and returns the status of procedure.
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X DELETE \
--url "https://api.stretch.com/api/v1/coach/availability/{availability_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 . delete ( "https://api.stretch.com/api/v1/coach/availability/ {availability_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/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "DELETE" );
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/coach/availability/{availability_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 :: Delete . 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/coach/availability/{availability_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. delete ( 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 . DeleteAsync ( new Uri ( "https://api.stretch.com/api/v1/coach/availability/{availability_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/api/v1/coach/availability/{availability_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "DELETE" , 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/coach/availability/{availability_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . delete ( 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
Bad Request (404) Validation Error (422)
ErrorResponse
{
"code" : 404
"error" : "coach_availability_not_found"
"message" : "Availability not found"
}
ErrorResponse:
error string
message string
code integer
Coach Available
PUT
https://api.stretch.com/api/v1/coach/available
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
available
boolean default: _True_
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X PUT \
--url "https://api.stretch.com/api/v1/coach/available" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"available": True
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"available" : True
}
response = requests . put ( "https://api.stretch.com/api/v1/coach/available" , 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/coach/available" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"available" : True
}
);
$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/coach/available" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"available" : True
};
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/coach/available'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"available" : True
} . 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/coach/available' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"available" : True
};
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 = {
"available" : True
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PutAsync ( new Uri ( "https://api.stretch.com/api/v1/coach/available" ), 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/coach/available"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"available" : True
}
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/coach/available' ;
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
Successful Response (200) Validation Error (422)
UserProfileOut
{
"gender" : "male" ,
"birthDate" : "2000-07-08" ,
"timezone" : "Asia/Dubai" ,
"firstName" : "John" ,
"lastName" : "Smith" ,
"description" : "string" ,
"languages" : [],
"experience" : 3 ,
"requiresParking" : False ,
"id" : "8e89b163-7dc5-4a4f-9050-1bc11fa1363c" ,
"type" : "guest" ,
"username" : "string" ,
"phone" : "+97100000000" ,
"email" : "[email protected] " ,
"verifiedPhone" : False ,
"verifiedEmail" : False ,
"available" : False ,
"verified" : False ,
"avatarUrl" : "string" ,
"mediaType" : "string" ,
"mediaUrl" : "string" ,
"mediaPreviewUrl" : "string" ,
"sessionCount" : 1234 ,
"totalPayment" : 1234 ,
"totalPaymentCurrency" : "string" ,
"profileCompletion" :
}