Skip to content

Classifier

Document classification services.

The service finds the documents inside the file you send, and our AI models classify them.

The classifier only answers which document that is — it does not read anything written inside the document. To also receive the fields written on it, use Full OCR.

Request

POST /classify/v3

Parameters

This endpoint has no query parameters. Unlike other endpoints, an unknown query parameter does not return 422 here: it is simply ignored.

Headers

http
Authorization: ApiKey <your-api-key>

This endpoint also accepts the JWT token, in the format Authorization: Bearer <accessToken>. See JWT Token.

Accepted files

As a parameter, this endpoint expects the file or image to be classified. For more information, see here.

ItemValue
Formatsimage/png, image/jpeg, application/pdf
Files per call1 file
Maximum size (multipart)15 MB

TIP

This endpoint accepts only one file or image at a time.

The form field name is up to you — it comes back in the response, in metadata.filesInfo. If more than one file is sent, the request is rejected with 422.

In a multi-page PDF, each page is analyzed separately, and every document recognized becomes an entry in data.

Besides multipart/form-data, the file can be sent as JSON, in the base64 field, as described in Sending files.

Example request

bash
curl -i -X POST 'https://api-homolog.nxcd.app/classify/v3' \
  --header 'Authorization: ApiKey YOUR_API_KEY' \
  --form 'documento=@./cnh.jpg'

Response

The fields below describe v3. The other versions return a data in a different format — see Versions.

FieldDescriptionTypeNotes
idUnique ID of the requestString
versionAPI versionString
dataList of the analysis resultsObject[]Comes back empty when nothing was recognized
data.classificationObject with the classification detailsObject
data.classification.typeType of the document foundStringSee the list of accepted documents
data.classification.subtypeSubtype of the document foundStringSee the list of accepted documents
data.classification.countryCountry of origin of the document foundStringSee the list of accepted documents
data.classification.sidesList with the side of the document foundObject[]Always contains a single item
data.classification.sides.sideSide of the document that was foundStringEnum: (OnlyFront, OnlyBack, FrontAndBack)
data.classification.sides.pagePage where the document was foundNumberStarts at 0
data.classification.sides.fieldnameName of the field the file was sent inString
data.classification.sides.confidenceConfidence of the classificationNumberValue already filtered internally
metadataMetadata about the request (to support debugging)Object
metadata.filesInfoList with the metadata of the filesObject[]
metadata.filesInfo.fieldnameName of the parameter the file was sent inString
metadata.filesInfo.nameName of the file that was sentString
metadata.filesInfo.sizeSize of the file that was sent, in bytesNumber
metadata.filesInfo.pagesNumber of pages in the fileNumber1 for images
metadata.filesInfo.mimetypeMIME type of the file that was sentString
metadata.filesInfo.encodingEncoding of the file that was sentString
metadata.filesInfo.sha256SHA256 of the file that was sentString
metadata.timeSpentProcessing time of the requestNumberIn milliseconds

TIP

confidence - We already filter internally so that only documents above the expected confidence are returned. We recommend filtering on this field only in specific cases, where the default filter does not meet your needs or where you want to raise the bar on the minimum quality you accept.

TIP

The response is always a list (the data field), because a file/image may contain no identity document, one, or several. To make this data simpler to consume, the list is sorted from the best to the worst result: if you expect a single document, take the first item of the list. If the list is empty, no document could be identified in that image.

JSON examples

Here are some examples of the response in JSON.

  1. Example when an identity document is found in the image
Status Code: 200
json
{
  "id": "5a7bad63-cac6-430c-ac65-a94def0f7b7a",
  "version": "v3",
  "data": [
    {
      "classification": {
        "type": "DriversLicense",
        "subtype": "Printed",
        "country": "BRA",
        "sides": [
          {
            "side": "FrontAndBack",
            "page": 0,
            "fieldname": "documento",
            "confidence": 0.99
          }
        ]
      }
    }
  ],
  "metadata": {
    "filesInfo": [
      {
        "fieldname": "documento",
        "name": "arquivo.JPG",
        "size": 567098,
        "pages": 1,
        "mimetype": "image/jpeg",
        "encoding": "7bit",
        "sha256": "41c2ece339abfcf9ba1e7d5a60666162a24ef34ba95adeb41ed1d9721c91c6b0"
      }
    ],
    "timeSpent": 10000
  }
}
  1. Example when no document is found in the image
