API reference

Everything you need to ship face recognition.

A REST API with multipart uploads in and JSON out. Enroll people, identify a face, compare two photos. Most teams send their first verify in minutes.

Base URLhttps://tareef.g4t.io/api/v1
AuthBearer token
Content typemultipart/form-data

Overview

The API is REST-based. Image uploads go in as multipart form bodies, responses come back as JSON, and results use standard HTTP status codes. HTTPS is required in production.

Every response also carries a stable status string. Branch on that, not on the HTTP code alone.

Your first call
curl -X POST https://tareef.g4t.io/api/v1/verify \
  -H "Authorization: Bearer frs_live_XXXXXX" \
  -F "file=@photo.jpg"

Quickstart

01 Create an API key Sign up for a free account and create a key in your dashboard.
02 Enroll people Add one or more people, each with reference photos.
03 Verify a photo Send a new photo and get the best match from your library.

Laravel SDK

tareef/laravel wraps every endpoint in a facade, with typed exceptions and streamed uploads. It needs PHP 8.2+ and Laravel 10, 11, 12 or 13.

Optional config

  • TAREEF_BASE_URL defaults to the hosted API
  • TAREEF_TIMEOUT and TAREEF_RETRIES
  • TAREEF_THROW_ON_QUOTA set to false to suppress the quota exception

Image inputs

Pass an UploadedFile, an SplFileInfo or an absolute path. Uploads are streamed, never buffered in memory.

Exceptions

ExceptionThrown when
FaceAlreadyExistsExceptionThe face is already enrolled on this account
NoFaceDetectedExceptionNo detectable face in the image
QuotaExceededExceptionThe monthly verify quota is reached
AuthenticationExceptionThe key is bad or revoked
ServiceUnavailableExceptionThe service is down or unreachable

All of them extend TareefException.

Install
composer require tareef/laravel

# then in .env
TAREEF_API_KEY=frs_live_XXXXXX
Enroll and identify
use Tareef\Laravel\Facades\Tareef;
use Tareef\Laravel\Exceptions\{NoFaceDetectedException, QuotaExceededException};

// Enroll someone from an uploaded file
$person = Tareef::register(
  name: 'Jane Doe',
  images: [$request->file('photo')],
  phone: '+15555555555',
);

// Identify a face
try {
  $result = Tareef::verify($request->file('selfie'));

  if ($result->matched) {
    return ['uuid' => $result->person->uuid, 'score' => $result->score];
  }
} catch (NoFaceDetectedException) {
  abort(422, 'No face in the photo.');
} catch (QuotaExceededException) {
  abort(429, 'Monthly verify quota hit.');
}

Node.js SDK

@g4t/tareef is a zero-dependency typed wrapper for Node 18+. It ships ESM and TypeScript types.

Configuration

baseUrl defaults to the hosted instance. Override it with the option or with TAREEF_BASE_URL.

Image inputs

Pass a file path, a Buffer or Uint8Array, a Blob or File, or { data, filename }. Uploads are sent as multipart.

Errors

  • FaceAlreadyExistsError carries the existing .uuid
  • NoFaceDetectedError
  • QuotaExceededError
  • AuthenticationError
  • ServiceUnavailableError

All of them subclass TareefError.

Install
npm install @g4t/tareef

# then set your key in the environment
export TAREEF_API_KEY=frs_live_XXXXXX
Enroll and identify
import { TareefClient, NoFaceDetectedError } from '@g4t/tareef';

const tareef = new TareefClient({ apiKey: 'frs_live_XXXXXX' });

// Enroll a person from local files
const person = await tareef.register({
  name: 'Jane Doe',
  images: ['./jane.jpg'],
});

// Identify a face
try {
  const r = await tareef.verify('./selfie.jpg');
  if (r.success) console.log(r.name, r.score);
} catch (e) {
  if (e instanceof NoFaceDetectedError) console.log('No face in the photo.');
}

Authentication

Send an Authorization: Bearer <key> header on every authenticated request. Legacy clients can use an x-api-key header instead.

  • Keys come from your dashboard and are bound to one account.
  • A key is frs_live_ followed by at least 32 random characters.
  • Revoking a key disables it immediately.
  • Missing or invalid credentials return 401 unauthorized with no further detail.
Header
Authorization: Bearer frs_live_XXXXXX
A key is shown only once, when you create it. Store it somewhere safe and revoke any key you no longer use.

Enroll a person

POST/api/v1/people

Creates a person in your library from one or more reference photos.

Body parameters

NameTypeDescription
name
required
stringDisplay name.
phone
optional
stringFree-form identifier: a phone, an email or an employee ID.
file
file or files[]
fileA single image (jpg, png, webp), 8 MB at most.
files[]
file or files[]
file[]Several images. Repeat the key once per file. More samples improve later accuracy.
Request
curl -X POST https://tareef.g4t.io/api/v1/people \
  -H "Authorization: Bearer frs_live_XXXXXX" \
  -F "name=Jane Doe" \
  -F "phone=+15555555555" \
  -F "file=@photo.jpg"

Responses

  • 200Returns success: true with the new uuid and images_registered.
  • 422 face_existsThe face is already enrolled. The existing UUID comes back.
  • 422 no_faceNo detectable face in any image you sent.
  • 422 spoof_detectedWith liveness on, every photo looks like a screen or a print, so nothing is enrolled. If only some fail, the rest are enrolled and images_rejected_spoof counts the discarded ones.

Add reference photos

POST/api/v1/people/{uuid}/images

Attaches more photos to a person you already enrolled. The body is the same as enrollment without name and phone. Each extra sample improves accuracy.

Path parameters

