Create a Collection
Endpointβ
POST https://api.verifik.co/v2/face-recognition/collections
Create a new collection for storing faces generated using Verifik's Life Detection services. Collections are required for the majority of biometric services.
Headersβ
Content-Typeβ
Type: String
Required: Yes
application/json
Authorizationβ
Type: String
Required: Yes
Bearer <token>
Parametersβ
nameβ
Type: String
Required: Yes
Name of the collection.
descriptionβ
Type: String
Required: Yes
Brief description of what the collection will be used for.
Requestβ
- Node.js
- Python
- PHP
- Go
import axios from 'axios';
const options = {
method: 'POST',
url: 'https://api.verifik.co/v2/face-recognition/collections',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your_token>'
},
data: {
name: 'Test Example',
description: 'Example on how to create a collection'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
import http.client
import json
conn = http.client.HTTPSConnection("api.verifik.co")
payload = json.dumps({
"name": "Test Example",
"description": "Example on how to create a collection"
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your_token>'
}
conn.request("POST", "/v2/face-recognition/collections", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.verifik.co/v2/face-recognition/collections');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer <your_token>'
));
$request->setBody('{
"name": "Test Example",
"description": "Example on how to create a collection"
}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.verifik.co/v2/face-recognition/collections"
payload := strings.NewReader(`{
"name": "Test Example",
"description": "Example on how to create a collection"
}`)
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <your_token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
Responseβ
- 200
- 400
{
"data": {
"__v": 0,
"_id": "65175da13e81e4fabc12345",
"code": "dac2c81b-96a6-4f19-ab54-d1a72d55b64b",
"name": "Test Example",
"client": "65175da13e81e4fabc12345",
"deleted": false,
"createdAt": "2023-09-29T23:28:33.894Z",
"updatedAt": "2023-09-29T23:28:33.894Z",
"description": "Example on how to create a collection"
}
}
{
"error": "Invalid request"
}