Platform · Extension Hooks
Extension Hooks
Rules attached to named points in a record's life: before or after it is saved, posted or approved, and when its status changes. A hook is a condition (the same expression language as custom rules) and one action: refuse with a message, warn, send on one of this company's webhooks, or write a log line. A hook cannot change a record or run code. New hooks start in dry run: evaluated and logged, never acting, until you switch them live. To fill in, work out, check, show or lock a field, use Custom Logic instead.
/api/platform/extension-hooksPublished as /api/v1/extension-hooksDownload specification (OpenAPI 3.1) Screen: Extension Hooks
Overview
| Package | Platform |
|---|---|
| Authentication | Bearer token: a service account's token (POST /api/auth/service-token) or, for the published path, an API key |
| Authorization | The caller's roles must hold Platform › Extension Hooks on the Roles screen: display for GET, add for POST, change for PUT, delete for DELETE; an action needs the grant of the button that runs it on the screen. |
| Table | ext.hooks · kept per company (and organisational unit where it has one) |
| Record | Read only; key id |
| Rules | The same as the screen: validation, numbering, approvals, posting, the company the caller belongs to, and the audit trail. |
API reference
11 operations. Open one for its parameters, bodies, responses and a sample request.
GET/api/platform/extension-hooksList extension hooks
Query parameters
| Name | Description | Example |
|---|---|---|
limit | Rows per page (50 by default, at most 200) | limit=100 |
offset | Rows to skip | offset=200 |
q | Free-text search over the search columns | q=acme |
sort | column:asc or column:desc, several separated by commas | sort=created_at:desc |
filter | A JSON condition or group (see the filter language), URL-encoded; any field below can be filtered and sorted | filter={"col":"status","op":"eq","value":"open"} |
<field>=<value> | Shorthand for "field is value" |
Response 200
{
"rows": [
{
"id": "3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73",
"name": "Example",
"description": "text",
"point": "Before a record is saved",
"module_key": "text",
"resource_key": "text",
"to_status": [],
"condition_expr": "text",
"action_kind": "Refuse with a message (before points only)",
"message": "text",
"message_expr": "text",
"webhook_id": "3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73",
"payload_map": {},
"mode": "text"
}
],
"count": 1
}Sample request
curl "https://demo.tranxact.ai/api/platform/extension-hooks?limit=20" \
-H "Authorization: Bearer $TOKEN"GET/api/platform/extension-hooks/{id}Read one extension hook
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
Response 200
{
"id": "3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73",
"name": "Example",
"description": "text",
"point": "Before a record is saved",
"module_key": "text",
"resource_key": "text",
"to_status": [],
"condition_expr": "text",
"action_kind": "Refuse with a message (before points only)",
"message": "text",
"message_expr": "text",
"webhook_id": "3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73",
"payload_map": {},
"mode": "text"
}404 when no record with that id is visible to the caller.
Sample request
curl "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73" \
-H "Authorization: Bearer $TOKEN"GET/api/platform/extension-hooks/vocabularyVocabulary
Response
200 with the data as JSON.
Sample request
curl "https://demo.tranxact.ai/api/platform/extension-hooks/vocabulary" \
-H "Authorization: Bearer $TOKEN"POST/api/platform/extension-hooksPost extension hooks
No body is required.
Response
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X POST "https://demo.tranxact.ai/api/platform/extension-hooks" \
-H "Authorization: Bearer $TOKEN"PUT/api/platform/extension-hooks/{id}Put extension hooks
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
No body is required.
Response
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X PUT "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73" \
-H "Authorization: Bearer $TOKEN"DELETE/api/platform/extension-hooks/{id}Delete extension hooks
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
No body is required.
Response
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X DELETE "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73" \
-H "Authorization: Bearer $TOKEN"POST/api/platform/extension-hooks/{id}/go-liveGo live
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
No body is required.
Response
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X POST "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73/go-live" \
-H "Authorization: Bearer $TOKEN"POST/api/platform/extension-hooks/{id}/dry-runDry run
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
No body is required.
Response
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X POST "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73/dry-run" \
-H "Authorization: Bearer $TOKEN"POST/api/platform/extension-hooks/{id}/testTest
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
Request body
The keys this action reads (* = required; "one of" lists the only values):
sample, recordIdResponse
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X POST "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73/test" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"sample":"value","recordId":"value"}'GET/api/platform/extension-hooks/choices/{kind}Choices
Path parameters
| Name | Type | Description |
|---|---|---|
kind | string (uuid) | The record's kind, as a list returns it. |
Response
200 with the data as JSON.
Sample request
curl "https://demo.tranxact.ai/api/platform/extension-hooks/choices/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73" \
-H "Authorization: Bearer $TOKEN"POST/api/platform/extension-hooks/{id}/copyCopy
Path parameters
| Name | Type | Description |
|---|---|---|
id | string (uuid) | The record's id, as a list returns it. |
Request body
The keys this action reads (* = required; "one of" lists the only values):
overrides, preview, withLinesResponse
200 or 201 with the record or result as JSON; a refusal is 409 or 422 with a sentence saying why.
Sample request
curl -X POST "https://demo.tranxact.ai/api/platform/extension-hooks/3f1c2a9e-5b7d-4c1e-9a2f-0d4b8e6c1a73/copy" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"overrides":"value","preview":"value","withLines":"value"}'Data model
Every field of a extension hook, as the API returns it. Field names are the JSON keys; any of them can be filtered and sorted on a list.
| Field | Type | Access | Description |
|---|---|---|---|
id | uuid | read only | Id |
org_id | uuid | read only | Org id |
name | text | read only | Name — A name people will recognise in the run log. |
description | text | read only | What it is for — Why this rule exists. |
point | text | read only | Point — When in the record's life the hook runs. Allowed: Before a record is saved After a record is saved Before a document is posted After a document is posted Before an approval is given After an approval is given Before the status changes After the status changed |
module_key | text | read only | Module key |
resource_key | text | read only | Resource key |
to_status | _text | read only | Only when moving to — For the status points: comma-separated statuses; empty means any move. |
condition_expr | text | read only | Condition — When the hook acts, e.g. total > 10000 and is_empty(project_code). Empty means always. You may use record fields, previous, changed, status, to_status, user and today. |
action_kind | text | read only | Does — Only a before hook can refuse or warn; only an after hook can send. Allowed: Refuse with a message (before points only) Warn but allow (before points only) Send on a webhook (after points only) Only write it in the run log |
message | text | read only | Message — What a person is told. {field} is replaced by the record's value. |
message_expr | text | read only | Message (as an expression) — Optional: work the message out, e.g. concat("Over budget by ", total - 10000). |
webhook_id | uuid | read only | Webhook — One of this company's outbound webhooks. It signs and screens the target like every delivery. |
payload_map | jsonb | read only | What is sent — A set of named expressions, e.g. {"number": "record_no", "total": "total"}. Empty sends the record without personal or secret fields. |
mode | text | read only | Mode |
is_active | boolean | read only | On — A hook that fails ten runs in a row is switched off with the reason; switch it on again after fixing it. |
sort_order | integer | read only | Order — Hooks at the same point run in this order. |
timeout_ms | integer | read only | Time budget (ms) — 10 to 500. A run over it is skipped and counted as an error. |
max_per_minute | integer | read only | Runs per minute — A ceiling for warnings, sends and log lines (a refusal is never throttled). |
run_count | bigint | read only | Run count |
veto_count | bigint | read only | Veto count |
error_count | bigint | read only | Error count |
consecutive_errors | integer | read only | Consecutive errors |
last_run_at | timestamp with time zone | read only | Last run at |
last_error | text | read only | Last error |
last_error_at | timestamp with time zone | read only | Last error at |
created_by | uuid | read only | Created by |
created_at | timestamp with time zone | read only | Created at |
updated_by | uuid | read only | Updated by |
updated_at | timestamp with time zone | read only | Updated at |
xf_text_1 | text | read only | Xf text 1 |
xf_text_2 | text | read only | Xf text 2 |
xf_text_3 | text | read only | Xf text 3 |
xf_text_4 | text | read only | Xf text 4 |
xf_text_5 | text | read only | Xf text 5 |
xf_num_1 | numeric | read only | Xf num 1 |
xf_num_2 | numeric | read only | Xf num 2 |
xf_num_3 | numeric | read only | Xf num 3 |
xf_date_1 | date | read only | Xf date 1 |
xf_date_2 | date | read only | Xf date 2 |
Errors
| Status | Meaning |
|---|---|
| 400 | The request could not be read: a filter that is not JSON, a bad parameter |
| 401 | No credential, or it is wrong, revoked or expired |
| 403 | The caller's roles do not hold Platform › Extension Hooks for this verb, or the address or origin is not allowed |
| 404 | No record with that id is visible to the caller |
| 409 | A conflict: a duplicate number, a document in a state that does not allow it, or a record changed or locked by someone else |
| 422 | Refused by the same validation as the screen; the error names the field and why |
Every error is JSON: {"error": "a sentence saying what was wrong"}, with field where it applies.