NameDescription
uuid
required
The person UUID returned by enrollment.
Request
curl -X POST https://tareef.g4t.io/api/v1/people/UUID/images \
  -H "Authorization: Bearer frs_live_XXXXXX" \
  -F "files=@a.jpg" -F "files=@b.jpg"

Identify a face

billable
POST/api/v1/verify

Searches every photo of every person in your library and returns the best match. Pass person_uuid to score the photo against one person only. Each call counts against your monthly quota.

Body parameters

NameTypeDescription
file
required
fileThe query image. One embedding is extracted and the best match returned.
person_uuid
optional
stringChecks one known person ("is this them?") in place of a library search. Also accepted as user_id.

Reading the score

The response includes a cosine score. Lower means closer.

ScoreMeaning
≤ 0.30Very confident match
≤ 0.38Accepted match
≤ 0.55Uncertain
> 0.55Different person
1:N · who is this?
curl -X POST https://tareef.g4t.io/api/v1/verify \
  -H "Authorization: Bearer frs_live_XXXXXX" \
  -F "file=@photo.jpg"
1:1 · is this that person?
curl -X POST https://tareef.g4t.io/api/v1/verify \
  -H "Authorization: Bearer frs_live_XXXXXX" \
  -F "file=@photo.jpg" \
  -F "person_uuid=PERSON_UUID"
Laravel
use Tareef\Laravel\Facades\Tareef;

$result = Tareef::verify($request->file('selfie'));

if ($result->matched) {
  return [
    'uuid' => $result->person->uuid,
    'name' => $result->person->name,
    'score' => $result->score,
  ];
}

Responses

  • 200A match. Returns uuid, name, score and samples.
  • 200 not_foundBelow the threshold, or not in your library.
  • 200 not_identicalWith person_uuid: a face was read, but it isn't that person.
  • 200 no_imagesWith person_uuid: that person has no enrolled photos yet.
  • 200 no_faceNo detectable face in the query image.
  • 200 spoof_detectedLiveness is on and the photo looks like a screen or a print. Nothing is matched.
  • 404 person_not_foundNo person with that person_uuid in this application.
  • 429 quota_exceededThe monthly limit is reached.

Liveness check

Turn it on in your application settings to reject spoofed faces: a photo shown on another screen, or a print. It also applies to enrollment photos.

The query image is checked before any search runs. Every response then includes liveness: { checked, is_real, score, reason }.

  • Refusal reasons are spoof, low_confidence and face_too_close.
  • On face_too_close, ask the user to move back until head and shoulders are in frame.
  • Send the original camera frame. Screenshots, heavy compression and tight crops make real selfies harder to tell from spoofs.

Compare two faces

billable
POST/api/v1/compare

Measures how similar two images are, with no enrollment and no library lookup. A good fit for KYC, such as matching a selfie to an ID photo.

Body parameters

NameDescription
file1
required
First image. With liveness on, this must be the live capture.
file2
required
Second image, the reference.

distance is cosine distance, lower is closer. similarity is 1 − distance. match applies the strictness configured for your application.

Request
curl -X POST https://tareef.g4t.io/api/v1/compare \
  -H "Authorization: Bearer frs_live_XXXXXX" \
  -F "file1=@selfie.jpg" \
  -F "file2=@id-photo.jpg"
200 OK
{
  "success": true,
  "match": true,
  "distance": 0.21,
  "similarity": 0.79,
  "threshold": 0.38
}

Responses

  • 200match is true or false, with distance and similarity.
  • 200 no_faceNo face in one or both images. no_face_in says which.
  • 200 spoof_detectedLiveness is on and file1 isn't a live capture. Only file1 is checked.

List people

GET/api/v1/people

Lists the people you have enrolled, newest first.

Query parameters

NameTypeDefaultDescription
limit
optional
integer100Maximum rows returned.
Request
curl https://tareef.g4t.io/api/v1/people \
  -H "Authorization: Bearer frs_live_XXXXXX"

Read and delete a person

GET/api/v1/people/{uuid}

Returns the person record and the paths of its reference images.

DELETE/api/v1/people/{uuid}

Permanently removes the person's embeddings and stored photos.

Deleting cannot be undone.
Read
curl https://tareef.g4t.io/api/v1/people/UUID \
  -H "Authorization: Bearer frs_live_XXXXXX"
Delete
curl -X DELETE https://tareef.g4t.io/api/v1/people/UUID \
  -H "Authorization: Bearer frs_live_XXXXXX"

Rate limits and quotas

  • Only verifications count against the monthly quota: identify and compare.
  • Enrollment, reads and deletes are free.
  • Quotas reset at 00:00 UTC on the 1st of each calendar month.
  • Going over returns 429 quota_exceeded, with used and limit in the body.
PlanPriceVerificationsPeople
Free Free 100 / mo 50
Pro 39,000 IQD/mo 10,000 / mo 5,000
Business 129,000 IQD/mo 100,000 / mo Unlimited

Error codes

Every response includes a stable status string. Branch on it, not on the HTTP code alone.

StatusHTTPMeaning
ok200Success.
not_found200 / 404No matching person, or the UUID isn't in your library.
no_face200No face detected in the image.
spoof_detected200 / 422Liveness is on and the face is a photo of a screen or a print.
liveness_unavailable200 / 422Liveness is on but couldn't run. Nothing was matched or enrolled.
face_exists422The face is already enrolled. The existing UUID is returned.
invalid422Malformed request body or missing required fields.
unauthorized401Missing or revoked API key.
quota_exceeded429Plan limit reached for the calendar month.
upstream_error502The face recognition service was unreachable.
Ready to send your first verify? The Free plan includes 100 verifications a month. No credit card.
Get an API key