sintoniadocs
API reference

Webhooks API

Publish external messages and receive signed encrypted-message events.

On this pageStart with the applicationAddress, authentication and permissionsCan not open messageAdministrative APIReceive Output EventsInstallation Settings

Sintonia offers entries to post external messages on a channel and outputs to deliver signed events to your service. This reference describes the implemented endpoints. OpenAPI specification contains contracts for import into API tools.

Start with the application#

  1. Open the channel and choose Webhooks and integrations.
  2. Create a entry to receive messages or a output to send events.
  3. Copy the entry URL or the exit signature secret. These values are displayed only in creation.

The configuration requires participating in the channel and administrator or owner of workspace. An installation administrator also needs to participate in the channel to configure it. Integrations are displayed with the label APP.

Address, authentication and permissions#

Use the installation's backend address, for example https://chat.example.com. Administrative paths begin with /api; external publication uses /hooks without /api.

Administrative requests use:

http
Authorization: Bearer TOKEN_DA_SESSAO
X-Workspace-Id: ID_DO_WORKSPACE
Content-Type: application/json

The session token is obtained at the Sintonia login; it is neither the URL entry or signature secret. To get a session from API, use your existing account:

http
POST /api/auth/login
Content-Type: application/json

{"email":"pessoa@example.com","password":"SUA_SENHA"}

The 200 response contains token and user (with id, name and email). Use the value of token as Bearer in administrative calls. Invalid credentials return 401. This login authenticates the session; access to encrypted content continues depending on device keys.

Inform X-Workspace-Id explicitly on accounts with multiple workspaces. Without the header, backend selects an account association, which may not match the desired channel.

OperationPermission
List, create and revoke integrations; see deliveriesValid session, member of workspace/channel and administrator or owner of workspace
See Encrypted Entrance Key PackagesValid session and member of workspace/channel; administrative function not required
Post in an entryPossession of secret token on URL; does not require session nor X-Workspace-Id

There is 100 active integrations by workspace limit, adding inputs and outputs. The identifiers are UUIDs. Names have 1 to 80 characters and cannot contain only spaces.

Can not open message#

POST /hooks/{token}#

The token is fixed on creation and identifies integration and its channel. Use fully copied URL from the application:

sh
curl --request POST 'https://chat.example.com/hooks/TOKEN_DA_ENTRADA' \
  --header 'Content-Type: application/json' \
  --data '{"text":"Deploy concluído com sucesso."}'

Success: 200, Content-Type: text/plain, body:

text
ok

The body must be a JSON object. There are two ways to inform the content:

FieldTypeBehavior
textstringUsed when it contains non-empty text. It has priority over blocks.
blocksobject arrayAlternative when text is missing or blank. Extracts text.text and the texts of elements[].text, joining them with line wrap.

Example of text blocks:

json
{
  "blocks": [
    {"text": {"text": "Status do ambiente"}},
    {"elements": [{"text": "API disponível"}, {"text": "Fila processada"}]}
  ]
}

The result is a message with three lines. Visual types, buttons, interactive actions, images and remote files are not rendered by the endpoint. Extra fields are ignored; channel and username do not replace the configured channel and name.

Limits:

  • HTTP body up to 65.536 bytes, including the entire structure JSON.
  • End text not empty, with up to 16.000 units UTF-16. Some characters, such as emojis, occupy two units.
  • 60 publications accepted by 60 window seconds per entry. The window is counted from the first post after the previous window.

Expected answers:

HTTPCondition
200Message received, encrypted and persisted.
400JSON malformed or final text empty/over limit.
404Unknown token, revoked entry, Unavailable workspace or unbound channel of integration workspace.
413Body HTTP above 65.536 bytes.
429Publication limit of the window reached.

Explicit errors of these endpoints return JSON with message, for example:

json
{"message":"Limite de 60 mensagens por minuto"}

