sale-cancellation

Sale Cancellation API — White Label — REST facade for requesting and tracking sale cancellations (reversals) in the Getnet White Label ecosystem, backed by the legacy SOAP service RequestCancelService.

Overview

sale-cancellation is the cancellation API of the White Label platform. It allows a partner application to request the cancellation (total or partial) of an original sale and to track the outcome through a 17-digit protocol.
Internally the service translates each REST call into the legacy SOAP service RequestCancelService, converting business codes returned by the backend into standard HTTP semantics.
  • Base path: /sale-cancellation/v1/cancellations
  • Auth standard: OAuth2 Bearer (JWT) validated at the API Gateway / Ingress
  • Version: 1.0.0
  • Response format: JSON (snake_case)
  • Contact: Getnet MPS White Label — mps-whitelabel@getnet.com.br

Architecture

text
API Consumer (Partner Application) │ │ 600;">POST /v1/cancellations (Bearer token + sale data) ▼ ┌─────────────────────────────────────────┐ │ Getnet Sale Cancellation API (WLB) │ │ │ │ Validate payload → map REST to SOAP │ │ protocol (17 digits, HTTP 202) │ └─────────────────────────────────────────┘ │ │ requestCancelTransation / queryCancelTransation (SOAP) ▼ RequestCancelService (Legacy Backend) business code → HTTP status (De/Para) Note: "Transation" is misspelled on purpose — it mirrors the legacy SOAP operation name defined in the WSDL and cannot be changed.

Key Design Decisions

ConcernSolution
StyleRESTful resource cancellations, versioned in the path (/v1)
AuthenticationNot enforced by the service; Bearer JWT validated by the Gateway/Ingress
Asynchronous naturePOST returns 202 Accepted with a tracking protocol
IdempotencyPOST is not idempotent (repeated calls may create different protocols); GET is safe and idempotent
Status semanticsLegacy SOAP business codes translated to HTTP status (De/Para mapping)
Error contractStandard envelope with code, message, details, trace_id
TraceabilityX-Correlation-Id echoed (or generated as UUID v4) and mirrored in X-Request-Id
ProtectionIP-based rate limiting (token bucket): 50 requests / 60 s → HTTP 429
CurrencyOnly 986 (BRL) is supported; defaults to 986 when omitted

Environments

EnvironmentBase URLDescription
Localhttp://localhost:8080/sale-cancellationLocal development
Developmenthttps://sales-data-ms-wlb-api-des.apps.ocp-dev.getnet.com.br/sale-cancellationDevelopment environment (DES)
Staginghttps://sales-data-ms-wlb-api-hti.apps.ocp-hml.getnet.com.br/sale-cancellationTesting/homologation (HML)
  • API Reference (OpenAPI JSON): {base-url}/v3/api-docs
  • Swagger UI: {base-url}/swagger-ui/index.html

API Endpoints

MethodPathOperationDescription
POST/v1/cancellationscancelRequests a sale cancellation
GET/v1/cancellations?branch=&client_key=queryByBranchAndClientKeyQueries cancellations by branch and client key
GET/v1/cancellations/{protocol}queryByProtocolQueries a cancellation by protocol

Request a Cancellation — POST /v1/cancellations

Requests the cancellation of an original sale. Returns the tracking protocol when accepted.
AttributeValue
MethodPOST
Operationcancel
CategoryCancellation
Content-Typeapplication/json
Success202 Accepted
Pre-conditions: the original transaction must exist and must not have been cancelled before.
Request parameters (body — JSON):
FieldTypeRequiredDescription
branchStringYesMerchant branch code. Numeric, up to 15 digits.
terminalStringYesPOS terminal identifier. Alphanumeric, up to 8 characters.
authorizationStringYesAuthorization code of the original transaction. Numeric, up to 6 digits.
dateStringYesOriginal transaction date (yyyy-MM-dd). Cannot be in the future.
modalityStringYesV = Cash (Vista), P = Installment (Parcelado).
amountNumberYesOriginal transaction amount in BRL. Must be greater than zero.
currency_codeStringNoISO 4217 code. Defaults to 986 (BRL); any other value is rejected.
inst_numIntegerYesNumber of installments. Use 1 for cash transactions.
nsuStringYesNSU of the original transaction. Numeric, up to 9 digits.
cancel_amountNumberYesAmount to cancel in BRL. Total or partial.
client_keyStringNoUnique client key. Alphanumeric, up to 32 characters.
Responses: 202 Accepted · 400 · 401 · 403 · 404 · 409 · 422 · 429 · 500 · 502 · 503 · 504
Response body (202):
json
{ "code": "00", "message": "SOLICITACAO RECEBIDA COM SUCESSO", "protocol": "20260603000123456" }

Query by Branch and Client Key — GET /v1/cancellations

ParameterInRequiredDescription
branchqueryYesMerchant branch code. Numeric, up to 15 digits.
client_keyqueryYesClient key. Alphanumeric, up to 32 characters.
X-Correlation-IdheaderNoCorrelation identifier; echoed or generated by the server.

Query by Protocol — GET /v1/cancellations/{protocol}