Status Code: 200
json
{
  "id": "5a7bad63-cac6-430c-ac65-a94def0f7b7a",
  "version": "v3",
  "data": [],
  "metadata": {
    "filesInfo": [
      {
        "fieldname": "documento",
        "name": "arquivo.JPG",
        "size": 567098,
        "pages": 1,
        "mimetype": "image/jpeg",
        "encoding": "7bit",
        "sha256": "41c2ece339abfcf9ba1e7d5a60666162a24ef34ba95adeb41ed1d9721c91c6b0"
      }
    ],
    "timeSpent": 10000
  }
}

Response headers

HeaderWhen it appears
Nextid-ReqIdOn every response. Carries the request identifier, the same one as the id field in the body.

Errors

CodeWhen it happens
401 UnauthorizedAPI key or JWT token missing, invalid, or without the nextid.classifications.classify permission.
404 Not FoundThe version stated in the URL does not exist. Only v2, v3, v4 and v5 are accepted.
406 Not AcceptableThe body was sent as JSON, but without the base64 field.
413 Payload Too LargeThe file sent as multipart/form-data is larger than 15 MB.
415 Unsupported Media TypeThe Content-Type header is missing or is not supported.
422 Unprocessable EntityThe file format is not accepted, or more than one file was sent in the same call.
500 Internal Server ErrorUnexpected failure during processing.

A document the classifier does not recognize is not an error: the response comes back 200 with an empty data.

The error response format is described in HTTP response codes.

Versions

The version documented on this page is v3, called at /classify/v3. It is the one that uses the same type vocabulary as the list of accepted identity documents below.

‼️ Omitting the version sends the call to v2

POST /classify, with no version in the path, is served by v2, which responds in a different format. Always state the version in the URL.

VersionStatusWhat changes
v3Recommendedclassification with type, subtype, country and sides as a list.
v4Availablesides disappears from classification: what is left is a consolidated side (Front, Back, FrontAndBack) and a sameImage. page, fieldname and confidence move to metadata.filesInfo[].details.
v5AvailableAccepted in the URL. Returns the same response body as v4, with version: "v5".
v2LegacyCarries neither subtype nor country. type uses the old vocabulary (CNH, RG, CPF, OTHERS…) and the side comes in face. This is the version that answers when no version is stated in the URL.

What changes in v2

Each item of data carries page and fieldname at the root, and classification is reduced to three fields:

FieldDescriptionType
data.pagePage where the document was foundNumber
data.fieldnameName of the field the file was sent inString
data.classification.typeCNH, RG, CPF, PROOF-OF-RESIDENCE, SELFIE, IMPRESSOS, CARTAOCREDITO or OTHERSString
data.classification.facefront, back or front-backString
data.classification.confidenceConfidence of the classificationNumber

Every type outside that list — passport, professional council card, foreign document — is returned as OTHERS in v2.

Status Code: 200
json
{
  "id": "5a7bad63-cac6-430c-ac65-a94def0f7b7a",
  "version": "v2",
  "data": [
    {
      "page": 0,
      "fieldname": "documento",
      "classification": {
        "confidence": 0.99,
        "type": "CNH",
        "face": "front-back"
      }
    }
  ],
  "metadata": {
    "filesInfo": [
      {
        "fieldname": "documento",
        "name": "arquivo.JPG",
        "size": 567098,
        "pages": 1,
        "mimetype": "image/jpeg",
        "encoding": "7bit",
        "sha256": "41c2ece339abfcf9ba1e7d5a60666162a24ef34ba95adeb41ed1d9721c91c6b0"
      }
    ],
    "timeSpent": 10000
  }
}

What changes in v4 and v5

classification no longer has the sides list and now carries an already consolidated side, in the Front / Back / FrontAndBack vocabulary. page, fieldname and confidence leave classification and reappear in metadata.filesInfo[].details.

