Get access token
curl --request POST \
--url https://api.teleship.com/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"clientId": "your-client-id",
"clientSecret": "your-client-secret"
}
'import requests
url = "https://api.teleship.com/oauth/token"
payload = {
"clientId": "your-client-id",
"clientSecret": "your-client-secret"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({clientId: 'your-client-id', clientSecret: 'your-client-secret'})
};
fetch('https://api.teleship.com/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.teleship.com/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.teleship.com/oauth/token"
payload := strings.NewReader("{\n \"clientId\": \"your-client-id\",\n \"clientSecret\": \"your-client-secret\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.teleship.com/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"clientId\": \"your-client-id\",\n \"clientSecret\": \"your-client-secret\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.teleship.com/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"clientId\": \"your-client-id\",\n \"clientSecret\": \"your-client-secret\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjMzMDUxMThiZTBmNTZkYzA4NGE0NmExN2RiNzU1NjVkNzY4YmE2ZmUiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiIiwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL3RlbGVzaGlwLWY5OTA4IiwiYXVkIjoidGVsZXNoaXAtZjk5MDgiLCJhdXRoX3RpbWUiOjE3MTc2OTkyMDgsInVzZXJfaWQiOiJjZDg2ZjUzMS02MjNhLTQ4Y2MtYTdlZS0yNDhiODA2ZWM2ZTYiLCJzdWIiOiJjZDg2ZjUzMS02MjNhLTQ4Y2MtYTdlZS0yNDhiODA2ZWM2ZTYiLCJpYXQiOjE3MTc2OTkyMDgsImV4cCI6MTcxNzcwMjgwOCwiZW1haWwiOiJjZDg2ZjUzMS02MjNhLTQ4Y2MtYTdlZS0yNDhiODA2ZWM2ZTZAYXV0aC50ZWxlc2hpcC50ZWxlc2hpcC5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsiY2Q4NmY1MzEtNjIzYS00OGNjLWE3ZWUtMjQ4YjgwNmVjNmU2QGF1dGgudGVsZXNoaXAudGVsZXNoaXAuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQifX0.H2VPnCqHyfYNeiQzPDgnrRnaDv_SLhK7OKquWoxFql5szjn5uMeYQzxCDj9iCxFMYaPN5JnCqNonOH6Feat3HML79oEi58WE43jpxoygqDlS2r1dzGCiuywaHgXKcVnVrL5cDhcWquMz1mtrY0iwqH8N8pUleIOBE1n5NGWFDedXX0JI3taaX9eGW2AHq_vIx-69WchA75_tZV0_vSDRo8vWddSfvwqVqEo3fooQS6mfMwW2jsaaBj3N-BffyXlaI2FasiO6yN9ofLZ4kbuoRxn1BZE8ER6POn60DX2WlWYg0OV8dCbKLHSGSp_xQuyLYwiroW3lB5y1SKjoKAT2YA",
"expirationTime": 1717702808582,
"expiresIn": 3600000,
"tokenType": "Bearer"
}{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}Authentication
Get access token
Obtain an OAuth2 access token for API authentication.
How it works:
- Provide your client credentials (client_id and client_secret)
- Receive a Bearer token for API access
- Token expires after 1 hour
Security:
- Always use HTTPS
- Store credentials securely
- Never expose client_secret in client-side code
POST
/
oauth
/
token
Get access token
curl --request POST \
--url https://api.teleship.com/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"clientId": "your-client-id",
"clientSecret": "your-client-secret"
}
'import requests
url = "https://api.teleship.com/oauth/token"
payload = {
"clientId": "your-client-id",
"clientSecret": "your-client-secret"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({clientId: 'your-client-id', clientSecret: 'your-client-secret'})
};
fetch('https://api.teleship.com/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.teleship.com/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.teleship.com/oauth/token"
payload := strings.NewReader("{\n \"clientId\": \"your-client-id\",\n \"clientSecret\": \"your-client-secret\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.teleship.com/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"clientId\": \"your-client-id\",\n \"clientSecret\": \"your-client-secret\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.teleship.com/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"clientId\": \"your-client-id\",\n \"clientSecret\": \"your-client-secret\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjMzMDUxMThiZTBmNTZkYzA4NGE0NmExN2RiNzU1NjVkNzY4YmE2ZmUiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiIiwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL3RlbGVzaGlwLWY5OTA4IiwiYXVkIjoidGVsZXNoaXAtZjk5MDgiLCJhdXRoX3RpbWUiOjE3MTc2OTkyMDgsInVzZXJfaWQiOiJjZDg2ZjUzMS02MjNhLTQ4Y2MtYTdlZS0yNDhiODA2ZWM2ZTYiLCJzdWIiOiJjZDg2ZjUzMS02MjNhLTQ4Y2MtYTdlZS0yNDhiODA2ZWM2ZTYiLCJpYXQiOjE3MTc2OTkyMDgsImV4cCI6MTcxNzcwMjgwOCwiZW1haWwiOiJjZDg2ZjUzMS02MjNhLTQ4Y2MtYTdlZS0yNDhiODA2ZWM2ZTZAYXV0aC50ZWxlc2hpcC50ZWxlc2hpcC5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsiY2Q4NmY1MzEtNjIzYS00OGNjLWE3ZWUtMjQ4YjgwNmVjNmU2QGF1dGgudGVsZXNoaXAudGVsZXNoaXAuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQifX0.H2VPnCqHyfYNeiQzPDgnrRnaDv_SLhK7OKquWoxFql5szjn5uMeYQzxCDj9iCxFMYaPN5JnCqNonOH6Feat3HML79oEi58WE43jpxoygqDlS2r1dzGCiuywaHgXKcVnVrL5cDhcWquMz1mtrY0iwqH8N8pUleIOBE1n5NGWFDedXX0JI3taaX9eGW2AHq_vIx-69WchA75_tZV0_vSDRo8vWddSfvwqVqEo3fooQS6mfMwW2jsaaBj3N-BffyXlaI2FasiO6yN9ofLZ4kbuoRxn1BZE8ER6POn60DX2WlWYg0OV8dCbKLHSGSp_xQuyLYwiroW3lB5y1SKjoKAT2YA",
"expirationTime": 1717702808582,
"expiresIn": 3600000,
"tokenType": "Bearer"
}{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}Body
application/json
Response
Access Token Response
JWT access token for API authentication
Example:
"eyJhbGciOiJSUzI1NiIsImtpZCI6IjMzMDUxMThiZTBmNTZkYzA4NGE0NmExN2RiNzU1NjVkNzY4YmE2ZmUiLCJ0eXAiOiJKV1QifQ..."
Token expiration timestamp
Example:
1717702808582
Time until token expiration in milliseconds (not a timestamp)
Example:
3600000
Type of token (always Bearer)
Example:
"Bearer"
Refresh token for obtaining new access tokens
Example:
"AMf-vBx..."
Was this page helpful?
⌘I