Appearance
Automation
Overview
This guide will walk you through the process of automating client management and issuing records using a series of API calls. By following these steps, you will be able to create a seamless workflow that integrates client creation and record issuance. This is particularly useful for systems such as registration forms on your website, allowing you to streamline these processes efficiently and effectively.
The result is a record that is sent to a client, either automatically via email or with a link that you can provide them with manually. The client can then go through the process of completing the record by uploading their documents and fulfilling any other necessary requirements. This automation not only saves time but also ensures a consistent and reliable process for managing client records.
Objective: Automate the process of managing clients and issuing records.
Step 1: Creating a Client
To begin the automation, create a client. This is usually the first step in automating workflows, allowing subsequent operations to be linked to a specific client. This client entry will only contain basic details such as their full name and email. It will not trigger any records to be sent to the client.
Endpoint: POST /api/v2/clients
Description: Create a new client by providing necessary details like name and email.
Code Example:
php
<?php
class CreateClient
{
public function __construct(private string $apiUrl, private string $accessToken)
{
}
public function createClient(array $clientData): array
{
$url = $this->apiUrl . '/clients';
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $this->accessToken
];
$payload = json_encode($clientData);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception(curl_error($ch));
}
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($statusCode !== 201) {
throw new Exception('Failed to create client, status code: ' . $statusCode);
}
return json_decode($response, true);
}
}
$clientCreator = new CreateClient('https://id.amiqus.co/api/v2', 'your_access_token');
$clientData = [
'name' => [
'title' => 'mr',
'first_name' => 'Martin',
'last_name' => 'McFly'
],
'email' => 'marty@example.com'
];
try {
$client = $clientCreator->createClient($clientData);
echo 'Client created successfully: ' . print_r($client, true);
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
python
import requests
import json
class CreateClient:
def __init__(self, api_url, access_token):
self.api_url = api_url
self.access_token = access_token
def create_client(self, client_data):
url = f"{self.api_url}/clients"
headers = {
'Content-Type': 'application/json',
'Authorization': f"Bearer {self.access_token}"
}
payload = json.dumps(client_data)
response = requests.post(url, headers=headers, data=payload)
if response.status_code != 201:
raise Exception(f"Failed to create client, status code: {response.status_code}")
return response.json()
client_creator = CreateClient('https://id.amiqus.co/api/v2', 'your_access_token')
client_data = {
'name': {
'title': 'mr',
'first_name': 'Martin',
'last_name': 'McFly'
},
'email': 'marty@example.com'
}
try:
client = client_creator.create_client(client_data)
print('Client created successfully:', client)
except Exception as e:
print('Error:', str(e))
javascript
const axios = require('axios');
class CreateClient {
constructor(apiUrl, accessToken) {
this.apiUrl = apiUrl;
this.accessToken = accessToken;
}
async createClient(clientData) {
const url = `${this.apiUrl}/clients`;
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.accessToken}`
};
try {
const response = await axios.post(url, clientData, { headers });
if (response.status !== 201) {
throw new Error(`Failed to create client, status code: ${response.status}`);
}
return response.data;
} catch (error) {
throw new Error(error.message);
}
}
}
const clientCreator = new CreateClient('https://id.amiqus.co/api/v2', 'your_access_token');
const clientData = {
name: {
title: 'mr',
first_name: 'Martin',
last_name: 'McFly'
},
email: 'marty@example.com'
};
clientCreator.createClient(clientData)
.then(client => {
console.log('Client created successfully:', client);
})
.catch(error => {
console.error('Error:', error.message);
});
Step 2: Creating a Record
Once the client is created, choose the steps you'd like the client to complete and create a record to be issued to the client. The below example will issue a record to a client that will ask them to conduct a Photo ID check and a Criminal Record check.
Endpoint: POST /api/v2/records
Description: Create a record to initiate a range of checks for the client.
Code Example:
php
<?php
class CreateRecord
{
public function __construct(private string $apiUrl, private string $accessToken)
{
}
public function createRecord(int $clientId): array
{
$url = $this->apiUrl . '/records';
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $this->accessToken
];
$payload = json_encode([
'client' => $clientId,
'steps' => [
[
'type' => 'check.photo_id',
'preferences' => [
'report_type' => 'biometric'
]
],
[
'type' => 'check.criminal_record',
'preferences' => [
'region' => 'england',
'type' => 'standard'
]
]
],
'notification' => 'email',
'message' => 'Please complete the following request to begin onboarding with Fusion Industries.',
'reminder' => true
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception(curl_error($ch));
}
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($statusCode !== 201) {
throw new Exception('Failed to create record, status code: ' . $statusCode);
}
return json_decode($response, true);
}
}
// Usage
$recordCreator = new CreateRecord('https://id.amiqus.co/api/v2', 'your_access_token');
$clientId = 34853;
try {
$record = $recordCreator->createRecord($clientId);
echo 'Record created successfully: ' . print_r($record, true);
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
python
import requests
import json
class CreateRecord:
def __init__(self, api_url, access_token):
self.api_url = api_url
self.access_token = access_token
def create_record(self, client_id):
url = f"{self.api_url}/records"
headers = {
'Content-Type': 'application/json',
'Authorization': f"Bearer {self.access_token}"
}
payload = json.dumps({
'client': client_id,
'steps': [
{
'type': 'check.photo_id',
'preferences': {
'report_type': 'biometric'
}
},
{
'type': 'check.criminal_record',
'preferences': {
'region': 'england',
'type': 'standard'
}
}
],
'notification': 'email',
'message': 'Please complete the following request to begin onboarding with Fusion Industries.',
'reminder': True
})
response = requests.post(url, headers=headers, data=payload)
if response.status_code != 201:
raise Exception(f"Failed to create record, status code: {response.status_code}")
return response.json()
# Usage
record_creator = CreateRecord('https://id.amiqus.co/api/v2', 'your_access_token')
client_id = 34853
try:
record = record_creator.create_record(client_id)
print('Record created successfully:', record)
except Exception as e:
print('Error:', str(e))
javascript
const axios = require('axios');
class CreateRecord {
constructor(apiUrl, accessToken) {
this.apiUrl = apiUrl;
this.accessToken = accessToken;
}
async createRecord(clientId) {
const url = `${this.apiUrl}/records`;
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.accessToken}`
};
const payload = {
client: clientId,
steps: [
{
type: 'check.photo_id',
preferences: {
report_type: 'biometric'
}
},
{
type: 'check.criminal_record',
preferences: {
region: 'england',
type: 'standard'
}
}
],
notification: 'email',
message: 'Please complete the following request to begin onboarding with Fusion Industries.',
reminder: true
};
try {
const response = await axios.post(url, payload, { headers });
if (response.status !== 201) {
throw new Error(`Failed to create record, status code: ${response.status}`);
}
return response.data;
} catch (error) {
throw new Error(error.message);
}
}
}
// Usage
const recordCreator = new CreateRecord('https://id.amiqus.co/api/v2', 'your_access_token');
const clientId = 34853;
recordCreator.createRecord(clientId)
.then(record => {
console.log('Record created successfully:', record);
})
.catch(error => {
console.error('Error:', error.message);
});