Skip to main content
POST
/
api
/
v1
/
token
User Authentication
curl --request POST \
  --url https://api-auth.sandbox.rails.xyz/api/v1/token \
  --header 'X-Api-Key: <x-api-key>' \
  --header 'X-Api-Secret: <x-api-secret>'
import requests

url = "https://api-auth.sandbox.rails.xyz/api/v1/token"

headers = {
"X-Api-Key": "<x-api-key>",
"X-Api-Secret": "<x-api-secret>"
}

response = requests.post(url, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-Api-Key': '<x-api-key>', 'X-Api-Secret': '<x-api-secret>'}
};

fetch('https://api-auth.sandbox.rails.xyz/api/v1/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-auth.sandbox.rails.xyz/api/v1/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-Api-Key: <x-api-key>",
"X-Api-Secret: <x-api-secret>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api-auth.sandbox.rails.xyz/api/v1/token"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("X-Api-Key", "<x-api-key>")
req.Header.Add("X-Api-Secret", "<x-api-secret>")

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-auth.sandbox.rails.xyz/api/v1/token")
.header("X-Api-Key", "<x-api-key>")
.header("X-Api-Secret", "<x-api-secret>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api-auth.sandbox.rails.xyz/api/v1/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<x-api-key>'
request["X-Api-Secret"] = '<x-api-secret>'

response = http.request(request)
puts response.read_body
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50VHlwZSI6InJldGFpbCIsImlzcyI6InN0YWdpbmcuZnVuZ2libGUueHl6Iiwic3ViIjoiNDcwMGYyODItMGFkNC00ZjU1LWIxNDItZGUzZTYwZDVkMTFlIiwiYXVkIjpbInN0YWdpbmctYXBwLmZ1bmdpYmxlLnh5eiJdLCJleHAiOjE3MTA4ODIxNzAsImlhdCI6MTcxMDg4MDM3MH0.Vgh_zKUgPSOPbVQ7nTHVg6jCYZ59nSJwqx6pfSDfGss",
  "token_type": "Bearer",
  "expires_in": 1800
}
{
"error": {
"slug": "UNAUTHORIZED",
"code": "1002"
},
"message": "Unauthorized"
}

Headers

X-Api-Key
string
required

The API key for the user

X-Api-Secret
string
required

The API secret for the user

Response

access_token
string
required

The access token used for API authentication

token_type
string
required

The type of token returned, typically Bearer

expires_in
integer
required

The number of seconds until the token expires