FieldDescriptionType
data.classification.typeType of the document foundString
data.classification.subtypeSubtype of the document foundString
data.classification.countryCountry of origin of the document foundString
data.classification.sideConsolidated side: Front, Back or FrontAndBackString
data.classification.sameImagetrue when front and back came from the same page of the same fileBoolean
metadata.filesInfo[].detailsOne entry per side recognized in that fileObject[]
metadata.filesInfo[].details[].sideSide recognized: Front, Back or FrontAndBackString
metadata.filesInfo[].details[].pagePage where it was recognized. Starts at 0.Number
metadata.filesInfo[].details[].confidenceConfidence of the classification of that sideNumber

🚧 In v4 and v5 the list does not come sorted by confidence

confidence leaves classification before the sorting step, so sorting by confidence does not happen in these versions: when more than one document is recognized in the same file, data comes in the order the documents were processed, not from the best to the worst. If you depend on that order, use v3.

Status Code: 200
json
{
  "id": "5a7bad63-cac6-430c-ac65-a94def0f7b7a",
  "version": "v4",
  "data": [
    {
      "classification": {
        "country": "BRA",
        "type": "DriversLicense",
        "subtype": "Printed",
        "side": "FrontAndBack",
        "sameImage": true
      }
    }
  ],
  "metadata": {
    "filesInfo": [
      {
        "fieldname": "documento",
        "name": "arquivo.JPG",
        "size": 567098,
        "pages": 1,
        "mimetype": "image/jpeg",
        "encoding": "7bit",
        "sha256": "41c2ece339abfcf9ba1e7d5a60666162a24ef34ba95adeb41ed1d9721c91c6b0",
        "details": [
          {
            "side": "FrontAndBack",
            "confidence": 0.99,
            "page": 0
          }
        ]
      }
    ],
    "timeSpent": 10000
  }
}

Identity types and subtypes

List of the types, subtypes and sides of every identity document recognized by our classifier. Note that the list below follows this order: country of origin, type, subtype and side.

E.g.:

  • Country
    • Type
      • Subtype
        • Side

Full list

ARG
DriversLicense
  • empty
    • OnlyFront
FederalID
  • empty
    • OnlyBack
    • OnlyFront

BHR
FederalID
  • empty
    • OnlyBack
    • OnlyFront

BRA
FederalCouncil
  • Accounting_Paper
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Accounting_Plastic
    • OnlyBack
    • OnlyFront
  • Administration_v1
    • OnlyBack
    • OnlyFront
  • Administration_v2
    • OnlyBack
    • OnlyFront
  • ArchitectureAndUrbanism
    • OnlyFront
  • Biology
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Biomedicine
    • OnlyBack
    • OnlyFront
  • Chemistry
    • OnlyBack
    • OnlyFront
  • Dentistry
    • OnlyBack
    • OnlyFront
  • EngineeringAndAgronomy_Paper
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • EngineeringAndAgronomy_Plastic
    • OnlyBack
    • OnlyFront
  • Fishery
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Lawyers
    • OnlyBack
    • OnlyFront
  • Medicine_Paper
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Medicine_Plastic
    • OnlyBack
    • OnlyFront
  • Musician
    • OnlyBack
    • OnlyFront
  • Nursing_v1
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Nursing_v2
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Nutrition
    • OnlyBack
    • OnlyFront
  • Pharmacy_Paper
    • OnlyBack
    • OnlyFront
  • Pharmacy_Plastic
    • OnlyBack
    • OnlyFront
  • PhysicalEducation
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Psychology
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Radiology
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • SalesRepresentatives
    • OnlyFront
  • SocialService
    • OnlyBack
    • OnlyFront
  • Veterinary
    • OnlyBack
    • OnlyFront
DriversLicense
  • BoatAndVessel
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Digital
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Printed
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Resolution2021Digital
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Resolution2021Paper
    • OnlyBack
    • OnlyFront
    • FrontAndBack
FederalID
  • Decree2018Digital
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Decree2018Paper
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Decree2018Plastic
    • OnlyBack
    • OnlyFront
  • Decree2022Paper
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • MainModel
    • OnlyBack
    • OnlyFront
    • FrontAndBack
FederalRevenueService
  • CIC
    • OnlyFront
  • Plastic
    • OnlyFront
  • Printed
    • OnlyFront
  • Temporary
    • OnlyFront
