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
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Params
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the collection |
description | string | No | Optional description |
Request
- Node.js
- PHP
- Python
- Go
const fetch = require("node-fetch");
async function run() {
const res = await fetch("https://api.verifik.co/v2/face-recognition/collections", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_TOKEN}`,
},
body: JSON.stringify({
name: "Test Example",
description: "Example on how to create a collection",
}),
});
console.log(await res.json());
}
run();
<?php
$ch = curl_init("https://api.verifik.co/v2/face-recognition/collections");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_TOKEN")
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"name" => "Test Example",
"description" => "Example on how to create a collection"
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os, requests
url = "https://api.verifik.co/v2/face-recognition/collections"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_TOKEN')}"
}
payload = {
"name": "Test Example",
"description": "Example on how to create a collection"
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload, _ := json.Marshal(map[string]string{
"name": "Test Example",
"description": "Example on how to create a collection",
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/face-recognition/collections", bytes.NewReader(payload))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_TOKEN"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
Response
- 200
- 401/403
- 409
- 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"
}
}
{
"message": "Access forbidden",
"code": "Forbidden"
}
{
"message": "Validation message from server",
"code": "MissingParameter"
}
{
"error": "Invalid request"
}
Notes
- Authentication: Send a valid bearer token; the new collection is associated with your client.
- Name:
nameis required;descriptionis optional but recommended for organization. - Errors:
409/MissingParametertypically indicates missing or invalid body fields per API validation.