Pređi na sadržaj
Teme dokumentacije

Webhooks

How to receive a signed message when a document, payment, purchase order or ticket changes, and how to verify the signature.

Ova stranica još nije prevedena na Vaš jezik. Prikazana je na jeziku koji je dostupan.

A webhook is a message Synaptik sends to an address in your system (a URL) when something happens. Your system does not have to ask about each document.

Before you start

  • Webhooks are off by default on the server. Pintor Project turns them on for your company when you ask.
  • The URL must use https and cannot point to an internal address (localhost, private addresses, .local, .internal). Synaptik checks this when the subscription is created and again on every delivery.

Create a subscription

A person in the company who has the wt.integrationkeys.manage permission creates it, with their Synaptik session (a user token). An application call that only has document and payment writes cannot create subscriptions.

curl -X POST "https://YOUR_API_ADDRESS/api/v1/integration/webhooks" \
  -H "Authorization: Bearer THE_PERSONS_TOKEN" \
  -H "X-Client-Uid: YOUR_WORKSPACE_UID" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Rental platform",
    "url": "https://your-system.example.com/hooks/synaptik",
    "events": ["document.sent", "document.accepted", "document.accepted_with_reparos", "document.rejected", "payment.applied", "payment.reversed"]
  }'

Body fields:

FieldDescription
nameA name to recognize the subscription. Required.
urlThe address that receives the messages. Required, https.
eventsList of events. Unknown names are dropped; if none are left, the request is refused.
projectUidOnly for ticket events: limits the messages to one project. Without it, the subscription receives those of the whole company. Do not send it with document, payment or purchase order events, because they do not belong to a project.

The response includes the signing secret, which starts with whsec_. It is shown only once:

{
  "success": true,
  "data": {
    "subscription": {
      "uid": "9d2f4a10-5b7c-4e21-8a63-1c0e7b9f2d55",
      "projectUid": null,
      "name": "Rental platform",
      "url": "https://your-system.example.com/hooks/synaptik",
      "events": "document.sent,document.accepted,document.accepted_with_reparos,document.rejected,payment.applied,payment.reversed",
      "createdAt": "2026-11-05T14:02:11Z",
      "revokedAt": null,
      "lastSuccessAt": null,
      "lastFailureAt": null,
      "isActive": true
    },
    "secret": "whsec_...",
    "instructions": "Firme cada entrega verificando la cabecera X-Synaptik-Signature: es el HMAC-SHA256 del cuerpo exacto, en hexadecimal, con este secreto. Guárdelo ahora."
  }
}

The instructions text is returned in Spanish. To change the secret, create a new subscription and revoke the old one. If the request is refused, the answer is 400 and the reason is in errors (for example La URL debe usar https., also in Spanish).

OperationRoute
List subscriptionsGET /api/v1/integration/webhooks
Create a subscriptionPOST /api/v1/integration/webhooks
Revoke a subscriptionDELETE /api/v1/integration/webhooks/{uid} (204; it also stops messages already waiting)
List the available eventsGET /api/v1/integration/webhooks/events

These four routes need the X-Client-Uid header (except the events route).

Events

EventWhen it is sent
document.sentThe SII received the document. From here the folio is final and a TrackID exists.
document.acceptedThe SII accepted the document.
document.accepted_with_reparosThe SII accepted it with objections. It is valid; issues says which.
document.rejectedThe SII refused the upload or the document. issues says why.
payment.appliedA new payment was recorded and applied to invoices. Repeating the same request sends nothing.
payment.reversedA payment was taken back (bounced cheque, refund).
purchase_order.approval_requestedA purchase order is waiting for approval.
purchase_order.approvedThe order has every approval it needs.
purchase_order.rejectedAn approver rejected the order; reason carries the reason.
purchase_order.sentThe order was sent to the supplier.
purchase_order.over_invoicedA supplier invoice went beyond the order's tolerance.
purchase_order.closedThe order was closed.
ticket.raisedA ticket was opened.
ticket.state_changedA ticket changed state.
ticket.commentedA ticket received a comment.

A document normally sends document.sent and then one of the other three. If the SII refuses the upload itself, only document.rejected arrives.

What your system receives

Synaptik sends a POST to your URL with a JSON body and these headers:

HeaderContent
X-Synaptik-EventThe event name, the same as in the body.
X-Synaptik-DeliveryOne identifier per delivery. A retry of the same delivery has the same value; use it to ignore repeats.
X-Synaptik-SignatureHMAC-SHA256 of the exact body, keyed with your secret, in lowercase hexadecimal.

Document event:

{
  "event": "document.accepted",
  "eventId": "6f1c2a8e-3d41-4b7e-9a50-2f0d5c7e9b11",
  "occurredAt": "2026-11-05T14:02:11.403+00:00",
  "documentUid": "0b6e7f2a-9c1d-4e8f-a3b5-7d2c1e0f9a44",
  "documentType": 0,
  "siiDocumentType": 33,
  "folio": 715,
  "documentDate": "2026-11-05T00:00:00",
  "siiStatus": "Aceptado",
  "trackId": "0024056226",
  "issues": [],
  "simulated": false
}
  • documentUid is the uid the API returned when the document was created.
  • siiDocumentType is the SII code (33 factura, 39 boleta, 61 credit note).
  • siiStatus is empty on document.sent, because the SII has not reviewed the document yet.
  • issues lists the objections or reasons for rejection, each with code (for example HED-3-845) and message.
  • simulated is true when the message comes from a simulation company, not the real SII.

Payment event (the payment is as the API returns it, see Reference):

{
  "event": "payment.applied",
  "eventId": "c2b8d3f4-7a19-4d60-b5e2-9f1a6c3e8d70",
  "occurredAt": "2026-10-15T14:03:11+00:00",
  "payment": { "uid": "...", "externalReference": "PAY-2026-10-000123", "status": "applied", "amount": 450000 }
}

Purchase order event (the values are an example):

{
  "event": "purchase_order.approved",
  "eventId": "a1d7e5c9-2b48-4f03-9c6a-3e8f0b1d7a22",
  "occurredAt": "2026-11-10T09:15:00+00:00",
  "orderUid": "...",
  "number": 128,
  "status": "approved",
  "supplierRut": "76016027-K",
  "supplierName": "Supplier SpA",
  "currency": "CLP",
  "net": 1000000,
  "total": 1190000,
  "approvalAmountClp": 1190000,
  "reason": null
}

Ticket event (it has no eventId; the values are an example):

{
  "event": "ticket.raised",
  "occurredAt": "2026-11-05T14:02:11Z",
  "ticketUid": "...",
  "ticketNumber": "TCK-1042",
  "subject": "Disk at 95% on server 3",
  "state": "New",
  "isOpen": true,
  "projectUid": "..."
}

Each document message carries the document's full SII status at that moment. Messages can arrive out of order (a retried document.sent can come after document.accepted), so keep the one with the latest occurredAt.

Verify the signature

The signature is the HMAC-SHA256 of the body exactly as it arrived, computed with your whsec_... secret (the full text, prefix included) and written in lowercase hexadecimal. Compute it over the received bytes, before parsing the JSON, and compare in constant time.

Node.js:

import { createHmac, timingSafeEqual } from "node:crypto";

export function isValidSignature(rawBody, signatureHeader, secret) {
  const expected = createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(signatureHeader ?? "");
  return a.length === b.length && timingSafeEqual(a, b);
}

Python:

import hashlib, hmac

def is_valid_signature(raw_body: bytes, signature_header: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature_header or "")

.NET:

var body = await new StreamReader(Request.Body).ReadToEndAsync();
var expected = Convert.ToHexString(
    HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), Encoding.UTF8.GetBytes(body))).ToLowerInvariant();
var received = Request.Headers["X-Synaptik-Signature"].ToString();

if (!CryptographicOperations.FixedTimeEquals(Encoding.ASCII.GetBytes(expected), Encoding.ASCII.GetBytes(received)))
    return Unauthorized();

Retries and timeouts

  • Synaptik looks for pending messages every 30 seconds, 20 at a time.
  • Any 2xx answer counts as delivered. Your system has 10 seconds to answer, so store the message, answer at once, and do the slow work afterwards.
  • After a failure (another status, a timeout or a connection error), Synaptik retries after 2, 4, 8, 16 and 32 minutes. After 6 attempts in total (about one hour) it stops.
  • A URL that points to an internal address is not retried.
  • If your system was down for longer, it can catch up with GET /api/v1/sii/events (the SII log by date range) or by reading each document's status with GET /api/v1/sii/documents/{uid}.
  • A problem on your side never stops a document from being issued or a payment from being recorded: the message is queued together with the change.