Verify Session
curl --request POST \
--url https://api.moonkey.fun/v1/auth/sessions/verify \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"session_token": "NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT",
"session_expires_in": 1000
}
'import requests
url = "https://api.moonkey.fun/v1/auth/sessions/verify"
payload = {
"session_token": "NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT",
"session_expires_in": 1000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
session_token: 'NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT',
session_expires_in: 1000
})
};
fetch('https://api.moonkey.fun/v1/auth/sessions/verify', 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.moonkey.fun/v1/auth/sessions/verify",
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([
'session_token' => 'NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT',
'session_expires_in' => 1000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.moonkey.fun/v1/auth/sessions/verify"
payload := strings.NewReader("{\n \"session_token\": \"NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT\",\n \"session_expires_in\": 1000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.moonkey.fun/v1/auth/sessions/verify")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"session_token\": \"NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT\",\n \"session_expires_in\": 1000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonkey.fun/v1/auth/sessions/verify")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_token\": \"NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT\",\n \"session_expires_in\": 1000\n}"
response = http.request(request)
puts response.read_body{
"session": {
"id": "sess_24tZ6tlJ7CxlTwB6Zoj6SHQ9vU3",
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"started_at": 1643163802,
"expires_at": 1643288111,
"last_active_at": 1643228111,
"factors": [
{
"delivery_channel": "sms",
"type": "otp",
"method": {
"method_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"method_type": "phone_number",
"phone_number_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"phone_number": "+14152222222",
"last_verified_at": 1643163802
}
}
],
"device_fingerprint": {
"user_agent": "",
"ip": ""
},
"updated_at": 1643228111,
"created_at": 1643163802
},
"session_token": "NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT",
"session_jwt": "eyJhbGciOiJIU..."
}Sessions
Verify Session
Verify session in an application by session token and/or optionally extend the expiration time of the session by N minutes from now if the session_expires_in property is present.
Returns
A successful response returns a Session object with associated authentication factors that include unique identifiers and delivery methods.
POST
/
v1
/
auth
/
sessions
/
verify
Verify Session
curl --request POST \
--url https://api.moonkey.fun/v1/auth/sessions/verify \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"session_token": "NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT",
"session_expires_in": 1000
}
'import requests
url = "https://api.moonkey.fun/v1/auth/sessions/verify"
payload = {
"session_token": "NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT",
"session_expires_in": 1000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
session_token: 'NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT',
session_expires_in: 1000
})
};
fetch('https://api.moonkey.fun/v1/auth/sessions/verify', 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.moonkey.fun/v1/auth/sessions/verify",
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([
'session_token' => 'NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT',
'session_expires_in' => 1000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.moonkey.fun/v1/auth/sessions/verify"
payload := strings.NewReader("{\n \"session_token\": \"NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT\",\n \"session_expires_in\": 1000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.moonkey.fun/v1/auth/sessions/verify")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"session_token\": \"NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT\",\n \"session_expires_in\": 1000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonkey.fun/v1/auth/sessions/verify")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_token\": \"NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT\",\n \"session_expires_in\": 1000\n}"
response = http.request(request)
puts response.read_body{
"session": {
"id": "sess_24tZ6tlJ7CxlTwB6Zoj6SHQ9vU3",
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"started_at": 1643163802,
"expires_at": 1643288111,
"last_active_at": 1643228111,
"factors": [
{
"delivery_channel": "sms",
"type": "otp",
"method": {
"method_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"method_type": "phone_number",
"phone_number_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"phone_number": "+14152222222",
"last_verified_at": 1643163802
}
}
],
"device_fingerprint": {
"user_agent": "",
"ip": ""
},
"updated_at": 1643228111,
"created_at": 1643163802
},
"session_token": "NGTCMAk51ItYAan83C6BLYXm7iJsKY0kCpsVj5WdJGg10eslpceC6MSS2RSqbUzT",
"session_jwt": "eyJhbGciOiJIU..."
}Authorizations
Auth Platform API includes all the Auth related features. All Users, Phone Numbers, Emails, and OTPs are associated with an App as the container.
Endpoints only accept App's Secret API keys other than certain endpoints that are used client side or via SDK that accept the public_token.
Authentication using App Api Key
Header:
Authorization: Bearer {api_key}
Authenticated Request
curl \ -X GET https://api.moonkey.fun/v1/auth/users/user_24wFP9pDa9YiMJLun94iKykoZs2 \ -H "Authorization: Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1r"
Body
application/json
⌘I