Skip to content

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_valid and check_digit_valid.
  • Fields of data: document (without punctuation), type (CPF, CNPJ or null when the length does not match), format_valid, check_digit_valid and valid.
  • Without a text document field, the answer is 400 with the code INVALID_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"}'

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}