KSA v2: Sign in
Sign in to your Complyance account with your refresh token and get the access token the other KSA ZATCA API v2 requests need. This page documents API v2, a legacy version.
Use this API to sign in to your Complyance account and get an access token for the other Complyance APIs. You need the refresh token you received when you signed up.
Send every required parameter in the format shown below.
Endpoint
http
POST https://<your-v2-api-host>/api/v1/proto/signInUse the v2 API host you were given when your account was set up. If you no longer have it, contact support@complyance.io.
Examples
Sign inbash
curl -X POST https://<your-v2-api-host>/api/v1/proto/signIn \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"refreshToken": "eyJjdHkiOiJKV1QifQ.example-refresh-token.signature"}'Sign injavascript
const inputBody = JSON.stringify({
refreshToken: 'eyJjdHkiOiJKV1QifQ.example-refresh-token.signature'
});
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
};
fetch('https://<your-v2-api-host>/api/v1/proto/signIn', {
method: 'POST',
body: inputBody,
headers: headers
})
.then(function (res) {
return res.json();
})
.then(function (body) {
console.log(body);
});Sign inruby
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
body = {
refreshToken: 'eyJjdHkiOiJKV1QifQ.example-refresh-token.signature'
}.to_json
result = RestClient.post 'https://<your-v2-api-host>/api/v1/proto/signIn', body, headers
p JSON.parse(result)Sign inpython
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
body = {
'refreshToken': 'eyJjdHkiOiJKV1QifQ.example-refresh-token.signature'
}
r = requests.post('https://<your-v2-api-host>/api/v1/proto/signIn', json=body, headers=headers)
print(r.json())Sign inphp
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
'Accept' => 'application/json',
);
$client = new \GuzzleHttp\Client();
// The request body.
$request_body = array(
'refreshToken' => 'eyJjdHkiOiJKV1QifQ.example-refresh-token.signature',
);
try {
$response = $client->request('POST', 'https://<your-v2-api-host>/api/v1/proto/signIn', array(
'headers' => $headers,
'json' => $request_body,
));
print_r($response->getBody()->getContents());
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
// Handle the exception or API errors.
print_r($e->getMessage());
}Sign injava
URL obj = new URL("https://<your-v2-api-host>/api/v1/proto/signIn");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
String body = "{\"refreshToken\": \"eyJjdHkiOiJKV1QifQ.example-refresh-token.signature\"}";
try (OutputStream os = con.getOutputStream()) {
os.write(body.getBytes(StandardCharsets.UTF_8));
}
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());Sign ingo
package main
import (
"bytes"
"net/http"
)
func main() {
jsonReq := []byte(`{"refreshToken": "eyJjdHkiOiJKV1QifQ.example-refresh-token.signature"}`)
req, err := http.NewRequest("POST", "https://<your-v2-api-host>/api/v1/proto/signIn", bytes.NewBuffer(jsonReq))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
// ...
}Request parameters
| Parameter | Required | Type | Description | Example |
|---|---|---|---|---|
refreshToken | Yes | string | The long-lived token you received when you signed up. It is valid for one year from the time it was created. | eyJjdHkiOiJKV1QifQ.example-refresh-token.signature |
Request bodyjson
{
"refreshToken": "eyJjdHkiOiJKV1QifQ.example-refresh-token.signature"
}Response parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
accessToken | string | A temporary token, valid for one day from the time it was created. Send it in the Authorization header to use the other Complyance APIs. | eyJhbGciOiJSUzI1NiJ9.example-access-token.signature |
Responsejson
{
"accessToken": "eyJhbGciOiJSUzI1NiJ9.example-access-token.signature"
}Next step
Generate an API key with the access token.