Register a webhook trigger
const url = 'https://example.com/v1/webhooks';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"flowId":"example","flowVersion":"example","projectId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","config":{"input":"example"},"hmacSecretName":"example","generateSecret":true,"signature":{"kind":"hmac-sha256","encoding":"hex","header":"example","prefix":"example"},"deliveryIdHeader":"example","bodyLimitBytes":1,"rateLimitPerMinute":1,"label":"example","runAsServiceAccountId":"example","runAsProject":true,"toolsAllowedUnattended":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/webhooks \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "flowId": "example", "flowVersion": "example", "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "config": { "input": "example" }, "hmacSecretName": "example", "generateSecret": true, "signature": { "kind": "hmac-sha256", "encoding": "hex", "header": "example", "prefix": "example" }, "deliveryIdHeader": "example", "bodyLimitBytes": 1, "rateLimitPerMinute": 1, "label": "example", "runAsServiceAccountId": "example", "runAsProject": true, "toolsAllowedUnattended": [ "example" ] }'A signed request to the trigger’s receiveUrl (POST /v1/hooks/{tenantId}/{webhookId}) starts a run of its flow, as its owner: the caller, until an admin takes it over. The route mints webhookId (a random UUID). The signing secret is written first (POST /v1/secrets), and hmacSecretName names it; a model provider’s key is refused (400 provider-key-refused), and so are a texts registration’s account key (400 connection-key-refused) and an identity provider’s secret (400 identity-provider-key-refused). Where it’s read is recorded on the trigger (hmacSecretScope): the first of its project, the project’s org and the workspace that has it and that the caller administers, else the broadest they administer; the receiver reads it there only. Or generateSecret: true: the server makes it, stores it as hmacSecretName in the trigger’s own project (a name the project already has is refused, 409 secret-write-conflict), and returns it once as signingSecret. signature says how the sender signs (default: a hex HMAC-SHA256 of the raw body in X-Kindgi-Signature); deliveryIdHeader names the header whose value, with the body, dedupes deliveries. A trigger that names no projectId goes in the project its API key or session is limited to, else in the workspace’s default project. Needs write on the project and execute on the flow. toolsAllowedUnattended names the tools whose calls in its runs needn’t wait for a person’s yes, though a tool asks for one in a run no person started: naming it takes admin on the project, each id must be a tool the flow calls, and it’s audited (trigger-tools-allowed-unattended-set).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”Webhook registered.
A webhook trigger: a signed request to its receiveUrl starts a run of its flow, as its owner. The signing secret is never on it, only its name.
object
Example
{ "owner": { "kind": "user", "isProjectAccount": true }, "hmacSecretScope": { "kind": "tenant" }, "signature": { "kind": "hmac-sha256", "encoding": "hex" }, "status": "active"}A body that fails validation (bad-input), runAsProject with runAsServiceAccountId or for a trigger with no project (bad-input), or provider-key-refused: hmacSecretName is a model provider’s key, or reserved-name-prefix: it’s under the reserved kindgi. prefix. Or connection-key-refused: a secret it names is the account key of a texts connection app registration (details.secret, details.appId), which only that registration names. Use a key of its own: a new API key from the provider, stored under its own name. A copy of this one under another name reaches the same account. Or identity-provider-key-refused: a secret it names is an identity provider’s secret, an OIDC client secret or a SAML signing or decryption key (details.secret, details.identityProviderId), which only sign-in names. If one app registration serves both, give it a second secret of its own (a second client secret), store that under its own name and use that name. Or reference-out-of-scope: the flow isn’t registered in the trigger’s project, its org or the workspace, or flowVersion isn’t a version that project runs (details.issues, at /flowId, whose message names the version), and nothing is registered. Or, with generateSecret, a name the secrets store can’t write, refused before anything is stored: secret-name-invalid (a name that isn’t 1 to 255 ASCII letters, digits, ., - and _ starting with a letter, digit or _, with any . between two non-. characters, or, under kindgi dev, isn’t capital letters, digits and underscores, starts with a digit, or is KINDGI_*; the message says the rule).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}secret-write-conflict: with generateSecret, the trigger’s project already has a secret of that name (it’s never overwritten, and no trigger is left). Or runAsServiceAccountId names an unregistered account (service-account-unregistered), a project’s own account (service-account-project-owned: name it with runAsProject), or one that can’t run the flow (trigger-owner-cannot-run-target). Or, with runAsProject, the project’s own account can’t run the flow either (trigger-owner-cannot-run-target; the account stays, for the next runAsProject), or an active account someone made already has the project account’s name, project-<projectId> (service-account-name-taken: a tenant admin can unregister it). Or the route-minted webhookId collided (astronomically rare). Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}trigger-operation-unsupported: runAsProject on a runtime that can’t make a project’s own account.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/webhooks: List webhook triggers- Error code
authz-backend-unavailable - Error code
bad-input - Error code
connection-key-refused - Error code
database-busy - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
identity-provider-key-refused - Error code
provider-key-refused - Error code
rate-limit-exceeded - Error code
reference-out-of-scope - Error code
request-too-large - Error code
reserved-name-prefix - Error code
secret-name-invalid - Error code
secret-write-conflict - Error code
service-account-name-taken - Error code
service-account-project-owned - Error code
service-account-unregistered - Error code
tenant-state-unavailable - Error code
trigger-operation-unsupported - Error code
trigger-owner-cannot-run-target - Every error code