The Spanish version is the authoritative reference. View in Spanish
π΅πͺ Peru
This sheet assumes you know the xPOS-Core communication protocol. Here we only document what is specific to Peru.
Peru joins the xPOS family in xPOS-Core 2.7.0, with the same principles of the platform: the sale never stops, and operation with several issuers on the same device is available from day one.
Summaryβ
| Aspect | Value |
|---|---|
country code | pe |
| Tax authority | SUNAT / OSE |
| Pattern | A β XML with XSD |
Supported inputType | json, xml |
| Extra endpoint | β |
| Output | Signed tax XML (UBL 2.1) |
Peru's particularities are documented in the following sections: two submission paths (with a synchronous verdict on both), input formats (txt and xdoc not available) and particular notes (cancellations do not apply).
π Two submission paths: direct SUNAT or OSEβ
Peru supports two destinations for the same document, depending on how the issuer is configured:
- Direct SUNAT: submission of the voucher to the authority's services.
- OSE (Electronic Services Operator): submission through the OSE, for companies operating under that modality.
Both paths speak the same protocol and return the Receipt Confirmation (CDR) in the same call: the difference between the two lanes is the destination and the credentials, not the integration model. From the POS point of view the contract is identical.
The destination is defined in the Gosocket administration portal, in the issuer's configuration, per document type: each typeDoc can be routed to SUNAT or to the OSE. With no rule defined for a type, the destination is SUNAT. xPOS receives these rules with the onboarding data: it is not a parameter that travels in each call.
Document types (typeDoc)β
The WebSocket example uses
typeDoc=1(electronic invoice).
typeDoc | Document |
|---|---|
| 1 | Electronic Invoice |
| 3 | Electronic Sales Receipt (Boleta de Venta) |
| 5 | Air Transport Ticket |
| 7 | Electronic Credit Note |
| 8 | Electronic Debit Note |
| 9 | Sender's Dispatch Guide (GuΓa de RemisiΓ³n Remitente) |
| 14 | Electronic Public Services |
| 25 | Attribution document |
| 30 / 42 | DAE Acquirer |
| 31 | Carrier's Dispatch Guide (GuΓa de RemisiΓ³n Transportista) |
| 34 | DAE Operator |
| 56 | SEAE payment voucher |
All types share the same transformation path; what changes per type is the UBL validation schema (Invoice / CreditNote / DebitNote / DespatchAdvice) and the SUNAT service it is sent to (guides 9 and 31 go to the Dispatch Guide service).
The RA (Voiding Communication) and RC (Daily Summary) events are not issued from the POS: xPOS itself builds and sends them. The Daily Summary is documented below.
Input formats (inputType)β
inputType | Supported | Detail |
|---|---|---|
json | β | Full transformation path (root β generic DTE β fiscal UBL). |
xml | β | The POS sends xPOS's generic DTE, not SUNAT's UBL: the first transformations are skipped and only the conversion to fiscal UBL runs. |
txt | β | Not available in Peru. Use json or xml. |
xdoc | β | Not available in Peru. Use json or xml. |
XSLT mappingβ
Peru's sheets are distributed compiled (.sef format β xPOS does not compile templates in the store) and arrive from the portal with the issuer's configuration:
| Sheet | Use |
|---|---|
input_to_dte_pe.sef | json input β generic DTE. With inputType=xml this step is skipped. |
dte_to_fiscal_pe.sef | Generic DTE β SUNAT fiscal UBL. Always runs. |
create_response_pe.sef | Custom response in GET /api/v1/status, when the issuer's output mode is Personalizada. |
summary_documents_pe | Builds the Daily Summary from the day's signed UBLs. It ships packaged inside the product, not through the configuration channel: changing the summary's shape requires an xPOS update. |
Numbering: the series and correlative travel in the documentβ
In Peru the voucher's identity is its series-correlative (F001-00000001), which travels inside the document (the UBL's cbc:ID). xPOS extracts it from the signed document and returns it in series, number, docNumber and countryIdentificationCode.
Peru-specific response fieldsβ
Peru returns the core + partial tax echo (statusCode and statusMessage, without statusDescription) + applicationResponse + timeGeneration + series.
| Field | Status | Notes |
|---|---|---|
statusCode / statusMessage | β | Read from the SUNAT/OSE CDR. statusCode: "0" = voucher accepted. |
statusDescription | β | Not emitted in Peru. |
applicationResponse | β | The CDR in base64. In contingency it does not come (the authority has not responded yet). |
countryIdentificationCode | β | The voucher's series-correlative (F001-00000001), equal to docNumber. Peru has no additional authority-assigned identifier. |
series | β | The voucher's series (F001). Peru-specific field. |
timeGeneration | β | ISO 8601. In contingency, the voucher's issuance date/time. |
timeValidation | β | Not emitted in Peru. |
barcodeText / barcodeBase64 | β | Not returned in Peru: barcodeText does not come in the response and barcodeBase64 arrives as the literal string "null" (it does not contain a code). |
contingencyCode | β | Only when the document went to contingency: 1 = automatic, 2 = manual. |
custom_response | β | Arrives as the string "null": Peru's Custom output operates in GET /api/v1/status, not on issuance. |
partnerNumber | β | Always null in Peru. |
WebSocket exampleβ
Illustrative values. The structure is real; the data are examples (fictitious RUC, series and UUIDs).
{
"env": "sbx",
"operation": "consolidate",
"typeDoc": 1,
"country": "pe",
"inputType": "json",
"origin": "20123456789",
"document": { /* Peru voucher */ }
}Notes about the response:
outputandsignedXmlare the same value: the signed UBL in base64.- On success,
statusCode: "0"is the acceptance verdict read from the CDR. - In contingency,
messagebecomes"Operation Successful en contingencia",applicationResponsedoes not come, andcontingencyCodeis added.
π Contingencyβ
If SUNAT or the OSE is unavailable, the voucher is generated, signed and stored locally, and the POS receives its response without waiting for the authority β the sale never blocks.
The later regularization operates through the Daily Summary: sales receipts (boletas) issued in contingency are declared to SUNAT in the summary corresponding to their issuance date.
π Daily Summary of receipts (boletas)β
SUNAT receives sales receipts (boletas) grouped in a Daily Summary (RC-YYYYMMDD-NNNNN), with its own asynchronous cycle: the summary is sent, the authority returns a ticket, and with that ticket xPOS later queries the confirmation (CDR).
xPOS builds and sends the summaries automatically, with no POS or store intervention:
- One summary covers a single issuance date. Receipts issued in contingency are declared in the summary of their issuance date: a store that spent three days in contingency generates three summaries, sent in successive cycles.
- The identifier's correlative is daily and per company: on multi-company devices, each issuer keeps its own summary series, with no crossings.
- A voucher already declared in a previous summary is not declared again.
- The outcome (CDR of acceptance or rejection of the summary) is visible in the dashboard, in the TA Response view, with the summary identifier as document number, and the status is synchronized with the Gosocket portal.
Authority errors, readableβ
SUNAT's and the OSE's services respond in SOAP: a failure on the authority's side does not arrive as an HTTP error but as a SOAP Fault inside a technically successful response. xPOS extracts the fault's code and description, so that:
- A voucher rejected by the authority is not marked as successfully sent.
- The rejection reason reaches the POS (
error_description), the dashboard and the portal in readable form.
The stage catalog and the frequent SUNAT/OSE codes are in Error codes Β· Peru.
Particular notesβ
- Publishes in Inbox-Gosocket (or through the System Integrator channel when the organization has it enabled).
- Re-retrieval via
GET /api/v1/statuswithtransactionIdor withdocNumber + typeDoc. For Peru,docNumberis the series-correlative with a hyphen (F001-00000001). With more than one issuer installed, the folio query also requiresorigin. - The issuer is validated against
origin: if the RUC of the issuer inside the document does not match the request'sorigin, the issuance fails atVALIDATE_ISSUER_STAGE. - Voiding:
POST /api/v1/cancelation-eventdoes not apply to Peru. The voiding of a Peruvian voucher is declared to SUNAT through a Voiding Communication, which travels through the same asynchronous ticket cycle as the Daily Summary and is built by the platform itself β its enablement is in preparation; today there is no parameter with which the POS can request a voiding. Coordinate voiding cases with your Gosocket contact. - Peru's custom client data node is
DocPersonalizado, and it is preserved inside the signed document.