Skip to content

Auth

Token

POST https://api.stretch.com/api/v1/auth/token

Get token by username, phone or email and password For getting token require take client id

grant_type = password username = username, phone or email scope = not required client_id = required client_secret = required for admin access

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
grant_type string
username required string
password required string
scope string
client_id string
client_secret string

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests

headers = {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    response = requests.post("https://api.stretch.com/api/v1/auth/token, 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/auth/token";
$headers = array(
    "Content-Type: application/x-www-form-urlencoded",
    "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/auth/token";
        String accessToken = "YOUR_ACCESS_TOKEN";

        try {
            URL apiUrl = new URL(url);
            HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            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/auth/token'
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/x-www-form-urlencoded',
  '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/auth/token';
const headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
  '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/x-www-form-urlencoded");var response = await client.PostAsync(new Uri("https://api.stretch.com/api/v1/auth/token")

    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/auth/token"
    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/x-www-form-urlencoded")
    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/auth/token';
  final accessToken = 'YOUR_ACCESS_TOKEN';

  final headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    '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');
  }
}
Response

Token

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string"
}

ErrorResponse

{
    "code": 401
    "error": "auth_bad_client_credentials"
    "message": "Could not validate oauth2 credentials"
}
{
    "code": 401
    "error": "auth_bad_credentials"
    "message": "Could not validate credentials"
}

ErrorResponse:

error string

message string

code integer

HTTPValidationError

{
    "detail": []
}

Refresh For Access Token

POST https://api.stretch.com/api/v1/auth/refresh

For refresh access token need put "refresh token" to header instead access token

Authorization: Bearer refresh token

refresh token probable can be updated too

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/refresh" \
  -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/auth/refresh, 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/auth/refresh";
$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/auth/refresh";
        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/auth/refresh'
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/auth/refresh';
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/auth/refresh")

    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/auth/refresh"
    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/auth/refresh';
  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');
  }
}
Response

Token

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string"
}

ErrorResponse

{
    "code": 401
    "error": "auth_bad_credentials"
    "message": "Could not validate credentials"
}

ErrorResponse:

error string

message string

code integer

HTTPValidationError

{
    "detail": []
}

Logout

POST https://api.stretch.com/api/v1/auth/logout

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/logout" \
  -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/auth/logout, 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/auth/logout";
$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/auth/logout";
        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/auth/logout'
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/auth/logout';
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/auth/logout")

    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/auth/logout"
    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/auth/logout';
  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');
  }
}

Complete user password reset

PUT https://api.stretch.com/api/v1/auth/password-reset

Complete password reset

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
old_password string Old password needed for replace only
password string Save password Password

Code sample

curl -X PUT \
  --url "https://api.stretch.com/api/v1/auth/password-reset" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "old_password": "string",
        "password": "string"
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "old_password": "string",
        "password": "string"
    }
    response = requests.put("https://api.stretch.com/api/v1/auth/password-reset", 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/auth/password-reset";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "old_password": "string",
        "password": "string"
    }
);

$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/auth/password-reset";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "old_password": "string",
        "password": "string"
    };

        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/auth/password-reset'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "old_password": "string",
        "password": "string"
    }.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/auth/password-reset';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "old_password": "string",
        "password": "string"
    };

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 = {
        "old_password": "string",
        "password": "string"
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PutAsync(new Uri("https://api.stretch.com/api/v1/auth/password-reset"), 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/auth/password-reset"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "old_password": "string",
        "password": "string"
    }
    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/auth/password-reset';
  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

Token

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string"
}

HTTPValidationError

{
    "detail": []
}

Password reset

POST https://api.stretch.com/api/v1/auth/password-reset

Password reset with your phone.

Flow:

POST /password-reset +phone -> access_token and session

POST /verify/phone +session -> sid and sms sended

PUT /verify/phone +sid and code -> success/error after success (your token unlocked for password reset)

PUT /password-reset +password -> new access_token and reset token

After set password all other sessions will drop

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
grant_type required string reset
client_id string (uuid) 2f9445b3-5266-45cd-8a85-d5c3fff69781
client_secret string
phone string Phone number in international format
+97100000000

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/password-reset" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    }
    response = requests.post("https://api.stretch.com/api/v1/auth/password-reset", 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/auth/password-reset";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    }
);

