Authorization
FACIA API relies on API keys for request authentication. You can conveniently view and manage your API keys in the FACIA Merchant Portal under account settings. Our API utilizes bearer authentication through Access Tokens and client-secret key authentication. It follows standard HTTP Status Codes and supports JSON/form-data Request and Response bodies. This comprehensive documentation thoroughly details each parameter, ensuring clarity and straightforward implementation.
Using the credentials created during registration, authentication can be performed based on:
- Access Token
- Client-secret key
Get Access Token
For authorization, Facia's SDKs require an Access Token with an expiration period of two days. You can obtain the Access Token using the following API through two methods:
- Email and Password
- Client-ID and Client-Secret Key
Endpoint
POSThttps://api.facia.ai/request-access-token
Request Samples:
1. Email and Password:
- HTTP
- Javascript
- PHP
- Python
- Curl
- Ruby
- Java
- C#
- Go
//POST /request-access-token HTTP/1.1
//HOST : https://api.facia.ai/
//Content-Type: application/json
{
"email": "your_email_here",
"password": "your_password_here"
}
var data = new FormData();
data.append("email", "your_email_here");
data.append("password", "your_password_here");
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "/request-access-token");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/request-access-token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(
'email' => 'your_email_here',
'password' => 'your_password_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "/request-access-token"
payload={
'email': 'your_email_here',
'password': 'your_password_here'}
files=[]
response = requests.re
curl --location 'https://api.facia.ai/request-access-token/' \
--header 'Content-Type: application/json' \
--data '{
"email": "your_email_here",
"password": "your_password_here"
}'
require 'net/http'
require 'uri'
url = URI.parse('/request-access-token')
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path)
request.set_form_data({
'email' => 'your_email_here',
'password' => 'your_password_here'
})
response = http.request(request)
puts response.body
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "/request-access-token";
String email = "your_email_here";
String password = "your_password_here";
try {
URL apiUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
Map<String, String> parameters = new HashMap<>();
parameters.put("email", email);
parameters.put("password", password);
StringBuilder postData = new StringBuilder();
for (Map.Entry<String, String> param : parameters.entrySet()) {
if (postData.length() != 0) {
postData.append('&');
}
postData.append(param.getKey());
postData.append('=');
postData.append(param.getValue());
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
OutputStream outputStream = connection.getOutputStream();
outputStream.write(postDataBytes);
outputStream.flush();
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println(response.toString());
} else {
System.out.println("Request failed with response code: " + responseCode);
}
connection.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string url = "/request-access-token";
string email = "your_email_here";
string password = "your_password_here";
using (HttpClient client = new HttpClient())
{
var payload = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("email", email),
new KeyValuePair<string, string>("password", password)
});
HttpResponseMessage response = await client.PostAsync(url, payload);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine("Request failed with response code: " + response.StatusCode);
}
}
}
}
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
)
func main() {
apiURL := "http://api.facia.ai/request-access-token"
email := "your_email_here"
password := "your_password_here"
payload := map[string]string{
"email": email,
"password": password,
}
data := url.Values{}
for key, value := range payload {
data.Set(key, value)
}
response, err := http.PostForm(apiURL, data)
if err != nil {
fmt.Println("Error:", err)
return
}
defer response.Body.Close()
if response.StatusCode == http.StatusOK {
buffer := new(bytes.Buffer)
buffer.ReadFrom(response.Body)
responseBody := buffer.String()
fmt.Println(responseBody)
} else {
fmt.Printf("Error: %s\n", response.Status)
}
}
2. Client-ID and Client-Secret Key:
- HTTP
- Javascript
- Curl
- PHP
- Python
- Ruby
- Java
- C#
- Go
//POST /request-access-token / HTTP/1.1
//HOST : https://api.facia.ai/
//Content-Type: application/json
{
"client_id": "your_client_id_here",
"client_secret": "your_client_secret_key_here"
}
var data = new FormData();
data.append("client_id", "string");
data.append("client_secret", "string");
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "/request-access-token");
xhr.send(data);
curl --location 'https://api.facia.ai/request-access-token/' \
--header 'Content-Type: application/json' \
--data '{
"client_id": "your_client_id_here",
"client_secret": "your_client_secret_key_here"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/request-access-token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(
'client_id' => 'string',
'client_secret' => 'string'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "/request-access-token"
payload={
'client_id': 'string',
'client_secret': 'string'}
files=[]
response = requests.re
require 'net/http'
require 'uri'
url = URI.parse('/request-access-token')
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path)
request.set_form_data({
'client_id' => 'your_client_id_here',
'client_secret' => 'your_client_secret_here'
})
response = http.request(request)
puts response.body
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "/request-access-token";
String client_id = "your_client_id_here";
String client_secret = "your_client_secret_here";
try {
URL apiUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
Map<String, String> parameters = new HashMap<>();
parameters.put("client_id", client_id);
parameters.put("client_secret", client_secret);
StringBuilder postData = new StringBuilder();
for (Map.Entry<String, String> param : parameters.entrySet()) {
if (postData.length() != 0) {
postData.append('&');
}
postData.append(param.getKey());
postData.append('=');
postData.append(param.getValue());
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
OutputStream outputStream = connection.getOutputStream();
outputStream.write(postDataBytes);
outputStream.flush();
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println(response.toString());
} else {
System.out.println("Request failed with response code: " + responseCode);
}
connection.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string url = "/request-access-token";
string client_id = "your_client_id_here";
string client_secret = "your_client_secret_here";
using (HttpClient client = new HttpClient())
{
var payload = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("client_id", client_id),
new KeyValuePair<string, string>("client_secret", client_secret)
});
HttpResponseMessage response = await client.PostAsync(url, payload);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine("Request failed with response code: " + response.StatusCode);
}
}
}
}
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
)
func main() {
apiURL := "http://api.facia.ai/request-access-token"
clientID := "string"
clientSecret := "string"
payload := map[string]string{
"client_id": clientID,
"client_secret": clientSecret,
}
data := url.Values{}
for key, value := range payload {
data.Set(key, value)
}
response, err := http.PostForm(apiURL, data)
if err != nil {
fmt.Println("Error:", err)
return
}
defer response.Body.Close()
if response.StatusCode == http.StatusOK {
buffer := new(bytes.Buffer)
buffer.ReadFrom(response.Body)
responseBody := buffer.String()
fmt.Println(responseBody)
} else {
fmt.Printf("Error: %s\n", response.Status)
}
}
Request Parameter
Parameters | Description |
---|---|
Required: Yes Type: String | |
password | Required: Yes Type: String |
client-id | Required without email: Yes Type: String |
client-secret | Required without email: Yes Type: String |
Sample Response
{
"status": true,
"message": "token",
"result": {
"data": {
"token": "your_token_here"
}
}
}
Get Client Credentials
Using the credentials created during registration, make a request to the /get-client-credentials
endpoint to obtain your unique client_id and client_secret key. The client_secret key (your unique API key) can be included in the headers to avoid generating a new access token every time.
Endpoint
POSThttps://api.facia.ai/get-client-credentials
Request Samples:
- HTTP
- Javascript
- Curl
- PHP
- Python
- Ruby
- Java
- C#
- Go
//POST /get-client-credentials HTTP/1.1 bearer token
//HOST : https://api.facia.ai/
//Content-Type: application/json
{
"email": "your_email_here",
"password": "your_password_here"
}
var data = new FormData();
data.append("email", "your_email_here");
data.append("password", "your_password_here");
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "/get-client-credentials");
xhr.send(data);
curl --location 'https://api.facia.ai/get-client-credentials/' \
--header 'Content-Type: application/json' \
--data '{
"email": "your_email_here",
"password": "your_password_here"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/get-client-credentials',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(
'email' => 'your_email_here',
'password' => 'your_password_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "/get-client-credentials"
payload={
'email': 'your_email_here',
'password': 'your_password_here'}
files=[]
response = requests.re
require 'net/http'
require 'uri'
url = URI.parse('/get-client-credentials')
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path)
request.set_form_data({
'email' => 'your_email_here',
'password' => 'your_password_here'
})
response = http.request(request)
puts response.body
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "/get-client-credentials";
String email = "your_email_here";
String password = "your_password_here";
try {
URL apiUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
Map<String, String> parameters = new HashMap<>();
parameters.put("email", email);
parameters.put("password", password);
StringBuilder postData = new StringBuilder();
for (Map.Entry<String, String> param : parameters.entrySet()) {
if (postData.length() != 0) {
postData.append('&');
}
postData.append(param.getKey());
postData.append('=');
postData.append(param.getValue());
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
OutputStream outputStream = connection.getOutputStream();
outputStream.write(postDataBytes);
outputStream.flush();
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println(response.toString());
} else {
System.out.println("Request failed with response code: " + responseCode);
}
connection.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
using System;
using System.Collections.Generic; // Add this line
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args) // Correct Main method signature
{
string url = "https://api.facia.ai/get-client-credentials/";
string email = "email";
string password = "password";
using (HttpClient client = new HttpClient())
{
var payload = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("email", email),
new KeyValuePair<string, string>("password", password)
});
HttpResponseMessage response = await client.PostAsync(url, payload);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine("Request failed with response code: " + response.StatusCode);
}
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
func main() {
url := "/get-client-credentials"
email := "your_email_here"
password := "your_password_here"
formData := url.Values{
"email": {email},
"password": {password},
}
response, err := http.PostForm(url, formData)
if err != nil {
fmt.Println("Error:", err)
return
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println(string(body))
}
Request Parameter
Parameters | Description |
---|---|
Required: Yes Type: String | |
password | Required: Yes Type: String |
Sample Response
{
"status": true,
"message": "credentials",
"result": {
"data": {
"client_id": "your_client_id",
"client_secret": "your_client_secret"
}
}
}