Validate a document
POST/v1/validate
Checks the format and check digits of a CPF or CNPJ (including the alphanumeric CNPJ) by calculation only. It queries no database: it does not confirm that the document exists or whose it is.
Request body
- documentstringrequired
- CPF or CNPJ, with or without punctuation.
Free: it uses no credit and does not query any database. Your plan’s rate limit applies.
- With a correct body the answer is always 200, even if the document is invalid: read
valid,format_validandcheck_digit_valid. - Fields of
data:document(without punctuation),type(CPF,CNPJornullwhen the length does not match),format_valid,check_digit_validandvalid. - Without a text
documentfield, the answer is 400 with the codeINVALID_DOCUMENT.
cURL
1curl -X POST https://api.brazid.com/v1/validate \2 -H "x-api-key: $BRAZID_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{"document":"529.982.247-25"}'
1const res = await fetch('https://api.brazid.com/v1/validate', {2 method: 'POST',3 headers: {4 'x-api-key': process.env.BRAZID_API_KEY,5 'Content-Type': 'application/json',6 },7 body: JSON.stringify({8 "document": "529.982.247-25"9 }),10});11 12const data = await res.json();13console.log(res.status, data);
1import os2import requests3 4res = requests.post(5 "https://api.brazid.com/v1/validate",6 headers={"x-api-key": os.environ["BRAZID_API_KEY"]},7 json={8 "document": "529.982.247-25"9 },10)11 12print(res.status_code, res.json())
1$ch = curl_init("https://api.brazid.com/v1/validate");2curl_setopt_array($ch, [3 CURLOPT_RETURNTRANSFER => true,4 CURLOPT_CUSTOMREQUEST => "POST",5 CURLOPT_HTTPHEADER => [6 "x-api-key: " . getenv("BRAZID_API_KEY"),7 "Content-Type: application/json",8 ],9 CURLOPT_POSTFIELDS => '{"document":"529.982.247-25"}',10]);11 12$data = json_decode(curl_exec($ch), true);13$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
200 OK
1{2 "success": true,3 "data": {4 "document": "52998224725",5 "type": "CPF",6 "format_valid": true,7 "check_digit_valid": true,8 "valid": true9 }10}
200 OK · valid: false
1{2 "success": true,3 "data": {4 "document": "52998224724",5 "type": "CPF",6 "format_valid": true,7 "check_digit_valid": false,8 "valid": false9 }10}