$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/auth/password-reset";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    };

        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/auth/password-reset'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    }.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/auth/password-reset';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    };

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 = {
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PostAsync(new Uri("https://api.stretch.com/api/v1/auth/password-reset"), 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/auth/password-reset"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "grant_type": "reset",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "phone": "+97100000000"
    }
    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/auth/password-reset';
  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

UserSignupOut

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string",
    "type": "guest",
    "phone": "+97100000000",
    "email": "[email protected]",
    "verifed_phone": False,
    "verifed_email": False,
    "session": "string"
}

HTTPValidationError

{
    "detail": []
}

Signup

POST https://api.stretch.com/api/v1/auth/signup

Sign up with your phone. Now allow make only phone signup.

Flow:

POST signup -> take access_token and use this token in all next requests

POST verify/phone -> create session request for phone verification

PUT verify/phone -> check session request by sid (if success your access_token unlocked for registration)

PUT complete -> create account with password and additional user info

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
grant_type required string create
client_id string (uuid) 2f9445b3-5266-45cd-8a85-d5c3fff69781
client_secret string
timezone string Default timezone for user
Asia/Dubai
email string Email format
[email protected]
phone string Phone number in international format
+97100000000
type required Type of signup user: client, coach, studio
client

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/signup" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    }
    response = requests.post("https://api.stretch.com/api/v1/auth/signup", 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/auth/signup";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    }
);

$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/auth/signup";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    };

        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/auth/signup'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    }.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/auth/signup';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    };

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 = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PostAsync(new Uri("https://api.stretch.com/api/v1/auth/signup"), 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/auth/signup"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai",
        "email": "[email protected]",
        "phone": "+97100000000",
        "type": "guest"
    }
    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/auth/signup';
  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

UserSignupOut

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string",
    "type": "guest",
    "phone": "+97100000000",
    "email": "[email protected]",
    "verifed_phone": False,
    "verifed_email": False,
    "session": "string"
}

HTTPValidationError

{
    "detail": []
}

Signup like guest

POST https://api.stretch.com/api/v1/auth/guest

Sign up with your like guest.

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
grant_type required string create
client_id string (uuid) 2f9445b3-5266-45cd-8a85-d5c3fff69781
client_secret string
timezone string Default timezone for user
Asia/Dubai

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/guest" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    }
    response = requests.post("https://api.stretch.com/api/v1/auth/guest", 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/auth/guest";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    }
);

$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/auth/guest";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    };

        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/auth/guest'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    }.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/auth/guest';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    };

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 = {
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PostAsync(new Uri("https://api.stretch.com/api/v1/auth/guest"), 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/auth/guest"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "grant_type": "create",
        "client_id": "2f9445b3-5266-45cd-8a85-d5c3fff69781",
        "client_secret": "string",
        "timezone": "Asia/Dubai"
    }
    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/auth/guest';
  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

UserSignupOut

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string",
    "type": "guest",
    "phone": "+97100000000",
    "email": "[email protected]",
    "verifed_phone": False,
    "verifed_email": False,
    "session": "string"
}

HTTPValidationError

{
    "detail": []
}

Check Phone

POST https://api.stretch.com/api/v1/auth/verify/phone/check

Ensures that the phone is verified and is able to receive messages or SMS.

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/verify/phone/check" \
  -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/auth/verify/phone/check, 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/auth/verify/phone/check";
$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/auth/verify/phone/check";
        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/auth/verify/phone/check'
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/auth/verify/phone/check';
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/auth/verify/phone/check")

    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/auth/verify/phone/check"
    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/auth/verify/phone/check';
  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');
  }
}
Response

HTTPValidationError

{
    "detail": []
}

Check verify phone request

PUT https://api.stretch.com/api/v1/auth/verify/phone

Verify phone number :param data: :param user: :return:

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
sid required string Verification sid
code required integer Verification code (1 attempt)
0000

Code sample

curl -X PUT \
  --url "https://api.stretch.com/api/v1/auth/verify/phone" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "sid": "string",
        "code": 0000
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "sid": "string",
        "code": 0000
    }
    response = requests.put("https://api.stretch.com/api/v1/auth/verify/phone", 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/auth/verify/phone";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "sid": "string",
        "code": 0000
    }
);