ParameterInRequiredDescription
protocolpathYesCancellation protocol number. Numeric, exactly 17 digits.
X-Correlation-IdheaderNoCorrelation identifier; echoed or generated by the server.
Response body (200):
json
{ "code": "00", "message": "Operacao efetuada com sucesso", "processing_status": { "code": "000", "message": "REALIZADO" }, "data": { "protocol": "20260603000123456", "client_key": "a1b2c3d4e5f6a7b8c9d0e1f2a", "branch": "55228091", "terminal": "ED315536", "authorization": "263250", "date": "2026-06-05", "modality": "V", "amount": 699.99, "currency_code": "986", "inst_num": 1, "nsu": "155098740", "cancel_amount": 699.99 } }
information icon
processing_status.code = "000" means the cancellation was completed successfully. Any other code indicates a rejection or a pending state (e.g. 100 = in progress, 074 = cancellation authorization denied) and may require a new cancellation request.

Schemas

CancellationResponse (POST)

FieldTypeRequiredDescription
codeStringYesBackend return code. 000 = accepted.
messageStringYesDescriptive result message returned by the backend.
protocolStringNoTracking protocol (17 digits). Present only on acceptance.

CancellationQueryResponse (GET)

FieldTypeRequiredDescription
codeStringYesQuery return code. 00 = query executed successfully.
messageStringYesDescriptive message of the query result.
processing_statusProcessingStatusNoDetailed cancellation processing status. Present on success.
dataCancellationDataNoCancellation transaction data. Present when a record is found.

ProcessingStatus

FieldTypeRequiredDescription
codeStringYesProcessing status code (000 = completed, 100 = in progress…).
messageStringYesTextual status description (e.g. REALIZADO).

CancellationData

FieldTypeDescription
protocolStringCancellation protocol number (17 digits).
client_keyStringClient key (up to 32 alphanumeric characters).
branchStringMerchant branch code (up to 15 digits).
terminalStringPOS terminal identifier (up to 8 characters).
authorizationStringAuthorization code of the original transaction.
dateStringOriginal transaction date (yyyy-MM-dd).
modalityStringV = Cash, P = Installment.
amountNumberOriginal transaction amount in BRL.
currency_codeStringISO 4217 currency code (986).
inst_numIntegerNumber of installments.
nsuStringNSU of the original transaction.
cancel_amountNumberCancelled amount in BRL (may be partial).

ErrorResponse

FieldTypeRequiredDescription
codeStringYesHTTP error code as string (e.g. 400, 404, 422).
messageStringYesHuman-readable error message.
detailsString[]NoList of individual validation or business failures.
trace_idStringNoTrace identifier (UUID v4), same value as X-Correlation-Id.

Authentication Flow

Authentication is not performed by this microservice: the API Gateway / Ingress validates the Bearer token and forwards only authenticated requests.

  1. Obtain an access_token from the OAuth2 API (client_credentials flow).
  2. Call the cancellation endpoints with Authorization: Bearer <access_token>.
  3. When the token expires → request a new token and retry.

Traceability Headers

HeaderDirectionDescription
X-Correlation-Idrequest/responseClient value is echoed when non-blank; otherwise the server generates a UUID v4.
X-Request-IdresponseAlways carries the same value as X-Correlation-Id (compatibility).

Error Handling

Errors follow the standard envelope (code, message, details, trace_id). Legacy SOAP business codes are translated into HTTP status codes (De/Para mapping).
HTTP StatusMeaning
400 Bad RequestInvalid payload, query or path parameters; backend validation error
401 UnauthorizedAuthentication with the backend failed
403 ForbiddenAccess denied by the backend
404 Not FoundOriginal transaction / cancellation not found
409 ConflictInconsistent state (e.g. transaction already cancelled)
422 Unprocessable EntityBusiness rule prevented the processing
429 Too Many RequestsRate limit exceeded for the client IP
500 Internal Server ErrorUnexpected internal error or unmapped backend code
502 Bad GatewayFailure communicating with the SOAP backend
503 Service UnavailableBackend temporarily unavailable
504 Gateway TimeoutTimeout waiting for the backend response
Error body example:
json
{ "code": "400", "message": "Dados da requisição inválidos. currency_code: deve ser '986'", "details": ["currency_code: deve ser '986'"], "trace_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479" }

Usage Example

Request a cancellation (cURL):
bash
curl -X POST "https://sales-data-ms-wlb-api-hti.apps.ocp-hml.getnet.com.br/sale-cancellation/v1/cancellations" \ -H "Authorization: Bearer {ACCESS-TOKEN}" \ -H "Content-Type: application/json" \ -H "X-Correlation-Id: f47ac10b-58cc-4372-a567-0e02b2c3d479" \ -d '{ "branch": "55228091", "terminal": "ED315536", "authorization": "263250", "date": "2026-06-05", "modality": "V", "amount": 625.00, "currency_code": "986", "inst_num": 1, "nsu": "155098740", "cancel_amount": 625.00, "client_key": "34567895673456782345678934567843" }'
Track the cancellation by protocol:
bash
curl "https://sales-data-ms-wlb-api-hti.apps.ocp-hml.getnet.com.br/sale-cancellation/v1/cancellations/20260603000123456" \ -H "Authorization: Bearer {ACCESS-TOKEN}"

Best Practices

  • Store the protocol — it is the only key to track the cancellation lifecycle; persist it right after the 202.
  • Do not retry blindlyPOST is not idempotent; on timeout, query by branch/client_key before requesting again.
  • Check processing_status.code — HTTP 200 only means the query succeeded; the cancellation outcome is in processing_status.
  • Send X-Correlation-Id — propagate your own identifier to correlate logs during support requests.
  • Respect the rate limit — 50 requests per 60 s per IP; handle 429 with backoff.
  • Validate before sendingmodality ∈ {V,P}, currency_code = 986, date not in the future, amounts greater than zero.

Getnet MPS White Label — Sale Cancellation API v1.0.0