There is no Retry-After header implemented. In case of 429, wait for the next window before trying again. The entry has no idempotence key: repeat an accepted POST creates another message, even with the same text. A lost response can result in duplication if the sender repeats the request.

Content protection#

The provider sends text to backend via HTTPS. backend processes it in memory and encryption before persisting, using ephemeral X25519, HKDF-SHA256 and AES-256-GCM with the public key to integration. The private integration key lies in a client-encrypted package with the channel key. backend does not receive the channel key or decipher the history.

The external source to the endpoint uses TLS; this snippet has no end-to-end encryption from the provider. Protect URL as an accreditation and avoid registering token or body in application logs, proxy, and capture tools.

Administrative API#

The following examples use BASE_URL, SESSION_TOKEN, WORKSPACE_ID and CHANNEL_ID variables filled in by the operator.

List integrations and deliveries#

GET /api/channels/{channel}/integrations

sh
curl "$BASE_URL/api/channels/$CHANNEL_ID/integrations" \
  --header "Authorization: Bearer $SESSION_TOKEN" \
  --header "X-Workspace-Id: $WORKSPACE_ID"

Success: 200, object with three lists:

json
{
  "incoming": [
    {"id":"11111111-1111-4111-8111-111111111111","name":"Deploy","active":true,"created_at":1794664800000}
  ],
  "outgoing": [],
  "deliveries": []
}

incoming and outgoing include active and revoked integrations of this channel and workspace. . They do not include tokens, destination URLs or signature secrets. deliveries contains even 100 output deliveries, ordered by next_attempt decreasing. There's no pagination in this version.

Fields of a delivery:

FieldTypeDescription
idUUIDStable event identifier delivered to this integration.
hook_idUUIDExit integration.
statusstringpending, delivered, failed or cancelled.
attemptswholeNumber of attempted lawsuits.
http_statuswhole or nullLast status HTTP received; null if there has been no response HTTP.
next_attemptwholeInstant Unix in milliseconds; it only represents a future delivery when status is pending.

Create an entry#

POST /api/channels/{channel}/integrations/incoming

json
{
  "name": "Deploy",
  "publicKey": "BASE64_DA_CHAVE_PUBLICA_X25519",
  "keyBox": "{\"ciphertext\":\"BASE64\",\"nonce\":\"BASE64\",\"mac\":\"BASE64\"}"
}

The example presents markers, not usable cryptographic material.

FieldMandatoryContract
nameYes.Name from 1 to 80 characters, not empty.
publicKeyYes.Public key X25519 of 32 bytes in Standard Base64, with 44 characters.
keyGenerationAfter renewalCurrent generation obtained from channel keys. Omiting is equivalent to the empty initial generation; an outdated generation is refused.
keyBoxYes.String containing JSON, with up to 2.000 characters, which protects the private key from integration. Do not send a JSON object in this field.

Generate the X25519 pair and the package in the client, keeping the private key out of backend. The application does this in ChannelCrypto.createIntegration, in lib/core/crypto.dart from the application repository. The package uses AES-256-GCM with a channel message key derivative by HKDF-SHA256: salt equal to UUID of the channel in UTF-8, sintonia/integrations/v1 domain, 32 output bytes. The AAD is the compact JSON UTF-8 of ["sintonia-integration-key-v1", channelId, publicKey]. Encrypted content is X25519 private secret of 32 bytes. ciphertext, nonce of 12 bytes and mac of 16 bytes are encoded in Standard Base64 within the string keyBox.

Server validation does not prove that the package deciphers correctly: the client needs to produce an authentic package corresponding to the public key. To configure an integration without implementing this protocol, create it by the application and only use your URL publication.

Success: 200:

json
{"id":"11111111-1111-4111-8111-111111111111","path":"/hooks/TOKEN_SECRETO"}

Concaten the address of backend with path. The original token cannot be consulted later; to replace it, revoke the entry and create another.

Consult input key packages#

GET /api/channels/{channel}/integrations/keys

