Return codes
Requests to the CPF API can return the following HTTP code:
Non-ticketed codes
The following codes will not be ticketed on billing: 400 (Invalid request), 401 (Not authorized), 403 (Forbidden), 500 (Server error) e 504 (Gateway Timeout).
Code / Responses
200 OK
Everything worked as expected and the data was validated successfully.
206 Partial Content
The information was returned, but not completely.
400 Invalid Request
The CPF number entered is not valid.
401 Not Authorized
Problems during authentication.
403 Forbidden
This error occurs when there is a wrong path in the request. Make sure to call the API as follows: "https://gateway.apiserpro.serpro.gov.br/consulta-cpf-df/v1/cpf/{ni}"
404 Not Found
There is no CPF with the registration number informed.
422 LGPD: Dados de Menor de Idade (Minor Data)
Minor data blocked in compliance with the brazilian General Data Protection Law - LGPD. The General Law for the Protection of Personal Data (LGPD), Law Nº 13.709, of August 14, 2018, provides for the processing of personal data, including in digital media, by a natural person or by a public or private legal entity, the objective of protecting the fundamental rights of freedom and privacy and the free development of the personality of the natural person. To protect the fundamental rights of freedom and privacy and the free development of the personality of the natural person, the National Data Protection Authority (ANPD) was created, as established in Decree Nº 10.474, of August 26, 2020.
500 Server Error
An internal server error has occurred.
504 Gateway Timeout
There was a network error and the gateway did not respond in time. The request did not reach the API Consulta CPF.