$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/auth/verify/phone";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "sid": "string",
        "code": 0000
    };

        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/auth/verify/phone'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "sid": "string",
        "code": 0000
    }.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/auth/verify/phone';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "sid": "string",
        "code": 0000
    };

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 = {
        "sid": "string",
        "code": 0000
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PutAsync(new Uri("https://api.stretch.com/api/v1/auth/verify/phone"), 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/auth/verify/phone"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "sid": "string",
        "code": 0000
    }
    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/auth/verify/phone';
  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

MobileCodeOut

{
    "status": "string"
}

ErrorResponse

{
    "code": 400
    "error": "auth_user_phone_empty_code"
    "message": "Empty code not allowed"
}
{
    "code": 400
    "error": "auth_user_blocked"
    "message": "User blocked"
}
{
    "code": 400
    "error": "auth_user_phone_invalid_code"
    "message": "Invalid code"
}

ErrorResponse:

error string

message string

code integer

ErrorResponse

{
    "code": 401
    "error": "auth_user_attempt_blocked"
    "message": "User attempt blocked. Slow down."
}

ErrorResponse:

error string

message string

code integer

HTTPValidationError

{
    "detail": []
}

Create verify phone request

POST https://api.stretch.com/api/v1/auth/verify/phone

Verifies the newly added phone number.

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
session string Validation session hash
channel string default: _sms_ Channel for sending smss

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/verify/phone" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "session": "string",
        "channel": "sms"
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "session": "string",
        "channel": "sms"
    }
    response = requests.post("https://api.stretch.com/api/v1/auth/verify/phone", 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/auth/verify/phone";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "session": "string",
        "channel": "sms"
    }
);

$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/auth/verify/phone";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "session": "string",
        "channel": "sms"
    };

        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/auth/verify/phone'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "session": "string",
        "channel": "sms"
    }.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/auth/verify/phone';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "session": "string",
        "channel": "sms"
    };

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 = {
        "session": "string",
        "channel": "sms"
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PostAsync(new Uri("https://api.stretch.com/api/v1/auth/verify/phone"), 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/auth/verify/phone"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "session": "string",
        "channel": "sms"
    }
    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/auth/verify/phone';
  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

MobileOut

{
    "sid": "string",
    "time_expire": 600,
    "time_repeat": 600
}

ErrorResponse

{
    "code": 400
    "error": "auth_user_blocked"
    "message": "User blocked"
}
{
    "code": 400
    "error": "auth_user_phone_already_verified"
    "message": "User phone already verified"
}
{
    "code": 400
    "error": "auth_user_attempt_please_wait"
    "message": "Please wait 60 seconds for next request"
}

ErrorResponse:

error string

message string

code integer

ErrorResponse

{
    "code": 400
    "error": "auth_user_attempt_retry_blocked"
    "message": "Attempts for sending sms blocked"
}

ErrorResponse:

error string

message string

code integer

HTTPValidationError

{
    "detail": []
}

Check Verify Email

GET https://api.stretch.com/api/v1/auth/verify/email

Verifies if the email given is verified or not by making a comparison with the UUID code.

Code sample

curl -X GET \
  --url "https://api.stretch.com/api/v1/auth/verify/email" \
  -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/auth/verify/email, 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/auth/verify/email";
$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/auth/verify/email";
        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/auth/verify/email'
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/auth/verify/email';
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/auth/verify/email")

    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/auth/verify/email"
    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/auth/verify/email';
  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

HTTPValidationError

{
    "detail": []
}

Create verify email request

POST https://api.stretch.com/api/v1/auth/verify/email

Sends a request to verify user's email.

Code sample

curl -X POST \
  --url "https://api.stretch.com/api/v1/auth/verify/email" \
  -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/auth/verify/email, 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/auth/verify/email";
$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/auth/verify/email";
        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/auth/verify/email'
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/auth/verify/email';
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/auth/verify/email")

    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/auth/verify/email"
    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/auth/verify/email';
  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');
  }
}
Response

EmailOut

{
    "time_expire": 600,
    "time_repeat": 600
}

ErrorResponse