Success: 200, list with id, public_key and key_box. The last two fields use underlined names in this answer. The query covers channel entries, including revoked and linked to other workspaces that share the channel. It is necessary for participants to read the history. Doesn't return secret URLs or private keys out of the blue.

Create an output#

POST /api/channels/{channel}/integrations/outgoing

sh
curl --request POST "$BASE_URL/api/channels/$CHANNEL_ID/integrations/outgoing" \
  --header "Authorization: Bearer $SESSION_TOKEN" \
  --header "X-Workspace-Id: $WORKSPACE_ID" \
  --header 'Content-Type: application/json' \
  --data '{"name":"Eventos do projeto","url":"https://integracoes.example.com/sintonia"}'

name is mandatory and accepts up to 80 characters. url is mandatory, accepted up to 2.000 characters and must be HTTPS, with hostname, without embedded credentials or fragment. Private/reserved IPs are blocked during delivery. Acceptance in creation does not confirm connectivity with destination.

Success: 200:

json
{"id":"22222222-2222-4222-8222-222222222222","secret":"BASE64_DO_SEGREDO_DE_ASSINATURA"}

The secret has 32 bytes in Standard Base64, and is displayed only in creation. Keep it in the receiving service. There is no query or secret rotation endpoint; to replace it, revoke the output and create another.

Repeal an entry or exit#

DELETE /api/channels/{channel}/integrations/{id}

sh
curl --request DELETE "$BASE_URL/api/channels/$CHANNEL_ID/integrations/$HOOK_ID" \
  --header "Authorization: Bearer $SESSION_TOKEN" \
  --header "X-Workspace-Id: $WORKSPACE_ID"

Success: 200, no body. The operation is idempotent and does not return 404 to an unmatched identifier in the authorized channel/workspace. Repeal preserves messages and encrypted read packages. Entries no longer accept publications; exits stop processing pending deliveries. A request already in transit may end. There's no reactivation implemented.

Administrative errors#

HTTPCondition
400Invalid fields, malformed public key/package or invalid URL.
401Absent session, invalid or expired.
403No participation in the workspace/channel or no administrative function required; workspace suspended.
409100 limit hit active integrations; or counts without selectable workspace.
503Unavailable output creation due to lack of WEBHOOK_ENCRYPTION_KEY in legacy mode saas or key configured with invalid size.

Form/JSON validations can use the default framework error format. Do not depend on a single structure for every HTTP error; use status and treat message when present.

Receive Output Events#

Sintonia makes a POST in the URL configured with Content-Type: application/json. Currently the event is message.created, generated by application messages and accepted messages on entries from the same channel.

json
{
  "id": "33333333-3333-4333-8333-333333333333",
  "type": "message.created",
  "workspace_id": "44444444-4444-4444-8444-444444444444",
  "channel_id": "55555555-5555-4555-8555-555555555555",
  "encrypted": true,
  "message": {
    "id": "66666666-6666-4666-8666-666666666666",
    "channel_id": "55555555-5555-4555-8555-555555555555",
    "user_id": "77777777-7777-4777-8777-777777777777",
    "client_id": "88888888-8888-4888-8888-888888888888",
    "parent_id": null,
    "ciphertext": "BASE64",
    "nonce": "BASE64",
    "mac": "BASE64",
    "created_at": 1794664800000,
    "kind": "message",
    "source_id": null,
    "ephemeral_key": null,
    "display_name": null,
    "author": "Pessoa de exemplo"
  }
}

The Base64 values above are illustrative. message carries the envelope and metadata; it does not contain deciphered text, original name of attachments or channel keys. kind is message or webhook; input messages have source_id, ephemeral_key and display_name of integration. Read, edit, delete events and separate files are not issued in this version. Allow additional fields at the event.

Each destination receives its own id event. Use this identifier for deduplication of deliveries; use message.id when you need to correlate the same message received by different integrations.

Headers and signature#