FirefighterID
  • RioDeJaneiro
    • OnlyBack
    • OnlyFront
ForeignID
  • empty
    • OnlyBack
    • OnlyFront
MigratoryRegister
  • empty
    • OnlyBack
    • OnlyFront
RefugeRequest
  • empty
    • OnlyBack
    • OnlyFront
    • FrontAndBack
MilitaryID
  • Airforce
    • OnlyBack
    • OnlyFront
  • Army_Paper
    • OnlyBack
    • OnlyFront
  • Army_Temporary
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • MilitaryDischarge
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Navy_Paper
    • OnlyBack
    • FrontAndBack
  • Navy_Plastic
    • OnlyBack
    • OnlyFront
Passport
  • empty
    • OnlyFront
PoliceID
  • Alagoas
    • OnlyFront
  • Amazonas
    • OnlyFront
  • Bahia
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • Ceara
    • OnlyFront
  • DistritoFederal
    • OnlyBack
    • OnlyFront
  • EspiritoSanto
    • OnlyFront
  • MatoGrosso
    • OnlyBack
    • OnlyFront
  • MatoGrossoDoSul
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • MinasGerais_Paper
    • OnlyBack
    • OnlyFront
  • MinasGerais_Plastic
    • OnlyFront
  • Para
    • OnlyBack
    • OnlyFront
  • Paraiba
    • OnlyBack
    • OnlyFront
  • Pernambuco
    • OnlyBack
    • OnlyFront
  • Piaui
    • OnlyFront
  • RioDeJaneiro
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • RioGrandeDoNorte
    • OnlyFront
  • SaoPaulo
    • OnlyBack
    • OnlyFront
    • FrontAndBack
ProofOfResidence
  • Celesc
    • OnlyFront
  • Cemig
    • OnlyFront
  • Claro
    • OnlyFront
  • CoelbaCelpe
    • OnlyFront
  • Copel
    • OnlyFront
  • Cpfl
    • OnlyFront
  • Edp
    • OnlyFront
  • Enel
    • OnlyFront
  • Energisa
    • OnlyFront
  • Equatorial
    • OnlyFront
  • Light
    • OnlyFront
  • Rge
    • OnlyFront
  • Sabesp
    • OnlyFront
  • Saneago
    • OnlyFront
  • Tim
    • OnlyFront
  • Vivo
    • OnlyFront
Transportation
  • ANTT
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • CRLV_Digital
    • OnlyBack
    • OnlyFront
    • FrontAndBack
  • CRLV_Printed
    • OnlyBack
    • OnlyFront
    • FrontAndBack
VoterID
  • empty
    • OnlyBack
    • OnlyFront
WorkAndSocialSecurityRegistry
  • Handwritten
    • OnlyBack
    • OnlyFront
  • Printed
    • OnlyBack
    • OnlyFront

COL
DriversLicense
  • empty
    • OnlyFront
FederalID
  • empty
    • OnlyBack
    • OnlyFront
Passport
  • empty
    • OnlyFront

ESP
FederalID
  • empty
    • OnlyBack
    • OnlyFront

ITA
FederalID
  • empty
    • OnlyBack
    • OnlyFront

MAR
DriversLicense
  • empty
    • OnlyBack
    • OnlyFront

MEX
VoterID
  • empty
    • OnlyFront

PAK
FederalID
  • empty
    • OnlyFront
    • OnlyBack

PER
FederalID_Paper
  • empty
    • OnlyFront
FederalID_Plastic
  • empty
    • OnlyFront
Passport
  • empty
    • OnlyFront

PRT
FederalID
  • empty
    • OnlyFront
    • OnlyBack
Passport
  • empty
    • OnlyFront

PRY
FederalID
  • empty
    • OnlyFront

URY
FederalID
  • empty
    • OnlyFront

USA
DriversLicense
  • Florida
    • OnlyFront
  • Georgia
    • OnlyFront
Passport
  • empty
    • OnlyFront
SocialSecurityID
  • empty
    • OnlyFront

VEN
FederalID
  • empty
    • OnlyFront
Passport
  • empty
    • OnlyFront

Nextcode | Identity Verification Solutions