{
    "code": 400
    "error": "auth_user_email_already_verified"
    "message": "User email already verified"
}
{
    "code": 400
    "error": "auth_user_blocked"
    "message": "User blocked"
}
{
    "code": 400
    "error": "auth_user_attempt_please_wait"
    "message": "Please wait 60 seconds for next request"
}

ErrorResponse:

error string

message string

code integer

Complete user registration

PUT https://api.stretch.com/api/v1/auth/complete

Complete user registration

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
gender User gender
male
oldPassword string Old password needed for replace only
password string Save password Password
email string Email for getting bill information and etc
username string Username input
firstName string First name input
lastName string Last name input

Code sample

curl -X PUT \
  --url "https://api.stretch.com/api/v1/auth/complete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    }
    response = requests.put("https://api.stretch.com/api/v1/auth/complete", 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/auth/complete";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    }
);

$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/auth/complete";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    };

        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/auth/complete'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    }.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/auth/complete';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    };

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 = {
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PutAsync(new Uri("https://api.stretch.com/api/v1/auth/complete"), 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/auth/complete"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "gender": "male",
        "oldPassword": "string",
        "password": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string"
    }
    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/auth/complete';
  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

Token

{
    "access_token": "string",
    "refresh_token": "string",
    "token_type": "bearer",
    "access_expire": 1234,
    "refresh_expire": 1234,
    "scopes": "string"
}

HTTPValidationError

{
    "detail": []
}

Get User Info

GET https://api.stretch.com/api/v1/auth/user

Code sample

curl -X GET \
  --url "https://api.stretch.com/api/v1/auth/user" \
  -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/auth/user, 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/auth/user";
$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/auth/user";
        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/auth/user'
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/auth/user';
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/auth/user")

    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/auth/user"
    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/auth/user';
  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

UserProfileOut

{
    "gender": "male",
    "birthDate": "2000-07-08",
    "timezone": "Asia/Dubai",
    "firstName": "John",
    "lastName": "Smith",
    "description": "string",
    "languages": [],
    "experience": 3,
    "requiresParking": False,
    "id": "cf6e0f9c-ae94-4d72-8faf-cdc90394c261",
    "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": 
}

Put User Info

PUT https://api.stretch.com/api/v1/auth/user

Input Fields / Form-Data / JSON

Query Parameter Type Description Example
gender User gender
male
birthDate string (date) User Birth date
2000-07-08
timezone string Default timezone for user
Asia/Dubai
firstName string User first
John
lastName string User last name
Smith
description string About
languages array Languages
experience integer Experience in years
3
requiresParking boolean Requires parking

Code sample

curl -X PUT \
  --url "https://api.stretch.com/api/v1/auth/user" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -d '{
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    }'
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

try:
    payload = {
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    }
    response = requests.put("https://api.stretch.com/api/v1/auth/user", 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/auth/user";
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
);


$payload = array(
    {
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    }
);

$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/auth/user";
        String accessToken = "YOUR_ACCESS_TOKEN";
        String payload = {
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    };

        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/auth/user'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    }.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/auth/user';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
};

const payload = {
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    };

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 = {
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    }
    var content = new StringContent(payload, Encoding.UTF8, "application/json");
    var response = await client.PutAsync(new Uri("https://api.stretch.com/api/v1/auth/user"), 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/auth/user"
    accessToken := "YOUR_ACCESS_TOKEN"

    client := &http.Client{}
    payload := map[string]string{
        "gender": "male",
        "birthDate": "2000-07-08",
        "timezone": "Asia/Dubai",
        "firstName": "John",
        "lastName": "Smith",
        "description": "string",
        "languages": [],
        "experience": 3,
        "requiresParking": False
    }
    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/auth/user';
  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

UserProfileOut

{
    "gender": "male",
    "birthDate": "2000-07-08",
    "timezone": "Asia/Dubai",
    "firstName": "John",
    "lastName": "Smith",
    "description": "string",
    "languages": [],
    "experience": 3,
    "requiresParking": False,
    "id": "49005dfe-7fda-41f3-8268-5d60c3f21704",
    "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": 
}

ErrorResponse

{
    "code": 400
    "error": "coach_validation_field_error"
    "message": "Validation field error"
}

ErrorResponse:

error string

message string

code integer

HTTPValidationError

{
    "detail": []
}