Skip to main content
connic
Connectors

Webhooks

Start agents with HTTP requests, return their answer in the response, or POST run results to your own endpoint.

Last updated
ModesInbound, sync, outbound
YAML typewebhook or http
CredentialsNone. connic generates the secrets.
BridgeOutbound, to reach an endpoint in a private network
Custom domainInbound and sync
Linked agentsOne or more. A request starts every linked agent.
While pausedRequests with a valid secret get 200 with {"status": "ignored"} and start no runs. connic doesn't store or replay them.

Set up

  1. Open the agent. In Connector Flow, click Add inbound connector for inbound or sync, or Add outbound connector for outbound (Add another once that side has a connector). Then click Create New Connector and select HTTP Webhook.

  2. Choose the mode. For outbound, enter the Callback URL, and select a Bridge if the endpoint is in a private network.

  3. Click Create. For inbound and sync, the details drawer opens with the Webhook URL and Secret Key. For outbound, choose how the agent uses the connector; the Signing Secret is in the details drawer. To open the drawer, hover over the connector in the flow and click the eye icon.

  4. For inbound and sync, send requests to the webhook URL. For outbound, verify the signature of each request your endpoint receives.

In code

Declare the webhook in connectors/*.yaml. The first deploy generates its URL and secrets, which then appear in the details drawer.

connectors/order-intake.yaml
type: webhook
mode: inbound              # or sync
config:
  require_auth: true
  rate_limit:
    per_ip: 60
agents:
  - order-processor
connectors/order-results.yaml
type: webhook
mode: outbound
bridge: office-network     # optional, for an endpoint in a private network
config:
  outbound_url: ${ORDER_RESULTS_URL}
agents:
  - name: order-processor
    outbound: { usage: automatic }

Configuration

The fields of a webhook, the same in connectors/*.yaml, the REST API, and connic MCP. The descriptions name the matching setting in the dashboard. Connectors in code describes the fields every connector shares, such as agents and environments.

FieldTypeStatusDescription
typestringRequiredwebhook or http.
modestringRequiredinbound, sync, or outbound. Dashboard: Mode.
domainstringOptionalInbound and sync. Hostname or ID of an active custom domain for the webhook URL.
bridgestringOptionalOutbound. Name or ID of the Bridge that delivers requests into a private network. Dashboard: Bridge.
apps_onlybooleanOptionalSync, and only in connectors/*.yaml. Accept requests only from the apps that list this connector, through their /_connic/c/<key> path. The webhook URL then rejects direct requests, and the secret isn't used.Default: false
configobjectOptionalWebhook settings.
outbound_urlstringRequiredOutbound. Where connic POSTs. An HTTPS URL on port 443, without credentials or a fragment, whose host resolves only to public IP addresses. With a bridge, the endpoint's http:// or https:// address in the private network; for https://, the endpoint needs a certificate from a public certificate authority that's valid for its hostname. In a connector file, connic lint and the start of the deploy check the scheme, port, and credentials of a URL without a Bridge; whether its host is public is checked when the connector is saved, which for a file happens at activation. Dashboard: Callback URL.
require_authbooleanOptionalInbound and sync. Callers must send the secret. Dashboard: Require Authentication.Default: true
http_status_fieldstringOptionalSync. Field in the agent's JSON output, as a dot path such as error.status. When it holds a number from 400 to 599, the webhook answers with that HTTP status. See Error status. Dashboard: HTTP Status Field.
rate_limitobjectOptionalInbound and sync. Requests per minute, each from 0 to 1,000; 0 means no limit. See Rate limits. Dashboard: Rate Limits.
totalintegerOptionalAll requests together. Dashboard: Total per Minute.Default: 0
per_ipintegerOptionalRequests from one client IP address. Dashboard: Per IP per Minute.Default: 0
keystringOptionalPayload field to count per_key by, as a dot path such as data.customer_id. Required when per_key is set. Dashboard: Rate Limit Key.
per_keyintegerOptionalRequests with the same value in key. Dashboard: Per Key per Minute.Default: 0

Generated values

connic creates these when the connector is created and keeps them across updates and deploys. Copy them from the details drawer. Leave them out of YAML files; connic lint rejects them.

ValueModesDescription
Webhook URLInbound, syncThe address callers send requests to. It uses the connector's custom domain when one is set.
Secret KeyInbound, syncThe secret callers send while Require Authentication is on.
Signing SecretOutboundThe key connic signs every outbound request with.

Send requests

Modes: Inbound, sync

Send GET or POST requests to the webhook URL. The request becomes the input of every linked agent. connic doesn't deduplicate requests, so a sender that retries starts new runs; send an event ID if your agent needs to detect repeats.

RequestAgent input
POST application/jsonThe JSON body. connic parses every POST body that isn't form data as JSON; a body that isn't valid JSON arrives as text, and an empty body as {}.
POST application/x-www-form-urlencodedEach form field becomes a key. For a repeated field, the last value wins.
POST multipart/form-dataText fields become keys, and uploads become files. See Files.
GETThe query parameters, except secret. On a POST, query parameters are not part of the input.
JSON
curl -X POST <webhook-url> \
  -H "Content-Type: application/json" \
  -H "X-Connic-Secret: <secret>" \
  -d '{
    "prompt": "Analyze this data",
    "data": {"key": "value"}
  }'
Form data
curl -X POST <webhook-url> \
  -H "X-Connic-Secret: <secret>" \
  -d "message=Process this invoice" \
  -d "customer_id=12345"
GET
curl "<webhook-url>?secret=<secret>&prompt=hello"

Files

Upload files as multipart/form-data. Each accepted file goes to the model with the agent input.

terminal
curl -X POST <webhook-url> \
  -H "X-Connic-Secret: <secret>" \
  -F "instructions=Compare these two documents" \
  -F "file1=@document1.pdf" \
  -F "file2=@document2.pdf"

In context["payload"], the text fields are top-level keys and the uploads are listed under files, base64-encoded. The model receives each file as its own part, and the payload without files as text.

payload shape
# context["payload"] in middleware before()
{
  "customer_id": "12345",      # text fields sit at the top level
  "tag": ["a", "b"],           # repeated keys are grouped into a list
  "instructions": "Compare these two documents",
  "files": [
    {
      "name": "document1.pdf",   # original filename
      "field_name": "file1",     # form field name
      "mime_type": "application/pdf",
      "data": "<base64-bytes>",  # always base64-encoded ASCII
      "size": 12345              # bytes
    }
  ]
}

A JSON body can carry files the same way: a files list of objects with name, mime_type, and base64 data.

An input takes up to 50 files, at most 32 MiB combined. At the first file over a limit, connic keeps the complete files before it and accepts no further files. Uploads of unsupported types are omitted. Each omitted file is described in file_issues in the payload, and form fields stay available even when no file is accepted. When a request has attachments, the response reports them in accepted, omitted, and issues.

Supported types: JPEG, PNG, GIF, WebP, and HEIC/HEIF images; PDF, Word, RTF, OpenDocument, EPUB, plain text, HTML, and Markdown documents; CSV, TSV, JSON, JSON Lines, XML, Excel, and PowerPoint files. connic takes an upload's type from the Content-Type of its part, not from the file name. curl only sets it for a few common extensions, so add it for others, for example -F "file=@data.csv;type=text/csv". Whether the model can read a type depends on the model; see file input for connic/* models.

Files are optional by default. Turn on Files required for an agent in the connector's details drawer, or set files_required: true on its link in YAML, to fail the run before it starts when a file is missing or was omitted.

A request has room for 32 MiB of files with their base64 encoding or multipart overhead, plus the other fields. Larger requests get 413 and start no run.

Responses

Modes: Inbound, sync

Inbound response

An inbound webhook queues a run for each linked agent and answers right away with the run IDs. The agents work in the background; to receive their results, see Results of inbound runs.

response.json
{
  "status": "ok",
  "dispatched_to": 2,
  "run_ids": [
    "550e8400-e29b-41d4-a716-446655440000",
    "550e8400-e29b-41d4-a716-446655440001"
  ]
}

Sync response

A sync webhook waits for the run and returns its result in the same response. The HTTP status is 200 either way, unless an error status is set, so check status in the body: it is failed when the run failed, was cancelled, or didn't finish within 5 minutes. A run that is still going keeps running, and result.status shows where it is, such as started or awaiting_approval. With several linked agents, the agents run one after another, each with its own 5 minutes, and the response lists each one under results.

response.json
{
  "status": "ok",
  "result": {
    "run_id": "550e8400-e29b-41d4-a716-446655440000",
    "agent_name": "invoice-processor",
    "status": "completed",
    "output": "The invoice total is $1,234.56",
    "error": null
  }
}
sync_request.py
import requests

resp = requests.post(
    "<webhook-url>",
    json={"query": "What is the status of order 123?"},
    headers={"X-Connic-Secret": "<secret>"},
    timeout=310,
)
resp.raise_for_status()
data = resp.json()
if data["status"] != "ok":
    raise RuntimeError(data["result"]["error"] or data["result"]["status"])
print(data["result"]["output"])
sync_request.js
const resp = await fetch("<webhook-url>", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Connic-Secret": "<secret>",
  },
  body: JSON.stringify({ query: "Summarize the latest ticket" }),
});

if (!resp.ok) throw new Error(await resp.text());
const data = await resp.json();
if (data.status !== "ok") throw new Error(data.result.error ?? data.result.status);
console.log(data.result.output);

Error status

To answer a sync request with an HTTP error, such as 401 for a missing user token, set http_status_field to a field of the agent's JSON output. When the output is a JSON object and that field holds a number from 400 to 599, the webhook answers with that status. The body stays the same, so clients that read it keep working. Any other output answers 200. With several linked agents, the first agent whose output holds a status decides.

A stop in middleware works the same way. The message of StopProcessing becomes the output, so a JSON message sets the status:

connectors/form-filler.yaml
type: webhook
mode: sync
config:
  http_status_field: status
agents:
  - form-filler
middleware/form-filler.py
import json

from connic import StopProcessing


async def before(content, context):
    request = context.get("request") or {}
    if not request.get("headers", {}).get("authorization"):
        raise StopProcessing(json.dumps({"status": 401, "message": "Missing token"}), publish_outbound=False)
    return content

Authentication

Modes: Inbound, sync

Send the secret

While Require Authentication is on, the default, every request must carry the connector's secret key in one of three places: the X-Connic-Secret header, an Authorization: Bearer header, or the secret query parameter. Prefer a header: query parameters end up in access logs. Turn the setting off only for an endpoint that is meant to be public.

terminal
# X-Connic-Secret header (recommended)
curl -X POST <webhook-url> \
  -H "Content-Type: application/json" \
  -H "X-Connic-Secret: <secret>" \
  -d '{"message": "hello"}'

# Authorization: Bearer header
curl -X POST <webhook-url> \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <secret>" \
  -d '{"message": "hello"}'

# Query parameter (ends up in access logs)
curl -X POST "<webhook-url>?secret=<secret>" \
  -H "Content-Type: application/json" \
  -d '{"message": "hello"}'

Verify the sender

Some senders sign their requests, for example with an HMAC signature header or a JWT in Authorization. Each webhook run carries the original request in context["request"], so middleware can check the signature before the agent runs: the method, the headers with lowercase names, the query parameters, the time connic received the request as received_at (UTC, ISO 8601), and the raw body as body_base64.

request shape
# context["request"] in middleware, tools and hooks
{
    "method": "POST",
    "headers": {"content-type": "application/json", "x-hub-signature-256": "sha256=..."},
    "query": {},
    "received_at": "2026-01-15T10:30:00.123456+00:00",
    "body_base64": "eyJhY3Rpb24iOiJvcGVuZWQifQ=="
}

connic removes its own secret (X-Connic-Secret, a matching Authorization header, and the secret query parameter) and headers added by its network, such as X-Forwarded-For, so middleware doesn't see the caller's IP address. The raw body is included up to 1 MiB and not for multipart requests; otherwise body_omitted is true. Run details show the body and the Authorization, Proxy-Authorization, Cookie, and X-API-Key headers as [REDACTED]. Runs started another way, such as reruns and tests, have no request.

Check an HMAC signature, such as GitHub's X-Hub-Signature-256:

middleware/github-events.py
import base64
import hashlib
import hmac
import os

from connic import StopProcessing


async def before(content, context):
    request = context.get("request")
    if request is None:  # Not started by a webhook request, such as a rerun
        return content
    body = base64.b64decode(request.get("body_base64") or "")
    digest = hmac.new(os.environ["GITHUB_WEBHOOK_SECRET"].encode(), body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(f"sha256={digest}", request["headers"].get("x-hub-signature-256", "")):
        raise StopProcessing("Invalid signature", publish_outbound=False)
    return content

Check a signed JWT, such as the Bot Framework token Microsoft Teams sends. Teams can't send the connic secret in a header, so add ?secret= to the messaging endpoint URL. A run can start well after its request arrived, for example while it waits in the queue, so the example checks exp and nbf against received_at with a few minutes of leeway instead of the current time.

middleware/teams-bot.py
# requirements.txt: PyJWT[crypto]
import asyncio
import os
from datetime import datetime

import jwt
from connic import StopProcessing

keys = jwt.PyJWKClient("https://login.botframework.com/v1/.well-known/keys")
LEEWAY = 300  # Seconds of clock skew


async def before(content, context):
    request = context.get("request")
    if request is None:  # Not started by a webhook request, such as a rerun
        return content
    token = request["headers"].get("authorization", "").removeprefix("Bearer ")
    try:
        key = await asyncio.to_thread(keys.get_signing_key_from_jwt, token)
        claims = jwt.decode(
            token, key.key, algorithms=["RS256"], audience=os.environ["MICROSOFT_APP_ID"],
            issuer="https://api.botframework.com", leeway=LEEWAY,
            options={"require": ["exp"], "verify_exp": False, "verify_nbf": False},
        )
    except jwt.PyJWTError:
        raise StopProcessing("Invalid token", publish_outbound=False)
    received_at = datetime.fromisoformat(request["received_at"]).timestamp()
    if not claims.get("nbf", 0) - LEEWAY <= received_at <= claims["exp"] + LEEWAY:
        raise StopProcessing("Invalid token", publish_outbound=False)
    if claims.get("serviceUrl") != context["payload"].get("serviceUrl"):
        raise StopProcessing("Invalid token", publish_outbound=False)
    return content
The check runs when the run starts. A request that fails it is still accepted and creates a run, which the middleware then stops. StopProcessing completes the run, so a sync caller gets "status": "ok" with the stop message as output. To answer with 401 or 403 instead, see Error status.

Rate limits

Modes: Inbound, sync

Rate limits cap the requests a webhook accepts per minute. Set them under Rate Limits in the dashboard or in config.rate_limit. All three are off by default.

  • total counts all requests together.
  • per_ip counts requests from one client IP address. IPv6 addresses count per /64 network.
  • per_key counts requests with the same value in the payload field named by key. Requests without that field skip this limit.

A request over a limit gets 429 with a Retry-After header. It creates no run, never reaches middleware, and uses no Project credit. Requests rejected per IP or per key don't count toward the total. connic also applies its own platform limits per webhook and per client IP, which answer the same way.

The key is read from the payload as sent, before middleware can check the sender. On a webhook without authentication, a client can change the value to get around the per-key limit, or send another user's value to use up that user's limit. Use the per-key limit to share capacity among senders you trust, and the per-IP and total limits against abuse.

Outbound delivery

Modes: Outbound

An outbound webhook POSTs JSON to its callback URL. It sends when a linked agent's run completes, when the model calls it as a tool, or when middleware calls it, depending on the link's usage. An outbound webhook doesn't accept requests.

Automatic payload

An automatic link POSTs each run that completes successfully. Failed and cancelled runs send nothing, and neither do runs whose middleware stops them with publish_outbound=False.

payload.json
{
  "run_id": "550e8400-e29b-41d4-a716-446655440000",
  "agent_name": "invoice-processor",
  "status": "completed",
  "output": "The invoice total is $1,234.56",
  "error": null,
  "started_at": "2026-01-15T10:30:00.123456Z",
  "ended_at": "2026-01-15T10:30:05.654321Z",
  "token_usage": {
    "input_tokens": 150,
    "output_tokens": 50,
    "thinking_tokens": 0,
    "cached_input_tokens": 0,
    "total_tokens": 200,
    "model": "connic/gpt-5.6-terra"
  }
}

token_usage also lists each model call under model_usages. It is {} when the run made no model call.

Agent-tool and middleware payload

The model or middleware passes the JSON body under payload; other top-level fields fail validation. connic POSTs the value of payload and adds the URL, signature, retries, and Bridge routing, none of which the model sees. The send is queued: the tool or send_connector returns once connic has accepted it, not your endpoint's response.

connector-payload.json
{
  "payload": {
    "invoice_id": "inv_123",
    "status": "approved"
  }
}

Delivery and retries

Every request has Content-Type: application/json and the signature headers below. A 2xx response counts as delivered. connic doesn't follow redirects, and any other status, 4xx included, counts as a failed attempt. Each attempt times out after 30 seconds, and a failed delivery is tried 3 times in total, waiting 1 and then 2 seconds between attempts. Retries reuse the first attempt's timestamp and signature. The connector's runs show each delivery with its status code.

Delivery is at least once: in rare cases your endpoint receives the same request twice. Use run_id to detect repeats of an automatic delivery.

Verify the signature

connic signs every request with the connector's signing secret, using HMAC-SHA256:

  • X-Connic-Timestamp is the Unix time in seconds when connic signed the request.
  • X-Connic-Signature is the hex HMAC-SHA256 of the timestamp, a ., and the raw request body.

Compute the signature over the raw body as received, compare it in constant time, and reject timestamps older than 5 minutes to block replays. Keep the signing secret in an environment variable.

verify_webhook.py
import hashlib
import hmac
import time


def verify_webhook(body: bytes, signature: str, timestamp: str, secret: str) -> bool:
    if abs(time.time() - int(timestamp)) > 300:
        return False
    expected = hmac.new(
        secret.encode(),
        f"{timestamp}.".encode() + body,
        hashlib.sha256,
    ).hexdigest()
    return hmac.compare_digest(expected, signature)


# Flask
@app.route("/webhook", methods=["POST"])
def handle_webhook():
    signature = request.headers.get("X-Connic-Signature", "")
    timestamp = request.headers.get("X-Connic-Timestamp", "")
    if not verify_webhook(request.get_data(), signature, timestamp, SIGNING_SECRET):
        return "Invalid signature", 401
    return "OK", 200
verify_webhook.js
import crypto from "crypto";

function verifyWebhook(body, signature, timestamp, secret) {
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected = crypto
    .createHmac("sha256", secret)
    .update(`${timestamp}.${body}`)
    .digest("hex");
  return (
    expected.length === signature.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature))
  );
}

// Express
app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const signature = req.headers["x-connic-signature"] ?? "";
  const timestamp = req.headers["x-connic-timestamp"] ?? "";
  if (!verifyWebhook(req.body.toString(), signature, timestamp, SIGNING_SECRET)) {
    return res.status(401).send("Invalid signature");
  }
  res.send("OK");
});

Limits and errors

Modes: Inbound, sync

StatusMeaning
200Accepted. Sync responses also return 200 when the run failed; check status in the body. With http_status_field, a sync response can carry a status from the agent's output instead; see Error status. A paused connector answers {"status": "ignored", "reason": "disabled"}, and a connector without linked agents answers No agents linked; neither starts a run. A HEAD request gets an empty 200 after the secret check and starts no run.
400The files field or a file in the request is invalid, or the form data is too large to parse.
401The secret is missing or wrong. Paused connectors check the secret too. On an apps_only webhook, the request didn't come from one of its apps.
404No webhook exists at this URL.
405The method isn't GET, HEAD, or POST.
413The request is larger than the room for 32 MiB of files and the other fields. The body names the limit with request_too_large.
429A configured rate limit or a platform limit is reached. Retry after the seconds in Retry-After.
500, 503connic couldn't accept the request. A 503 with no_active_deployment means the project has no active deployment; deploy it before retrying. For other errors, retry with backoff.