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
httpsand 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:
| Field | Description |
|---|---|
name | A name to recognize the subscription. Required. |
url | The address that receives the messages. Required, https. |
events | List of events. Unknown names are dropped; if none are left, the request is refused. |
projectUid | Only 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).
| Operation | Route |
|---|---|
| List subscriptions | GET /api/v1/integration/webhooks |
| Create a subscription | POST /api/v1/integration/webhooks |
| Revoke a subscription | DELETE /api/v1/integration/webhooks/{uid} (204; it also stops messages already waiting) |
| List the available events | GET /api/v1/integration/webhooks/events |
These four routes need the X-Client-Uid header (except the events route).
Events
| Event | When it is sent |
|---|---|
document.sent | The SII received the document. From here the folio is final and a TrackID exists. |
document.accepted | The SII accepted the document. |
document.accepted_with_reparos | The SII accepted it with objections. It is valid; issues says which. |
document.rejected | The SII refused the upload or the document. issues says why. |
payment.applied | A new payment was recorded and applied to invoices. Repeating the same request sends nothing. |
payment.reversed | A payment was taken back (bounced cheque, refund). |
purchase_order.approval_requested | A purchase order is waiting for approval. |
purchase_order.approved | The order has every approval it needs. |
purchase_order.rejected | An approver rejected the order; reason carries the reason. |
purchase_order.sent | The order was sent to the supplier. |
purchase_order.over_invoiced | A supplier invoice went beyond the order's tolerance. |
purchase_order.closed | The order was closed. |
ticket.raised | A ticket was opened. |
ticket.state_changed | A ticket changed state. |
ticket.commented | A 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:
| Header | Content |
|---|---|
X-Synaptik-Event | The event name, the same as in the body. |
X-Synaptik-Delivery | One identifier per delivery. A retry of the same delivery has the same value; use it to ignore repeats. |
X-Synaptik-Signature | HMAC-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
}
documentUidis theuidthe API returned when the document was created.siiDocumentTypeis the SII code (33 factura, 39 boleta, 61 credit note).siiStatusis empty ondocument.sent, because the SII has not reviewed the document yet.issueslists the objections or reasons for rejection, each withcode(for exampleHED-3-845) andmessage.simulatedistruewhen 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 withGET /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.