HeaderValue
X-Sintonia-Event-IdSame identifier as the event's id field; stable on referrals.
X-Sintonia-TimestampInstant attempt in Unix seconds, as decimal text.
X-Sintonia-Signaturev1= followed by 64 tiny hexadecimal characters.

Calculation:

text
chave = Base64Decode(secret)
conteúdo_assinado = ASCII(timestamp) + "." + corpo_HTTP_original_em_bytes
assinatura = "v1=" + HEX_MINÚSCULO(HMAC_SHA256(chave, conteúdo_assinado))

Valide before to play JSON. Do not serialize the object again to calculate the signature: spaces, order of fields and exact bytes are part of the signed content. Compare in constant time and accept only timestamps within a short window, for example ±300 seconds. Server clocks need to be synchronized.

There is a Executable example in Python 3.9+, using only the default library. Copy the file to your receiving service before importing the function:

python
from verify_webhook import verify_webhook

# Get these values from your framework and the receiving service safe.
if not verify_webhook(raw_body, request_headers, secret_base64):
    # Answer 401 and do not process the event.
    raise PermissionError("Assinatura inválida ou expirada")

# After validation: decode JSON and check if id matches
# to X-Sintonia-Event-Id. Record the event in a persistent queue with
# Deduplication by id, atomicly, and respond 2xx.

The subscription does not replace deduplication: the same event can be delivered again with new timestamp and signature. Preserve the identifiers processed throughout the period in which you accept referrals. Avoid automatically republishing on the same channel the events received from that channel, so as not to create publishing cycles.

Confirmation, referral and states#

Answer 2xx after accepting the event with durability. Any other status, DNS error, connection, TLS or timeout keeps the attempt unconfirmed. 3xx are not followed redirects. There is no order warranty, delivery exactly once or manual repetition by the administrative endpoint.

The line persists in the bank. The processor consults pending deliveries every five seconds by default and selects up to ten per cycle. There are up to eight attempts, with the minimum intervals below between consecutive failures:

text
10 s, 20 s, 40 s, 80 s, 160 s, 320 s, 640 s

The scheduling of the processor, load and unavailability may increase the intervals. The id and body remain equal in the attempts; timestamp and signature are recalculated. pending awaiting processing, delivered received 2xx, failed exhausted attempts and cancelled was disabled or lost the required association/availability prior to delivery.

The connection and reading have a five-second timeout; there is an additional ten-second limit for the sending/answer phase. Do not rely on that time as an exact time frame for the cycle execution. See deliveries in the administrative list to track the result.

Installation Settings#

VariableDefaultUsage
WEBHOOK_ENCRYPTION_KEYempty32 bytes operating key in Base64 to encrypt output credentials. Mandatory to create outputs in SaaS mode. All replicas must use the same key.
WEBHOOK_KEY_FILE./data/webhook.keyIn selfhost without explicit key, automatically generated file. In Compose is in /app/data/webhook.key, in volume instance-data.
WEBHOOK_DISPATCH_INTERVAL5000Delivery processor interval in milliseconds; configure in the backend process.
ALLOW_PRIVATE_WEBHOOK_TARGETSfalseOnly in selfhost, it allows private destinations and HTTP. It is ignored in legacy mode saas.

The transport solves the DNS, validates the IPs and fixes a validated IP on the connection. HTTPS checks the certificate by the original hostname. Do not send requests to private/reserved IPs in default mode.

Encrypted credentials, queue and metadata stay in the bank. Make backup also of the operating key; losing it prevents you from using existing outputs. This operating key does not decipher users' conversations. See DEPLOYMENT.md and SECURITY.md for persistence and cryptographic limits.

Recovery from a historyless account renews the keys of affected conversations and disables your entry webhooks. Create new integrations with the current generation; the server can't retrieve the private key from an old integration. The packages of previous generations preserve the history for participants who already had access.

Search channels, QR codes, uploads, security…

↑ ↓ navigate ↵ open result