# OnAPI Service Welcome to our SUNAT Electronic Invoices API portal. In this space, you can perform Tax Intelligence operations such as: - **Generation and management of CPEs** in a controlled SUNAT testing environment; - **OpenAI Artificial Intelligence tools** applied to CPEs; - **Validation and identity verification tools** from RENIEC; - **Support tools for CPEs**, and more. Version: 1.0.3 ## Servers Homologation Environment ``` https://e-hom-onapi.factura-core.com/integrator/api/v1 ``` Production Environment ``` https://e-prod-onapi.factura-core.com/integrator/api/v1 ``` Development Environment ``` https://e-dev-onapi.factura-core.com/integrator/api/v1 ``` ## Security ### bearerAuth Type: http Scheme: bearer Bearer Format: JWT ## Download OpenAPI description [OnAPI Service](https://onapi.redocly.app/_spec/apis/index.yaml) ## Authentication **Credential Generation** The team will generate and provide credentials (username and password). This step will be performed only once. **Token Generation** Using the credentials obtained in the previous step, the user will generate a token through a service provided by the team for this purpose. This token will have a validity period, which is indicated in the service response. Within this period, the token can be used as many times as needed to invoke the services. ### Authentication endpoint - [POST /integrator/authenticate](https://onapi.redocly.app/apis/authentication/authentication.md): Authenticates a user using their credentials and returns an access token along with a refresh token. This endpoint is typically used as the first step in the authentication flow. It verifies the user's credentials (e.g., username and password) and, if valid, issues tokens that can be used to access protected resources. The returned access token should be included in the header of subsequent API requests using the Bearer scheme. - The access token is typically short-lived and used to authorize API requests. - The refresh token is long-lived and can be used to obtain a new access token without re-authenticating. - Credentials should be transmitted over HTTPS to ensure security. - Refresh tokens must be securely stored and never exposed to third parties. - Multiple failed login attempts may result in temporary blocking or rate limiting. ### Refresh Token endpoint - [POST /integrator/refresh-token](https://onapi.redocly.app/apis/authentication/refresh-token.md): Exchanges a valid refresh token for a new access token (and optionally a new refresh token). This endpoint is used to keep the user authenticated without requiring them to log in again. It should be called before the current access token expires. The client must send a valid refresh token, typically received from the login or token exchange endpoint. If the refresh token is valid and not expired or revoked, the response will contain a new access token. Depending on server configuration, a new refresh token may also be issued. - Refresh tokens must be kept secure and should not be shared or exposed. - Reuse of refresh tokens after logout or expiration will result in an error. - Clients should always update their stored refresh token if a new one is provided in the response. ## Logs Retrieves the most recent API request logs processed by the integrator service. This endpoint returns detailed information for each request, including the HTTP method, endpoint path, request headers, body content, and the timestamp when the request was received. The number of logs returned is controlled by the `limit` path parameter. ### Logs endpoint - [GET /integrator/log/{limit}](https://onapi.redocly.app/apis/logs/logs.md): Retrieve Requested logs. ## Integrator Methods for querying and generating SUNAT Electronic Invoices. ### NGR endpoint - [GET /integrator/ngr/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/ngr.md) ### CDR endpoint - [GET /integrator/cdr/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/cdr.md): This method queries the receipt confirmation of processed electronic invoices. ### PDF endpoint - [GET /integrator/pdf/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/pdf.md): This method queries the printed representation (PDF) of processed electronic invoices. ### XML endpoint - [GET /integrator/xml/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/xml.md): This method queries the XML of processed electronic invoices. ### Cancel endpoint - [GET /integrator/cancel/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/cancel.md): This method queries the status of receipts submitted for cancellation. ### SendMessage endpoint - [POST /integrator/sendMessage](https://onapi.redocly.app/apis/integrator/sendmessage.md): This method sends electronic receipts for processing in SUNAT. ### StoreXML endpoint - [POST /integrator/storeXml](https://onapi.redocly.app/apis/integrator/storexml.md): This method stores the trama XML and CDR. ### Retrieve pdf link - [GET /integrator/url/pdf/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/urlpdf.md): This method retrieves the url to download the invoice in pdf format. ### Retrieve xml link - [GET /integrator/url/xml/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/urlxml.md): This method retrieves the url to download the invoice in xml format. ### Retrieve cdr link - [GET /integrator/url/cdr/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/integrator/urlcdr.md): This method retrieves the url to download the invoice cdr in xml format. ## Reniec Tools APIs of the National Registry of Identification and Civil Status (RENIEC) of the Government of Peru. ### Dni endpoint - [GET /integrator/consulta/dni/{dni}](https://onapi.redocly.app/apis/reniec-tools/dni.md): This method queries the DNI of citizens in the RENIEC database. ### Verify fingerprint biometrics identity endpoint - [POST /integrator/reniec/biometrics/fingerprint/identity](https://onapi.redocly.app/apis/reniec-tools/fingerprintidentity.md): Verify fingerprint biometrics identity endpoint. ### Verify fingerprint biometrics quality endpoint - [POST /integrator/reniec/biometrics/fingerprint/quality](https://onapi.redocly.app/apis/reniec-tools/fingerprintquality.md): Verify fingerprint biometrics quality endpoint. ## Tools AI Artificial Intelligence APIs to support Electronic Invoices, such as: - Identity Document Validation (DNI) vs. Selfies - Voice-Based Product Generation for CPE Creation ### Dni detection endpoint - [POST /integrator/tools/ai/dni/detection](https://onapi.redocly.app/apis/tools-ai/dnidetection.md): Data extraction from the photo of the citizen's physical DNI. ### Invoice extraction endpoint - [POST /integrator/tools/ai/invoice/extraction](https://onapi.redocly.app/apis/tools-ai/invoiceextraction.md): Invoice extraction from the image. ### Invoice extraction status endpoint - [GET /integrator/tools/ai/invoice/extraction/status/{jobId}](https://onapi.redocly.app/apis/tools-ai/invoiceextractionstatus.md): Invoice extraction status ### Item from audio endpoint - [POST /integrator/tools/ai/itemsFromAudio](https://onapi.redocly.app/apis/tools-ai/itemsfromaudio.md): Data extraction from the audio generated by the user. ### Extract info endpoint - [POST /integrator/tools/ai/extractInfo](https://onapi.redocly.app/apis/tools-ai/extractinfo.md): Data extraction from the pdf file. ## Tools CPEs APIs related to SUNAT Electronic Invoices. ### Ruc endpoint - [GET /integrator/consulta/ruc/{ruc}](https://onapi.redocly.app/apis/tools-cpes/ruc.md): This method queries the DNI of citizens in the RENIEC database. ### SendCPEwsp endpoint - [POST /integrator/wsp/cpe](https://onapi.redocly.app/apis/tools-cpes/wspcpe.md): This method sends the electronic receipts via WhatsApp. ### GetStsClaveSOL endpoint - [POST /integrator/wsp/getStatusClaveSol](https://onapi.redocly.app/apis/tools-cpes/statusclavesol.md): This method queries the registration status of taxpayers (businesses) in SUNAT. ### sendCPEQRCode endpoint - [POST /integrator/wsp/sendCPEQRCode](https://onapi.redocly.app/apis/tools-cpes/sendcpeqrcode.md): This method queries the registration status of taxpayers (businesses) in SUNAT. ### OnboardingPortal endpoint - [POST /integrator/tools/onboardingPortal](https://onapi.redocly.app/apis/tools-cpes/onboardingportal.md): This method queries the registration status on the web platform. ### Send CPE email endpoint - [POST /integrator/tools/sendCpeEmail](https://onapi.redocly.app/apis/tools-cpes/sendcpeemail.md): This method sends the processed payment receipts by email. ### Create taxes business code endpoint - [POST /integrator/portal/comercio/{code}/impuestos](https://onapi.redocly.app/apis/tools-cpes/createtaxes.md): This method registers taxes associated with the business using its code. ### Create serie business code endpoint - [POST /integrator/portal/comercio/{code}/series](https://onapi.redocly.app/apis/tools-cpes/createserie.md): This method registers the series of the receipt associated with the business using its code. ### Serie Business code endpoint - [GET /integrator/consulta/comercio/{code}/series](https://onapi.redocly.app/apis/tools-cpes/queryserie.md): This method lists the series associated with the business using its code. ### Business code endpoint - [GET /integrator/consulta/comercio/{code}](https://onapi.redocly.app/apis/tools-cpes/querybusiness.md): This method lists the bussiness associated with the business using its code. ### Taxes Business code endpoint - [GET /integrator/consulta/comercio/{code}/impuestos](https://onapi.redocly.app/apis/tools-cpes/querytaxesbusiness.md): This method lists the taxes associated with the business using its code. ## Tools GRE APIs related ### Evidences endpoint - [GET /integrator/tools/gre/evidences/{ruc}/{doctype}/{serie}/{number}](https://onapi.redocly.app/apis/tools-gre/evidencesendpoint.md): This method lists the evidences ### Download evidences endpoint - [GET /integrator/tools/gre/evidences/download/{dispatchAdviceId}/{evidenceId}](https://onapi.redocly.app/apis/tools-gre/downloadevidencesendpoint.md): This method download the evidences ## Products APIs related to products and services. ### Create products endpoint - [POST /integrator/products](https://onapi.redocly.app/apis/products/createproducts.md): This method registers the products associated with the business using its code. ### Update products endpoint - [PUT /integrator/products/{id}](https://onapi.redocly.app/apis/products/updateproducts.md): This method update the products associated with the business using its code. ### Delete products endpoint - [DELETE /integrator/products/{id}](https://onapi.redocly.app/apis/products/deleteproducts.md): This method delete the products associated with the business using its code. ### Get products endpoint - [GET /integrator/products/sync/{ruc}/{date}](https://onapi.redocly.app/apis/products/syncproducts.md): This method get the products associated with the business using its code. ### Find products endpoint - [GET /integrator/products/find](https://onapi.redocly.app/apis/products/findproducts.md): Retrieve a paginated list of products for a given company. Optional filters include description, category, and deleted flag.