n8n-nodes-pilot-status 2.9.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,75 @@
2
2
 
3
3
  All notable changes to `n8n-nodes-pilot-status`.
4
4
 
5
+ ## 2.11.0 - 2026-10-28
6
+
7
+ ### Added
8
+
9
+ - **Credential: Workspace ID** (optional), sent as `x-workspace-id` for an **account key**
10
+ (`ps_account_...`); empty = header not sent, so workspace and number keys are unchanged.
11
+ The credential test calls `GET /v1/workspaces` for an account key without a Workspace ID
12
+ (it would otherwise be `400 WORKSPACE_ID_REQUIRED`), `/v1/templates` otherwise.
13
+ - **Workspace (Account Key)** resource — **Get Many** (`GET /v1/workspaces`) and **Create**
14
+ (`POST /v1/workspaces`, body exactly `{ name }`; the answer carries the new workspace's
15
+ primary key once, or `apiKey: null`).
16
+ - **Workspace API Key (Account Key)** resource — **Get Many**, **Create** (`{ name }`) and
17
+ **Revoke** over `/v1/workspaces/{workspaceId}/api-keys[/{keyId}]`.
18
+ - **Workspace Webhook** resource — the seven operations of Phone Line Webhook over
19
+ `/v1/workspace/webhooks*`, with the event `wallet.topup_paid` (opt-in: `*` stays every
20
+ phone-line event only).
21
+ - **Billing** resource:
22
+ - **Create Checkout** (`POST /v1/billing/checkout`) with **Method** `card` (default) or
23
+ `pix` (BRL only; answers `pix { transactionId, copyPaste, qrCode, expiresAt }`).
24
+ Success/Cancel URL are never sent with Pix, and `method` never with Add Card — the API
25
+ answers `400 FIELD_NOT_APPLICABLE` to either.
26
+ - **Get Top-Up** (`GET /v1/billing/topups/{id}`).
27
+ - **Create / Sync Card Setup Intent** (`POST /v1/billing/card/setup-intent`,
28
+ `.../{id}/sync`) and **Create / Sync Payment Intent** (`POST /v1/billing/payment-intents`
29
+ with `{ purpose: "wallet_topup", amount, saveCard? }` and an optional **Idempotency Key**
30
+ header; `.../{id}/sync`) — Stripe Elements.
31
+
32
+ ### Not included
33
+
34
+ - The Pilot Status Trigger does not offer `wallet.topup_paid`: like `phone_line.*`, it is
35
+ delivered by the workspace registry, which the Trigger's Automatic mode does not use.
36
+ Point a Workspace Webhook at a regular Webhook node.
37
+ - Phone lines' new `price` and `amountDue` fields: the node does not list or read phone
38
+ lines (only verification and activation audio), so there is nothing to map.
39
+
40
+ ## 2.10.0 - 2026-10-27
41
+
42
+ ### Added
43
+
44
+ - **Message → Send: Media Filename** additional field, sent as `mediaFilename` — the file
45
+ name the recipient sees for a document (1–240 chars; `/` and `\` become `_`). Works on
46
+ a direct document send and on a template whose approved header is a Document, with or
47
+ without a Media URL; any other header type is rejected with
48
+ `MEDIA_FILENAME_REQUIRES_DOCUMENT_HEADER`. With a Media URL and no Media Type, setting
49
+ it sends the media as a document instead of the `image` default.
50
+ - **Phone Line Webhook** resource — the `phone_line.*` event subscriptions, a registry
51
+ separate from the number webhooks of `/v1/webhooks`. Workspace (tenant-scoped) key only,
52
+ `phone_lines:webhooks` (ADMIN and up).
53
+ - **Create** — `POST /v1/phone-lines/webhooks` (URL, Events, optional Name). The answer
54
+ carries the `plwh_...` signing **secret, shown only this once**. Not idempotent. An
55
+ empty Name is omitted from the body.
56
+ - **Get Many** — `GET /v1/phone-lines/webhooks` → `{ webhooks, events }` as one item.
57
+ - **Get** — `GET /v1/phone-lines/webhooks/{id}`.
58
+ - **Update** — `PATCH /v1/phone-lines/webhooks/{id}`: only the fields added under Update
59
+ Fields (Name, URL, Events, Active) are sent; Active off pauses the webhook.
60
+ - **Delete** — `DELETE /v1/phone-lines/webhooks/{id}`, also deletes the delivery history.
61
+ - **Get Deliveries** — `GET /v1/phone-lines/webhooks/{id}/deliveries?limit=` (1–200,
62
+ default 50), never the payload.
63
+ - **Get Delivery** — `GET /v1/phone-lines/webhooks/{id}/deliveries/{deliveryId}`, with
64
+ the exact signed `payload` string; a `phone_line.code_received` payload carries the
65
+ activation code.
66
+ - Ids are URL-encoded in the path.
67
+
68
+ ### Not included
69
+
70
+ - The Pilot Status Trigger still does not offer `phone_line.*` events: its Automatic mode
71
+ registers in the numbers registry, which never delivers them. Point a phone-line webhook
72
+ created here at a regular Webhook node instead.
73
+
5
74
  ## 2.9.0 - 2026-10-25
6
75
 
7
76
  ### Added
package/README.md CHANGED
@@ -33,10 +33,11 @@ To use the Pilot Status node, you need an **API Key**.
33
33
  2. Create a new API Key.
34
34
  3. In n8n, add a new **Pilot Status API** credential and paste your API Key.
35
35
 
36
- The credential has two optional fields:
36
+ The credential has three optional fields:
37
37
 
38
38
  - **Base URL** — API root without `/v1`. Leave it alone unless you are pointing the workflow at a staging environment. It is used by the node, by the credential test *and* by the dropdowns (templates, groups, newsletters), which used to always hit production.
39
39
  - **WhatsApp Number ID** — sent as `x-whatsapp-number-id` on every request. Fill it in when your key is **tenant-scoped** and the operation is per-number; a **number-scoped** key already carries its number, and the header is ignored.
40
+ - **Workspace ID** — only for an **account key** (`ps_account_...`, created in *Profile → API*): sent as `x-workspace-id` to name the workspace the key acts on (an id from **Workspace (Account Key) → Get Many**). Without it, every workspace operation answers `400 WORKSPACE_ID_REQUIRED`; a workspace the key's user is not an active member of answers `403 WORKSPACE_MEMBERSHIP_REQUIRED`. Leave it empty for a workspace or number key. With an account key and no Workspace ID, the credential test calls `GET /v1/workspaces` instead of `/v1/templates`.
40
41
 
41
42
  *Note: TEST keys will only send messages to the WhatsApp number registered in your Pilot Status Profile.*
42
43
 
@@ -199,7 +200,45 @@ Requires a **workspace (tenant-scoped) API key** — a number-scoped key is refu
199
200
  - **Binary Field** (default): the name of a binary property of the input item (e.g. the output of *Read/Write Files from Disk*, *HTTP Request* or a form upload). It is sent as `data:<mimeType>;base64,<data>`.
200
201
  - **Data URI**: a ready `data:<mime>;base64,...` string.
201
202
 
202
- > Phone-line webhooks (`phone_line.*`) live in a **separate registry** with their own `plwh_...` secret, and the **Pilot Status Trigger does not register them**: its Automatic mode creates subscriptions in the numbers webhook registry, which never delivers `phone_line.*`. To receive them, create the phone-line webhook in the dashboard and point it at a regular n8n *Webhook* node (verify `x-pilot-status-signature`, HMAC-SHA256 of the raw body).
203
+ > Phone-line webhooks (`phone_line.*`) live in a **separate registry** with their own `plwh_...` secret, and the **Pilot Status Trigger does not register them**: its Automatic mode creates subscriptions in the numbers webhook registry, which never delivers `phone_line.*`. To receive them, create the phone-line webhook (in the dashboard or with **Phone Line Webhook → Create** below) and point it at a regular n8n *Webhook* node (verify `x-pilot-status-signature`, HMAC-SHA256 of the raw body).
204
+
205
+ ### 13. Phone Line Webhook (`phone_line.*` event subscriptions)
206
+
207
+ A registry **separate** from the number webhooks of `/v1/webhooks`: a phone-line webhook receives only `phone_line.*` events, and never a number event. Requires a **workspace (tenant-scoped) API key** with `phone_lines:webhooks` (**ADMIN** and up). Errors come back as `{ error, code }`; another workspace's webhook (or an unknown id) is `404 WEBHOOK_NOT_FOUND`.
208
+
209
+ Events: `phone_line.purchased`, `phone_line.audio_received`, `phone_line.code_received`, `phone_line.code_failed`, `phone_line.renewed`, `phone_line.payment_failed`, `phone_line.suspended`, `phone_line.returned`, `phone_line.canceled`, `phone_line.verification_updated`, or `*` (**All Phone Line Events**, including future ones).
210
+
211
+ - **Create:** `POST /v1/phone-lines/webhooks` with **URL** (https, public — an internal or private destination is `400 WEBHOOK_URL_REFUSED`), **Events** (at least one) and an optional **Name** (max 100 characters; left empty, the URL's hostname). Answers `201 { webhook: { id, name, url, events, active, secret, createdAt } }`. ⛔ The `plwh_...` **secret is shown only in this response, never again** — store it right away; it signs every delivery. **Not idempotent**: running it twice creates two webhooks with two secrets. An empty Name is left out of the body, never sent as `""` or `null`.
212
+ - **Get Many:** `GET /v1/phone-lines/webhooks` → `{ webhooks, events }` as **one item** (like every other Get Many of this node): `webhooks` oldest first, each `{ id, name, url, events, active, lastDeliveryAt, lastStatusCode, createdAt }`; `events` is the subscribable catalogue. Never the secrets.
213
+ - **Get:** `GET /v1/phone-lines/webhooks/{id}` → `{ webhook }` (same shape, no secret).
214
+ - **Update:** `PATCH /v1/phone-lines/webhooks/{id}` with only the fields added under **Update Fields** — **Name**, **URL**, **Events** (replaces the list) and **Active** (off **pauses** the webhook without deleting it). Fields not added stay unchanged; a blank Name/URL or an empty Events selection is ignored rather than sent. Answers `{ webhook }`; the secret does not change.
215
+ - **Delete:** `DELETE /v1/phone-lines/webhooks/{id}` → `{ ok: true }`. ⚠️ Also deletes the webhook's **delivery history**. No undo.
216
+ - **Get Deliveries:** `GET /v1/phone-lines/webhooks/{id}/deliveries?limit=` (**Limit** 1–200, default 50) → `{ deliveries }`, newest first, each `{ id, event, status (PENDING|DELIVERED|FAILED), attempts, responseStatus, lastError, createdAt, deliveredAt }`. Never the payload.
217
+ - **Get Delivery:** `GET /v1/phone-lines/webhooks/{id}/deliveries/{deliveryId}` → `{ delivery }` with `durationMs`, `responseBody` and `payload` — the **exact signed JSON string** that was sent (parse it yourself; it is a string so the signature can be re-checked byte for byte). ⛔ A `phone_line.code_received` payload carries the **activation code** — treat this output as a credential.
218
+
219
+ ### 14. Workspace Webhook (workspace events: phone lines + `wallet.topup_paid`)
220
+
221
+ `/v1/workspace/webhooks*` — the **same rows** as Phone Line Webhook (a webhook created on one shows on the other, same `plwh_...` secret and signature), with a wider event set: every `phone_line.*` event plus **`wallet.topup_paid`** (a wallet top-up, Pix or card, was credited: `data` = `{ orderId, amount, currency, method, provider, paidAt, balance }`). ⚠️ `*` (**All Phone Line Events**) means every *phone-line* event — it does **not** include `wallet.topup_paid`, which is opt-in: select it by name. Same seven operations, fields and rules as Phone Line Webhook (Create shows the secret once and is not idempotent; Update sends only the added fields; Get Deliveries `limit` 1–200; Get Delivery returns the exact signed `payload`). Tenant-scoped credential; `phone_lines:webhooks` (**ADMIN** and up).
222
+
223
+ ### 15. Billing (`/v1/billing/*`)
224
+
225
+ Tenant-scoped credential. Nothing here charges by itself — a human pays the hosted page or the Pix, and a Stripe intent is confirmed by Stripe.js in a browser.
226
+
227
+ - **Create Checkout:** `POST /v1/billing/checkout`. **Purpose** *Wallet Top-Up* (needs **Amount**, in the workspace currency) or *Add Card*. For a top-up, **Method** *Card* (default) answers `{ url, purpose, method, orderId, amount, currency }` — a hosted Stripe page; *Pix* (BRL workspaces only, else `400 PIX_NOT_ELIGIBLE`) answers `{ purpose, method: "pix", orderId, status: "pending", amount, currency, pix: { transactionId, copyPaste, qrCode, expiresAt } }` — show the copy-and-paste code or the QR to the payer. Success/Cancel URL are card-only and are never sent with Pix (the API would answer `400 FIELD_NOT_APPLICABLE`); `method` is never sent with Add Card.
228
+ - **Get Top-Up:** `GET /v1/billing/topups/{id}` → `{ topup: { id, status (pending|paid|expired|failed), amount, currency, method, provider, createdAt, paidAt, expiresAt } }`. Read-only; poll it after a checkout or payment intent. `404 TOPUP_NOT_FOUND`.
229
+ - **Create Card Setup Intent:** `POST /v1/billing/card/setup-intent` → `{ clientSecret, setupIntentId, publishableKey }` for the Stripe Payment Element (`stripe.confirmSetup`). OWNER (`billing:payment_method:manage`).
230
+ - **Sync Card Setup Intent:** `POST /v1/billing/card/setup-intent/{id}/sync` → `{ setupIntentId, status, saved, card }` — makes the confirmed card the workspace's saved card now. Idempotent.
231
+ - **Create Payment Intent:** `POST /v1/billing/payment-intents` with `{ purpose: "wallet_topup", amount, saveCard? }` → `{ clientSecret, paymentIntentId, orderId, amount, currency, publishableKey }` for `stripe.confirmPayment`. Optional **Idempotency Key** (header `Idempotency-Key`): a retry within 24 h with the same key and body gets the same intent (`Idempotent-Replayed: true`); same key with another body → `409 IDEMPOTENCY_KEY_REUSED`, first call still running → `409 IDEMPOTENCY_KEY_IN_USE`.
232
+ - **Sync Payment Intent:** `POST /v1/billing/payment-intents/{id}/sync` → `{ paymentIntentId, status, orderId, orderStatus, amount, currency, credited, balance, cardSaved }` — credits the wallet exactly once; never charges.
233
+ - ⛔ Never log a `clientSecret`. `503 PAYMENTS_NOT_CONFIGURED` when card payments are unavailable.
234
+
235
+ ### 16. Workspace and Workspace API Key (account key only)
236
+
237
+ These need an **account key** (`ps_account_...`); any other key or an OAuth token answers `403 ACCOUNT_KEY_REQUIRED`. The credential's Workspace ID is ignored here.
238
+
239
+ - **Workspace (Account Key) → Get Many:** `GET /v1/workspaces` → `{ data: [{ id, name, role, plan, createdAt }] }` — the workspaces the key's user is an active member of.
240
+ - **Workspace (Account Key) → Create:** `POST /v1/workspaces` with `{ name }` → `201 { id, name, plan, createdAt, role: "OWNER", apiKey }`, `apiKey` being the new workspace's primary `ps_workspace_...` key, **shown only here** — or `null` if minting failed (the workspace exists: mint a key with Workspace API Key → Create, do not create again). `409 WORKSPACE_LIMIT_REACHED`.
241
+ - **Workspace API Key → Get Many / Create / Revoke:** `GET|POST /v1/workspaces/{workspaceId}/api-keys`, `DELETE .../api-keys/{keyId}`, with the user's live role (ADMIN and up). Create mints a named key (`apiKey.key` shown once; `409 WORKSPACE_KEY_LIMIT_REACHED`); Revoke answers `{ id, revokedAt }` (`409 PRIMARY_KEY_NOT_REVOCABLE` for the primary, `404 API_KEY_NOT_FOUND`).
203
242
 
204
243
  ---
205
244
 
@@ -36,6 +36,14 @@ class PilotStatusApi {
36
36
  required: false,
37
37
  description: 'Sent as x-whatsapp-number-id on every request. Required when the key is tenant-scoped and the operation is per-number (Chatwoot, webhook logs); leave empty for a number-scoped key, which already carries its number.',
38
38
  },
39
+ {
40
+ displayName: 'Workspace ID',
41
+ name: 'workspaceId',
42
+ type: 'string',
43
+ default: '',
44
+ required: false,
45
+ description: 'Only for an ACCOUNT key (ps_account_…, created in Profile → API): sent as x-workspace-id on every request to name the workspace the key acts on (an id from Workspace → Get Many). Without it, every workspace operation answers 400 WORKSPACE_ID_REQUIRED; a workspace the key\'s user is not an active member of answers 403 WORKSPACE_MEMBERSHIP_REQUIRED. The Workspace and Workspace API Key resources need an account key and ignore this field; any other key there answers 403 ACCOUNT_KEY_REQUIRED. Leave empty for a workspace or number key.',
46
+ },
39
47
  ];
40
48
  this.authenticate = {
41
49
  type: 'generic',
@@ -47,13 +55,18 @@ class PilotStatusApi {
47
55
  // `x-whatsapp-number-id: `, which the server would read as a header
48
56
  // that is present and invalid.
49
57
  'x-whatsapp-number-id': '={{$credentials.whatsappNumberId || undefined}}',
58
+ // Same rule: empty = header omitted, so workspace and number keys are unchanged.
59
+ 'x-workspace-id': '={{$credentials.workspaceId || undefined}}',
50
60
  },
51
61
  },
52
62
  };
53
63
  this.test = {
54
64
  request: {
55
65
  baseURL: '={{($credentials.baseUrl || "https://pilotstatus.com.br").replace(/\\/+$/, "") + "/v1"}}',
56
- url: '/templates',
66
+ // An account key with no Workspace ID names no workspace, so /templates would be
67
+ // 400 WORKSPACE_ID_REQUIRED for a valid key: it is tested on /workspaces instead,
68
+ // the one route it reaches without the header.
69
+ url: '={{String($credentials.apiKey || "").startsWith("ps_account_") && !$credentials.workspaceId ? "/workspaces" : "/templates"}}',
57
70
  },
58
71
  };
59
72
  }
@@ -44,6 +44,71 @@ export declare function resolvePhoneLineDocument(ctx: IExecuteSingleFunctions):
44
44
  export declare function phoneLineStartVerificationPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
45
45
  /** Submit Document: the body is exactly `{ document }`. No Idempotency-Key on this route. */
46
46
  export declare function phoneLineSubmitDocumentPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
47
+ /**
48
+ * The events a phone-line webhook subscribes to (`/v1/phone-lines/webhooks`). A registry of
49
+ * its own: these never reach the number webhooks of `/v1/webhooks`, and the number events
50
+ * never reach these. `*` subscribes to every phone-line event, present and future.
51
+ */
52
+ export declare const PHONE_LINE_WEBHOOK_EVENT_OPTIONS: INodePropertyOptions[];
53
+ /**
54
+ * Phone Line Webhook → Create: builds the WHOLE `POST /v1/phone-lines/webhooks` body.
55
+ *
56
+ * The API is strict: an unknown field is 400 UNKNOWN_FIELDS and a `null` or wrong-typed
57
+ * one is 400 INVALID_FIELD_TYPE. So the body carries exactly `url`, `events` and — only when
58
+ * it is not blank — `name` (a missing name becomes the URL's hostname on the server).
59
+ */
60
+ export declare function phoneLineWebhookCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
61
+ /**
62
+ * Phone Line Webhook → Update: builds the `PATCH /v1/phone-lines/webhooks/{id}` body from
63
+ * the "Update Fields" collection. Only the fields the user ADDED are sent — an absent field
64
+ * is left unchanged by the API — and a blank text field or an empty event list is treated
65
+ * as "not added" rather than sent (the API would refuse an empty list with 400, and a
66
+ * `null` with 400 INVALID_FIELD_TYPE). `active: false` is sent as is: it pauses the webhook.
67
+ */
68
+ export declare function phoneLineWebhookUpdatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
69
+ /**
70
+ * The events a WORKSPACE webhook subscribes to (`/v1/workspace/webhooks`): the phone-line
71
+ * events plus the workspace's own (`wallet.topup_paid`). Same table, secret and signature as
72
+ * the phone-line webhooks — a row made on either surface shows on both.
73
+ *
74
+ * ⚠️ `*` keeps the meaning it always had in this table: every PHONE-LINE event. Wallet
75
+ * events are OPT-IN — a `*` row never receives `wallet.topup_paid`; select it by name.
76
+ */
77
+ export declare const WORKSPACE_WEBHOOK_EVENT_OPTIONS: INodePropertyOptions[];
78
+ /**
79
+ * Workspace Webhook → Create: the WHOLE `POST /v1/workspace/webhooks` body. Same strictness as
80
+ * the phone-line twin: exactly `url`, `events` and — only when not blank — `name`.
81
+ */
82
+ export declare function workspaceWebhookCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
83
+ /**
84
+ * Workspace Webhook → Update: the `PATCH /v1/workspace/webhooks/{id}` body — only the fields
85
+ * added under "Update Fields", blanks and empty lists left out, `active: false` sent as is.
86
+ */
87
+ export declare function workspaceWebhookUpdatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
88
+ /**
89
+ * Workspace → Create: the body is exactly `{ name }` — `POST /v1/workspaces` refuses any other
90
+ * field with 400 UNKNOWN_FIELDS.
91
+ */
92
+ export declare function workspaceCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
93
+ /** Workspace API Key → Create: the body is exactly `{ name }`. */
94
+ export declare function workspaceApiKeyCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
95
+ /**
96
+ * Billing → Create Checkout: the `POST /v1/billing/checkout` body.
97
+ *
98
+ * - Add Card: `{ purpose, successUrl?, cancelUrl? }` — never `method` (400 FIELD_NOT_APPLICABLE).
99
+ * - Wallet Top-Up: `{ purpose, amount, method }`; with method `card` also the redirect URLs.
100
+ * With `pix` they are NEVER sent, even if a value lingers in the hidden fields: a Pix has no
101
+ * redirect and the API answers 400 FIELD_NOT_APPLICABLE to them.
102
+ *
103
+ * Blank URLs are left out instead of sent empty.
104
+ */
105
+ export declare function billingCheckoutPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
106
+ /**
107
+ * Billing → Create Payment Intent: the body is `{ purpose: "wallet_topup", amount }` plus
108
+ * `saveCard` only when on (the route refuses unknown fields). The optional Idempotency Key goes
109
+ * out as the `Idempotency-Key` HEADER; blank = not sent (every run creates a new intent).
110
+ */
111
+ export declare function billingPaymentIntentPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
47
112
  /**
48
113
  * Lead Form → Update: builds the WHOLE `PUT /v1/lead-pages/{id}/forms/{formId}` body.
49
114
  *
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PilotStatus = exports.DEFAULT_BASE_URL = exports.FLOW_CATEGORY_OPTIONS = exports.GO_TRISTATE = void 0;
3
+ exports.PilotStatus = exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS = exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS = exports.DEFAULT_BASE_URL = exports.FLOW_CATEGORY_OPTIONS = exports.GO_TRISTATE = void 0;
4
4
  exports.apiBaseUrl = apiBaseUrl;
5
5
  exports.resolvePhoneLineDocument = resolvePhoneLineDocument;
6
6
  exports.phoneLineStartVerificationPreSend = phoneLineStartVerificationPreSend;
7
7
  exports.phoneLineSubmitDocumentPreSend = phoneLineSubmitDocumentPreSend;
8
+ exports.phoneLineWebhookCreatePreSend = phoneLineWebhookCreatePreSend;
9
+ exports.phoneLineWebhookUpdatePreSend = phoneLineWebhookUpdatePreSend;
10
+ exports.workspaceWebhookCreatePreSend = workspaceWebhookCreatePreSend;
11
+ exports.workspaceWebhookUpdatePreSend = workspaceWebhookUpdatePreSend;
12
+ exports.workspaceCreatePreSend = workspaceCreatePreSend;
13
+ exports.workspaceApiKeyCreatePreSend = workspaceApiKeyCreatePreSend;
14
+ exports.billingCheckoutPreSend = billingCheckoutPreSend;
15
+ exports.billingPaymentIntentPreSend = billingPaymentIntentPreSend;
8
16
  exports.leadFormConfigPreSend = leadFormConfigPreSend;
9
17
  exports.parseContentDispositionFileName = parseContentDispositionFileName;
10
18
  exports.phoneLineAudioToBinary = phoneLineAudioToBinary;
@@ -110,6 +118,237 @@ async function phoneLineSubmitDocumentPreSend(requestOptions) {
110
118
  ensureObjectBody(requestOptions).document = await resolvePhoneLineDocument(this);
111
119
  return requestOptions;
112
120
  }
121
+ /**
122
+ * The events a phone-line webhook subscribes to (`/v1/phone-lines/webhooks`). A registry of
123
+ * its own: these never reach the number webhooks of `/v1/webhooks`, and the number events
124
+ * never reach these. `*` subscribes to every phone-line event, present and future.
125
+ */
126
+ exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS = [
127
+ { name: 'All Phone Line Events', value: '*', description: 'Every phone_line.* event, including future ones' },
128
+ { name: 'Activation Audio Received', value: 'phone_line.audio_received' },
129
+ {
130
+ name: 'Activation Code Received',
131
+ value: 'phone_line.code_received',
132
+ description: 'The payload carries the activation code — treat it as a credential',
133
+ },
134
+ { name: 'Activation Code Failed', value: 'phone_line.code_failed' },
135
+ { name: 'Line Canceled', value: 'phone_line.canceled' },
136
+ { name: 'Line Payment Failed', value: 'phone_line.payment_failed' },
137
+ { name: 'Line Purchased', value: 'phone_line.purchased' },
138
+ { name: 'Line Renewed', value: 'phone_line.renewed' },
139
+ { name: 'Line Returned', value: 'phone_line.returned' },
140
+ { name: 'Line Suspended', value: 'phone_line.suspended' },
141
+ { name: 'Verification Updated', value: 'phone_line.verification_updated' },
142
+ ];
143
+ /**
144
+ * A multiOptions value as a clean list. An expression may hand over a comma-separated
145
+ * string instead of an array; blanks and duplicates are dropped.
146
+ */
147
+ function toEventList(raw) {
148
+ const list = Array.isArray(raw) ? raw : typeof raw === 'string' ? raw.split(',') : [];
149
+ return [...new Set(list.map((e) => String(e).trim()).filter((e) => e !== ''))];
150
+ }
151
+ /**
152
+ * Phone Line Webhook → Create: builds the WHOLE `POST /v1/phone-lines/webhooks` body.
153
+ *
154
+ * The API is strict: an unknown field is 400 UNKNOWN_FIELDS and a `null` or wrong-typed
155
+ * one is 400 INVALID_FIELD_TYPE. So the body carries exactly `url`, `events` and — only when
156
+ * it is not blank — `name` (a missing name becomes the URL's hostname on the server).
157
+ */
158
+ async function phoneLineWebhookCreatePreSend(requestOptions) {
159
+ var _a, _b;
160
+ const url = String((_a = this.getNodeParameter('phoneLineWebhookUrl', '')) !== null && _a !== void 0 ? _a : '').trim();
161
+ if (!url)
162
+ throw new Error('Pilot Status: "URL" is required to create a phone line webhook.');
163
+ const events = toEventList(this.getNodeParameter('phoneLineWebhookEvents', []));
164
+ if (events.length === 0) {
165
+ throw new Error('Pilot Status: choose at least one event in "Events" (or "All Phone Line Events") to create a phone line webhook.');
166
+ }
167
+ const body = { url, events };
168
+ const name = String((_b = this.getNodeParameter('phoneLineWebhookName', '')) !== null && _b !== void 0 ? _b : '').trim();
169
+ if (name)
170
+ body.name = name;
171
+ requestOptions.body = body;
172
+ return requestOptions;
173
+ }
174
+ /**
175
+ * Phone Line Webhook → Update: builds the `PATCH /v1/phone-lines/webhooks/{id}` body from
176
+ * the "Update Fields" collection. Only the fields the user ADDED are sent — an absent field
177
+ * is left unchanged by the API — and a blank text field or an empty event list is treated
178
+ * as "not added" rather than sent (the API would refuse an empty list with 400, and a
179
+ * `null` with 400 INVALID_FIELD_TYPE). `active: false` is sent as is: it pauses the webhook.
180
+ */
181
+ async function phoneLineWebhookUpdatePreSend(requestOptions) {
182
+ const raw = this.getNodeParameter('phoneLineWebhookUpdateFields', {});
183
+ const fields = raw && typeof raw === 'object' ? raw : {};
184
+ const body = {};
185
+ const name = typeof fields.name === 'string' ? fields.name.trim() : '';
186
+ if (name)
187
+ body.name = name;
188
+ const url = typeof fields.url === 'string' ? fields.url.trim() : '';
189
+ if (url)
190
+ body.url = url;
191
+ if (fields.events !== undefined) {
192
+ const events = toEventList(fields.events);
193
+ if (events.length > 0)
194
+ body.events = events;
195
+ }
196
+ if (typeof fields.active === 'boolean')
197
+ body.active = fields.active;
198
+ if (Object.keys(body).length === 0) {
199
+ throw new Error('Pilot Status: add at least one field under "Update Fields" (Name, URL, Events or Active) to update a phone line webhook.');
200
+ }
201
+ requestOptions.body = body;
202
+ return requestOptions;
203
+ }
204
+ /**
205
+ * The events a WORKSPACE webhook subscribes to (`/v1/workspace/webhooks`): the phone-line
206
+ * events plus the workspace's own (`wallet.topup_paid`). Same table, secret and signature as
207
+ * the phone-line webhooks — a row made on either surface shows on both.
208
+ *
209
+ * ⚠️ `*` keeps the meaning it always had in this table: every PHONE-LINE event. Wallet
210
+ * events are OPT-IN — a `*` row never receives `wallet.topup_paid`; select it by name.
211
+ */
212
+ exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS = [
213
+ {
214
+ name: 'All Phone Line Events',
215
+ value: '*',
216
+ description: 'Every phone_line.* event, including future ones. Does NOT include Wallet Top-Up Paid.',
217
+ },
218
+ ...exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS.filter((o) => o.value !== '*'),
219
+ {
220
+ name: 'Wallet Top-Up Paid',
221
+ value: 'wallet.topup_paid',
222
+ description: 'A wallet top-up (Pix or card) was credited: data has orderId, amount, currency, method, provider, paidAt and balance. Opt-in: "*" does not include it.',
223
+ },
224
+ ];
225
+ /**
226
+ * Workspace Webhook → Create: the WHOLE `POST /v1/workspace/webhooks` body. Same strictness as
227
+ * the phone-line twin: exactly `url`, `events` and — only when not blank — `name`.
228
+ */
229
+ async function workspaceWebhookCreatePreSend(requestOptions) {
230
+ var _a, _b;
231
+ const url = String((_a = this.getNodeParameter('workspaceWebhookUrl', '')) !== null && _a !== void 0 ? _a : '').trim();
232
+ if (!url)
233
+ throw new Error('Pilot Status: "URL" is required to create a workspace webhook.');
234
+ const events = toEventList(this.getNodeParameter('workspaceWebhookEvents', []));
235
+ if (events.length === 0) {
236
+ throw new Error('Pilot Status: choose at least one event in "Events" to create a workspace webhook.');
237
+ }
238
+ const body = { url, events };
239
+ const name = String((_b = this.getNodeParameter('workspaceWebhookName', '')) !== null && _b !== void 0 ? _b : '').trim();
240
+ if (name)
241
+ body.name = name;
242
+ requestOptions.body = body;
243
+ return requestOptions;
244
+ }
245
+ /**
246
+ * Workspace Webhook → Update: the `PATCH /v1/workspace/webhooks/{id}` body — only the fields
247
+ * added under "Update Fields", blanks and empty lists left out, `active: false` sent as is.
248
+ */
249
+ async function workspaceWebhookUpdatePreSend(requestOptions) {
250
+ const raw = this.getNodeParameter('workspaceWebhookUpdateFields', {});
251
+ const fields = raw && typeof raw === 'object' ? raw : {};
252
+ const body = {};
253
+ const name = typeof fields.name === 'string' ? fields.name.trim() : '';
254
+ if (name)
255
+ body.name = name;
256
+ const url = typeof fields.url === 'string' ? fields.url.trim() : '';
257
+ if (url)
258
+ body.url = url;
259
+ if (fields.events !== undefined) {
260
+ const events = toEventList(fields.events);
261
+ if (events.length > 0)
262
+ body.events = events;
263
+ }
264
+ if (typeof fields.active === 'boolean')
265
+ body.active = fields.active;
266
+ if (Object.keys(body).length === 0) {
267
+ throw new Error('Pilot Status: add at least one field under "Update Fields" (Name, URL, Events or Active) to update a workspace webhook.');
268
+ }
269
+ requestOptions.body = body;
270
+ return requestOptions;
271
+ }
272
+ /** A required, trimmed `name` for the account-level creates (`{ name }` is the whole body). */
273
+ function requiredName(param, what) {
274
+ var _a;
275
+ const name = String((_a = this.getNodeParameter(param, '')) !== null && _a !== void 0 ? _a : '').trim();
276
+ if (!name)
277
+ throw new Error(`Pilot Status: "Name" is required to create ${what}.`);
278
+ return name;
279
+ }
280
+ /**
281
+ * Workspace → Create: the body is exactly `{ name }` — `POST /v1/workspaces` refuses any other
282
+ * field with 400 UNKNOWN_FIELDS.
283
+ */
284
+ async function workspaceCreatePreSend(requestOptions) {
285
+ requestOptions.body = { name: requiredName.call(this, 'workspaceName', 'a workspace') };
286
+ return requestOptions;
287
+ }
288
+ /** Workspace API Key → Create: the body is exactly `{ name }`. */
289
+ async function workspaceApiKeyCreatePreSend(requestOptions) {
290
+ requestOptions.body = { name: requiredName.call(this, 'workspaceApiKeyName', 'a workspace API key') };
291
+ return requestOptions;
292
+ }
293
+ /** A positive finite amount, or a clear error before the round trip (the API's INVALID_AMOUNT). */
294
+ function positiveAmount(raw, what) {
295
+ const amount = Number(raw);
296
+ if (!Number.isFinite(amount) || amount <= 0) {
297
+ throw new Error(`Pilot Status: "Amount" must be a positive number to ${what}.`);
298
+ }
299
+ return amount;
300
+ }
301
+ /**
302
+ * Billing → Create Checkout: the `POST /v1/billing/checkout` body.
303
+ *
304
+ * - Add Card: `{ purpose, successUrl?, cancelUrl? }` — never `method` (400 FIELD_NOT_APPLICABLE).
305
+ * - Wallet Top-Up: `{ purpose, amount, method }`; with method `card` also the redirect URLs.
306
+ * With `pix` they are NEVER sent, even if a value lingers in the hidden fields: a Pix has no
307
+ * redirect and the API answers 400 FIELD_NOT_APPLICABLE to them.
308
+ *
309
+ * Blank URLs are left out instead of sent empty.
310
+ */
311
+ async function billingCheckoutPreSend(requestOptions) {
312
+ var _a, _b;
313
+ const purpose = String(this.getNodeParameter('billingPurpose', 'wallet_topup'));
314
+ const body = { purpose };
315
+ let withUrls = true;
316
+ if (purpose === 'wallet_topup') {
317
+ body.amount = positiveAmount(this.getNodeParameter('billingAmount', 0), 'top up the wallet');
318
+ const method = String(this.getNodeParameter('billingMethod', 'card'));
319
+ body.method = method;
320
+ withUrls = method !== 'pix';
321
+ }
322
+ if (withUrls) {
323
+ const successUrl = String((_a = this.getNodeParameter('billingSuccessUrl', '')) !== null && _a !== void 0 ? _a : '').trim();
324
+ if (successUrl)
325
+ body.successUrl = successUrl;
326
+ const cancelUrl = String((_b = this.getNodeParameter('billingCancelUrl', '')) !== null && _b !== void 0 ? _b : '').trim();
327
+ if (cancelUrl)
328
+ body.cancelUrl = cancelUrl;
329
+ }
330
+ requestOptions.body = body;
331
+ return requestOptions;
332
+ }
333
+ /**
334
+ * Billing → Create Payment Intent: the body is `{ purpose: "wallet_topup", amount }` plus
335
+ * `saveCard` only when on (the route refuses unknown fields). The optional Idempotency Key goes
336
+ * out as the `Idempotency-Key` HEADER; blank = not sent (every run creates a new intent).
337
+ */
338
+ async function billingPaymentIntentPreSend(requestOptions) {
339
+ var _a, _b;
340
+ const body = {
341
+ purpose: 'wallet_topup',
342
+ amount: positiveAmount(this.getNodeParameter('billingAmount', 0), 'create a payment intent'),
343
+ };
344
+ if (this.getNodeParameter('billingSaveCard', false) === true)
345
+ body.saveCard = true;
346
+ requestOptions.body = body;
347
+ const key = String((_a = this.getNodeParameter('billingIdempotencyKey', '')) !== null && _a !== void 0 ? _a : '').trim();
348
+ if (key)
349
+ requestOptions.headers = { ...((_b = requestOptions.headers) !== null && _b !== void 0 ? _b : {}), 'Idempotency-Key': key };
350
+ return requestOptions;
351
+ }
113
352
  /**
114
353
  * Lead Form → Update: builds the WHOLE `PUT /v1/lead-pages/{id}/forms/{formId}` body.
115
354
  *
@@ -347,6 +586,11 @@ class PilotStatus {
347
586
  { name: 'Remote Pairing', value: 'remotePairing' },
348
587
  { name: 'Call', value: 'call' },
349
588
  { name: 'Phone Line', value: 'phoneLine' },
589
+ { name: 'Phone Line Webhook', value: 'phoneLineWebhook' },
590
+ { name: 'Workspace Webhook', value: 'workspaceWebhook' },
591
+ { name: 'Billing', value: 'billing' },
592
+ { name: 'Workspace (Account Key)', value: 'workspace' },
593
+ { name: 'Workspace API Key (Account Key)', value: 'workspaceApiKey' },
350
594
  ],
351
595
  default: 'message',
352
596
  },
@@ -752,6 +996,14 @@ class PilotStatus {
752
996
  default: 'image',
753
997
  description: 'Type of media being attached. Audio arrives as an audio file on official (Meta) numbers and as a voice note on unofficial numbers; Voice Note arrives as a voice note on all numbers. Audio and Voice Note cannot be combined with a template, and Audio takes no caption. Sticker takes no caption either and must be an image/webp file (static up to 100 KB, animated up to 500 KB).',
754
998
  },
999
+ {
1000
+ displayName: 'Media Filename',
1001
+ name: 'mediaFilename',
1002
+ type: 'string',
1003
+ default: '',
1004
+ placeholder: 'invoice-1234.pdf',
1005
+ description: 'File name the recipient sees for a document (1–240 characters; "/" and "\\" become "_"). Works on a direct document send (Media URL with Media Type Document, no template or text) and on a template whose approved header is a Document, with or without a Media URL. Any other header type is rejected with MEDIA_FILENAME_REQUIRES_DOCUMENT_HEADER. When set with a Media URL and no Media Type, the media is sent as a document.',
1006
+ },
755
1007
  {
756
1008
  displayName: 'Buttons (JSON)',
757
1009
  name: 'buttons',
@@ -935,9 +1187,20 @@ class PilotStatus {
935
1187
  name: 'mediaTypeNormalized',
936
1188
  type: 'hidden',
937
1189
  displayOptions: { show: { resource: ['message'], operation: ['send'] } },
938
- default: '={{ $parameter.additionalFields?.media ? ($parameter.additionalFields.mediaType || "image") : undefined }}',
1190
+ // A file name only makes sense on a document, so it flips the default kind:
1191
+ // "image" would make the API reject the send.
1192
+ default: '={{ $parameter.additionalFields?.media ? ($parameter.additionalFields.mediaType || ($parameter.additionalFields.mediaFilename ? "document" : "image")) : undefined }}',
939
1193
  routing: { send: { type: 'body', property: 'mediaType' } },
940
1194
  },
1195
+ {
1196
+ displayName: 'Media Filename',
1197
+ name: 'mediaFilenameNormalized',
1198
+ type: 'hidden',
1199
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
1200
+ // Also valid WITHOUT a Media URL: a template with a DOCUMENT header names its file.
1201
+ default: '={{ $parameter.additionalFields?.mediaFilename || undefined }}',
1202
+ routing: { send: { type: 'body', property: 'mediaFilename' } },
1203
+ },
941
1204
  {
942
1205
  displayName: 'Buttons',
943
1206
  name: 'buttonsNormalized',
@@ -3074,6 +3337,697 @@ class PilotStatus {
3074
3337
  default: 'data',
3075
3338
  required: true,
3076
3339
  },
3340
+ // ----------------------------------
3341
+ // Phone Line Webhook Operations (/v1/phone-lines/webhooks) — a registry SEPARATE from the
3342
+ // number webhooks of /v1/webhooks: these receive phone_line.* events only. TENANT-SCOPED
3343
+ // API key only; permission phone_lines:webhooks (ADMIN and up).
3344
+ // ----------------------------------
3345
+ {
3346
+ displayName: 'Operation',
3347
+ name: 'operation',
3348
+ type: 'options',
3349
+ noDataExpression: true,
3350
+ displayOptions: { show: { resource: ['phoneLineWebhook'] } },
3351
+ options: [
3352
+ {
3353
+ name: 'Create',
3354
+ value: 'create',
3355
+ description: 'Register a webhook that receives phone_line.* events. Answers 201 {webhook} with the plwh_ signing SECRET — shown ONLY in this response, never again: store it now. Not idempotent: running it twice creates two webhooks with two secrets.',
3356
+ action: 'Create a phone line webhook',
3357
+ routing: {
3358
+ request: { method: 'POST', url: '/phone-lines/webhooks' },
3359
+ send: { preSend: [phoneLineWebhookCreatePreSend] },
3360
+ },
3361
+ },
3362
+ {
3363
+ name: 'Delete',
3364
+ value: 'delete',
3365
+ description: 'Delete a phone line webhook AND its delivery history. There is no undo. Answers {ok: true}.',
3366
+ action: 'Delete a phone line webhook',
3367
+ routing: {
3368
+ request: {
3369
+ method: 'DELETE',
3370
+ url: '=/phone-lines/webhooks/{{encodeURIComponent($parameter.phoneLineWebhookId)}}',
3371
+ },
3372
+ },
3373
+ },
3374
+ {
3375
+ name: 'Get',
3376
+ value: 'get',
3377
+ description: 'One phone line webhook: {webhook} with id, name, url, events, active, lastDeliveryAt, lastStatusCode, createdAt. Never the secret. Another workspace\'s webhook is 404 WEBHOOK_NOT_FOUND.',
3378
+ action: 'Get a phone line webhook',
3379
+ routing: {
3380
+ request: {
3381
+ method: 'GET',
3382
+ url: '=/phone-lines/webhooks/{{encodeURIComponent($parameter.phoneLineWebhookId)}}',
3383
+ },
3384
+ },
3385
+ },
3386
+ {
3387
+ name: 'Get Many',
3388
+ value: 'getAll',
3389
+ description: 'Every phone line webhook of the workspace (oldest first) and the subscribable event catalogue. Answers {webhooks, events}. Never the secrets.',
3390
+ action: 'Get many phone line webhooks',
3391
+ routing: { request: { method: 'GET', url: '/phone-lines/webhooks' } },
3392
+ },
3393
+ {
3394
+ name: 'Update',
3395
+ value: 'update',
3396
+ description: 'Change only the fields added under Update Fields; the others stay as they are. Active off PAUSES the webhook. Answers {webhook}; the secret does not change.',
3397
+ action: 'Update a phone line webhook',
3398
+ routing: {
3399
+ request: {
3400
+ method: 'PATCH',
3401
+ url: '=/phone-lines/webhooks/{{encodeURIComponent($parameter.phoneLineWebhookId)}}',
3402
+ },
3403
+ send: { preSend: [phoneLineWebhookUpdatePreSend] },
3404
+ },
3405
+ },
3406
+ {
3407
+ name: 'Get Deliveries',
3408
+ value: 'getDeliveries',
3409
+ description: 'The webhook\'s latest deliveries, newest first: {deliveries} with event, status (PENDING, DELIVERED, FAILED), attempts, responseStatus, lastError, createdAt, deliveredAt. Never the payload — use Get Delivery for that.',
3410
+ action: 'Get the deliveries of a phone line webhook',
3411
+ routing: {
3412
+ request: {
3413
+ method: 'GET',
3414
+ url: '=/phone-lines/webhooks/{{encodeURIComponent($parameter.phoneLineWebhookId)}}/deliveries',
3415
+ },
3416
+ },
3417
+ },
3418
+ {
3419
+ name: 'Get Delivery',
3420
+ value: 'getDelivery',
3421
+ description: 'One delivery with durationMs, responseBody and the payload: the EXACT signed JSON string that was sent. A phone_line.code_received payload carries the activation code — treat the output as a credential.',
3422
+ action: 'Get a delivery of a phone line webhook',
3423
+ routing: {
3424
+ request: {
3425
+ method: 'GET',
3426
+ url: '=/phone-lines/webhooks/{{encodeURIComponent($parameter.phoneLineWebhookId)}}/deliveries/{{encodeURIComponent($parameter.phoneLineWebhookDeliveryId)}}',
3427
+ },
3428
+ },
3429
+ },
3430
+ ],
3431
+ default: 'getAll',
3432
+ },
3433
+ {
3434
+ displayName: 'Webhook ID',
3435
+ name: 'phoneLineWebhookId',
3436
+ type: 'string',
3437
+ description: 'Pilot Status id of the phone line webhook — webhooks[].id from Get Many',
3438
+ displayOptions: {
3439
+ show: {
3440
+ resource: ['phoneLineWebhook'],
3441
+ operation: ['delete', 'get', 'update', 'getDeliveries', 'getDelivery'],
3442
+ },
3443
+ },
3444
+ default: '',
3445
+ required: true,
3446
+ },
3447
+ {
3448
+ displayName: 'Delivery ID',
3449
+ name: 'phoneLineWebhookDeliveryId',
3450
+ type: 'string',
3451
+ description: 'deliveries[].id from Get Deliveries',
3452
+ displayOptions: { show: { resource: ['phoneLineWebhook'], operation: ['getDelivery'] } },
3453
+ default: '',
3454
+ required: true,
3455
+ },
3456
+ // Phone Line Webhook: Create. The body is built by phoneLineWebhookCreatePreSend.
3457
+ {
3458
+ displayName: 'URL',
3459
+ name: 'phoneLineWebhookUrl',
3460
+ type: 'string',
3461
+ placeholder: 'https://example.com/phone-line-hook',
3462
+ description: 'HTTPS URL that receives the events. Must be public: an internal or private destination is refused (400 WEBHOOK_URL_REFUSED).',
3463
+ displayOptions: { show: { resource: ['phoneLineWebhook'], operation: ['create'] } },
3464
+ default: '',
3465
+ required: true,
3466
+ },
3467
+ {
3468
+ displayName: 'Events',
3469
+ name: 'phoneLineWebhookEvents',
3470
+ type: 'multiOptions',
3471
+ options: exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS,
3472
+ description: 'Phone line events delivered to the URL. At least one is required.',
3473
+ displayOptions: { show: { resource: ['phoneLineWebhook'], operation: ['create'] } },
3474
+ default: [],
3475
+ required: true,
3476
+ },
3477
+ {
3478
+ displayName: 'Name',
3479
+ name: 'phoneLineWebhookName',
3480
+ type: 'string',
3481
+ description: 'Optional label (max 100 characters). Left empty, the URL\'s hostname is used.',
3482
+ displayOptions: { show: { resource: ['phoneLineWebhook'], operation: ['create'] } },
3483
+ default: '',
3484
+ },
3485
+ // Phone Line Webhook: Update. The body is built by phoneLineWebhookUpdatePreSend.
3486
+ {
3487
+ displayName: 'Update Fields',
3488
+ name: 'phoneLineWebhookUpdateFields',
3489
+ type: 'collection',
3490
+ placeholder: 'Add Field',
3491
+ displayOptions: { show: { resource: ['phoneLineWebhook'], operation: ['update'] } },
3492
+ default: {},
3493
+ options: [
3494
+ {
3495
+ displayName: 'Active',
3496
+ name: 'active',
3497
+ type: 'boolean',
3498
+ default: true,
3499
+ description: 'Whether the webhook receives events. Off pauses it without deleting it.',
3500
+ },
3501
+ {
3502
+ displayName: 'Events',
3503
+ name: 'events',
3504
+ type: 'multiOptions',
3505
+ options: exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS,
3506
+ default: [],
3507
+ description: 'REPLACES the subscribed events. An empty selection is ignored.',
3508
+ },
3509
+ {
3510
+ displayName: 'Name',
3511
+ name: 'name',
3512
+ type: 'string',
3513
+ default: '',
3514
+ description: 'New label (max 100 characters). A blank value is ignored.',
3515
+ },
3516
+ {
3517
+ displayName: 'URL',
3518
+ name: 'url',
3519
+ type: 'string',
3520
+ default: '',
3521
+ placeholder: 'https://example.com/phone-line-hook',
3522
+ description: 'New HTTPS public URL. A blank value is ignored.',
3523
+ },
3524
+ ],
3525
+ },
3526
+ // Phone Line Webhook: Get Deliveries
3527
+ {
3528
+ displayName: 'Limit',
3529
+ name: 'phoneLineWebhookDeliveriesLimit',
3530
+ type: 'number',
3531
+ typeOptions: { minValue: 1, maxValue: 200 },
3532
+ description: 'Max number of results to return',
3533
+ displayOptions: { show: { resource: ['phoneLineWebhook'], operation: ['getDeliveries'] } },
3534
+ default: 50,
3535
+ routing: { send: { type: 'query', property: 'limit' } },
3536
+ },
3537
+ // ----------------------------------
3538
+ // Workspace Webhook Operations (/v1/workspace/webhooks) — the workspace's events: every
3539
+ // phone_line.* event plus wallet.topup_paid. Same rows as Phone Line Webhook (a webhook made
3540
+ // on one shows on the other). TENANT-SCOPED key only (a workspace key, or an account key with Workspace ID set); permission phone_lines:webhooks (ADMIN and up).
3541
+ // ----------------------------------
3542
+ {
3543
+ displayName: 'Operation',
3544
+ name: 'operation',
3545
+ type: 'options',
3546
+ noDataExpression: true,
3547
+ displayOptions: { show: { resource: ['workspaceWebhook'] } },
3548
+ options: [
3549
+ {
3550
+ name: 'Create',
3551
+ value: 'create',
3552
+ description: 'Register a webhook for workspace events (phone lines and Wallet Top-Up Paid). Answers 201 {webhook} with the plwh_ signing SECRET — shown ONLY in this response, never again: store it now. Not idempotent: running it twice creates two webhooks with two secrets.',
3553
+ action: 'Create a workspace webhook',
3554
+ routing: {
3555
+ request: { method: 'POST', url: '/workspace/webhooks' },
3556
+ send: { preSend: [workspaceWebhookCreatePreSend] },
3557
+ },
3558
+ },
3559
+ {
3560
+ name: 'Delete',
3561
+ value: 'delete',
3562
+ description: 'Delete a workspace webhook AND its delivery history. There is no undo. Answers {ok: true}.',
3563
+ action: 'Delete a workspace webhook',
3564
+ routing: { request: { method: 'DELETE', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}' } },
3565
+ },
3566
+ {
3567
+ name: 'Get',
3568
+ value: 'get',
3569
+ description: 'One workspace webhook: {webhook} with id, name, url, events, active, lastDeliveryAt, lastStatusCode, createdAt. Never the secret. Another workspace\'s webhook is 404 WEBHOOK_NOT_FOUND.',
3570
+ action: 'Get a workspace webhook',
3571
+ routing: { request: { method: 'GET', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}' } },
3572
+ },
3573
+ {
3574
+ name: 'Get Many',
3575
+ value: 'getAll',
3576
+ description: 'Every webhook of the workspace (oldest first, including the ones made as Phone Line Webhook) and the subscribable event catalogue. Answers {webhooks, events}. Never the secrets.',
3577
+ action: 'Get many workspace webhooks',
3578
+ routing: { request: { method: 'GET', url: '/workspace/webhooks' } },
3579
+ },
3580
+ {
3581
+ name: 'Update',
3582
+ value: 'update',
3583
+ description: 'Change only the fields added under Update Fields; the others stay as they are. Active off PAUSES the webhook. Answers {webhook}; the secret does not change.',
3584
+ action: 'Update a workspace webhook',
3585
+ routing: {
3586
+ request: { method: 'PATCH', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}' },
3587
+ send: { preSend: [workspaceWebhookUpdatePreSend] },
3588
+ },
3589
+ },
3590
+ {
3591
+ name: 'Get Deliveries',
3592
+ value: 'getDeliveries',
3593
+ description: 'The webhook\'s latest deliveries, newest first: {deliveries} with event, status (PENDING, DELIVERED, FAILED), attempts, responseStatus, lastError, createdAt, deliveredAt. Never the payload — use Get Delivery for that.',
3594
+ action: 'Get the deliveries of a workspace webhook',
3595
+ routing: { request: { method: 'GET', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}/deliveries' } },
3596
+ },
3597
+ {
3598
+ name: 'Get Delivery',
3599
+ value: 'getDelivery',
3600
+ description: 'One delivery with durationMs, responseBody and the payload: the EXACT signed JSON string that was sent. A phone_line.code_received payload carries the activation code — treat the output as a credential.',
3601
+ action: 'Get a delivery of a workspace webhook',
3602
+ routing: {
3603
+ request: {
3604
+ method: 'GET',
3605
+ url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}/deliveries/{{encodeURIComponent($parameter.workspaceWebhookDeliveryId)}}',
3606
+ },
3607
+ },
3608
+ },
3609
+ ],
3610
+ default: 'getAll',
3611
+ },
3612
+ {
3613
+ displayName: 'Webhook ID',
3614
+ name: 'workspaceWebhookId',
3615
+ type: 'string',
3616
+ description: 'Pilot Status id of the workspace webhook — webhooks[].id from Get Many',
3617
+ displayOptions: {
3618
+ show: {
3619
+ resource: ['workspaceWebhook'],
3620
+ operation: ['delete', 'get', 'update', 'getDeliveries', 'getDelivery'],
3621
+ },
3622
+ },
3623
+ default: '',
3624
+ required: true,
3625
+ },
3626
+ {
3627
+ displayName: 'Delivery ID',
3628
+ name: 'workspaceWebhookDeliveryId',
3629
+ type: 'string',
3630
+ description: 'deliveries[].id from Get Deliveries',
3631
+ displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['getDelivery'] } },
3632
+ default: '',
3633
+ required: true,
3634
+ },
3635
+ // Workspace Webhook: Create. The body is built by workspaceWebhookCreatePreSend.
3636
+ {
3637
+ displayName: 'URL',
3638
+ name: 'workspaceWebhookUrl',
3639
+ type: 'string',
3640
+ placeholder: 'https://example.com/workspace-hook',
3641
+ description: 'HTTPS URL that receives the events. Must be public: an internal or private destination is refused (400 WEBHOOK_URL_REFUSED).',
3642
+ displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['create'] } },
3643
+ default: '',
3644
+ required: true,
3645
+ },
3646
+ {
3647
+ displayName: 'Events',
3648
+ name: 'workspaceWebhookEvents',
3649
+ type: 'multiOptions',
3650
+ options: exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS,
3651
+ description: 'Events delivered to the URL. At least one is required. "All Phone Line Events" does NOT include Wallet Top-Up Paid — select it by name.',
3652
+ displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['create'] } },
3653
+ default: [],
3654
+ required: true,
3655
+ },
3656
+ {
3657
+ displayName: 'Name',
3658
+ name: 'workspaceWebhookName',
3659
+ type: 'string',
3660
+ description: 'Optional label (max 100 characters). Left empty, the URL\'s hostname is used.',
3661
+ displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['create'] } },
3662
+ default: '',
3663
+ },
3664
+ // Workspace Webhook: Update. The body is built by workspaceWebhookUpdatePreSend.
3665
+ {
3666
+ displayName: 'Update Fields',
3667
+ name: 'workspaceWebhookUpdateFields',
3668
+ type: 'collection',
3669
+ placeholder: 'Add Field',
3670
+ displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['update'] } },
3671
+ default: {},
3672
+ options: [
3673
+ {
3674
+ displayName: 'Active',
3675
+ name: 'active',
3676
+ type: 'boolean',
3677
+ default: true,
3678
+ description: 'Whether the webhook receives events. Off pauses it without deleting it.',
3679
+ },
3680
+ {
3681
+ displayName: 'Events',
3682
+ name: 'events',
3683
+ type: 'multiOptions',
3684
+ options: exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS,
3685
+ default: [],
3686
+ description: 'REPLACES the subscribed events. An empty selection is ignored.',
3687
+ },
3688
+ {
3689
+ displayName: 'Name',
3690
+ name: 'name',
3691
+ type: 'string',
3692
+ default: '',
3693
+ description: 'New label (max 100 characters). A blank value is ignored.',
3694
+ },
3695
+ {
3696
+ displayName: 'URL',
3697
+ name: 'url',
3698
+ type: 'string',
3699
+ default: '',
3700
+ placeholder: 'https://example.com/workspace-hook',
3701
+ description: 'New HTTPS public URL. A blank value is ignored.',
3702
+ },
3703
+ ],
3704
+ },
3705
+ // Workspace Webhook: Get Deliveries
3706
+ {
3707
+ displayName: 'Limit',
3708
+ name: 'workspaceWebhookDeliveriesLimit',
3709
+ type: 'number',
3710
+ typeOptions: { minValue: 1, maxValue: 200 },
3711
+ description: 'Max number of results to return',
3712
+ displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['getDeliveries'] } },
3713
+ default: 50,
3714
+ routing: { send: { type: 'query', property: 'limit' } },
3715
+ },
3716
+ // ----------------------------------
3717
+ // Billing Operations (/v1/billing/*) — TENANT-SCOPED key only (a workspace key, or an account key with Workspace ID set). Nothing here
3718
+ // charges by itself: a human pays the hosted page or the Pix, and a Stripe intent is
3719
+ // confirmed by Stripe.js in a browser. Checkout/top-up/payment intents need
3720
+ // billing:wallet:topup; Add Card and setup intents billing:payment_method:manage (OWNER);
3721
+ // Get Top-Up billing:read.
3722
+ // ----------------------------------
3723
+ {
3724
+ displayName: 'Operation',
3725
+ name: 'operation',
3726
+ type: 'options',
3727
+ noDataExpression: true,
3728
+ displayOptions: { show: { resource: ['billing'] } },
3729
+ options: [
3730
+ {
3731
+ name: 'Create Checkout',
3732
+ value: 'createCheckout',
3733
+ description: 'Wallet Top-Up: by card, a hosted Stripe page {url, orderId}; by Pix (BRL workspaces only, else 400 PIX_NOT_ELIGIBLE), {orderId, status: pending, pix: {transactionId, copyPaste, qrCode, expiresAt}} — show the copy-and-paste code or the QR to the payer. Add Card: a hosted page {url} that saves a card. Nothing is charged until a human pays. Poll a top-up with Get Top-Up.',
3734
+ action: 'Create a checkout',
3735
+ routing: {
3736
+ request: { method: 'POST', url: '/billing/checkout' },
3737
+ send: { preSend: [billingCheckoutPreSend] },
3738
+ },
3739
+ },
3740
+ {
3741
+ name: 'Get Top-Up',
3742
+ value: 'getTopup',
3743
+ description: 'Status of a wallet top-up order (card or Pix): {topup} with id, status (pending, paid, expired, failed), amount, currency, method, provider, createdAt, paidAt, expiresAt. Read-only — polling it calls no payment provider. Another workspace\'s order is 404 TOPUP_NOT_FOUND.',
3744
+ action: 'Get a wallet top-up',
3745
+ routing: {
3746
+ request: {
3747
+ method: 'GET',
3748
+ url: '=/billing/topups/{{encodeURIComponent($parameter.billingTopupId)}}',
3749
+ },
3750
+ },
3751
+ },
3752
+ {
3753
+ name: 'Create Card Setup Intent',
3754
+ value: 'createCardSetupIntent',
3755
+ description: 'Transparent card save (Stripe Elements): {clientSecret, setupIntentId, publishableKey} for your page to mount the Payment Element and call stripe.confirmSetup — the card goes browser → Stripe. Then run Sync Card Setup Intent. The clientSecret lets anyone holding it confirm the intent: never log it. 503 PAYMENTS_NOT_CONFIGURED when card payments are unavailable.',
3756
+ action: 'Create a card setup intent',
3757
+ routing: { request: { method: 'POST', url: '/billing/card/setup-intent' } },
3758
+ },
3759
+ {
3760
+ name: 'Sync Card Setup Intent',
3761
+ value: 'syncCardSetupIntent',
3762
+ description: 'After stripe.confirmSetup resolves: reads the SetupIntent from Stripe and, if it succeeded, makes the card the workspace\'s saved card now. Answers {setupIntentId, status, saved, card: {brand, last4, expMonth, expYear} | null}; not succeeded yet = saved false. Idempotent. Unknown or another workspace\'s id: 404 SETUP_INTENT_NOT_FOUND.',
3763
+ action: 'Sync a card setup intent',
3764
+ routing: {
3765
+ request: {
3766
+ method: 'POST',
3767
+ url: '=/billing/card/setup-intent/{{encodeURIComponent($parameter.billingSetupIntentId)}}/sync',
3768
+ },
3769
+ },
3770
+ },
3771
+ {
3772
+ name: 'Create Payment Intent',
3773
+ value: 'createPaymentIntent',
3774
+ description: 'Transparent wallet top-up by card (Stripe Elements): creates a pending order and a PaymentIntent, answering {clientSecret, paymentIntentId, orderId, amount, currency, publishableKey} for stripe.confirmPayment in your page. Then run Sync Payment Intent. Never log the clientSecret. 400 AMOUNT_TOO_SMALL below the minimum card charge; 503 PAYMENTS_NOT_CONFIGURED.',
3775
+ action: 'Create a payment intent',
3776
+ routing: {
3777
+ request: { method: 'POST', url: '/billing/payment-intents' },
3778
+ send: { preSend: [billingPaymentIntentPreSend] },
3779
+ },
3780
+ },
3781
+ {
3782
+ name: 'Sync Payment Intent',
3783
+ value: 'syncPaymentIntent',
3784
+ description: 'After stripe.confirmPayment resolves: reads the PaymentIntent from Stripe and, if it succeeded, credits the wallet — exactly once (a replay, or the racing webhook, gets credited false). Answers {paymentIntentId, status, orderId, orderStatus, amount, currency, credited, balance, cardSaved}. It never charges. Unknown or another workspace\'s id: 404 PAYMENT_INTENT_NOT_FOUND.',
3785
+ action: 'Sync a payment intent',
3786
+ routing: {
3787
+ request: {
3788
+ method: 'POST',
3789
+ url: '=/billing/payment-intents/{{encodeURIComponent($parameter.billingPaymentIntentId)}}/sync',
3790
+ },
3791
+ },
3792
+ },
3793
+ ],
3794
+ default: 'createCheckout',
3795
+ },
3796
+ // Billing: Create Checkout. The body is built by billingCheckoutPreSend.
3797
+ {
3798
+ displayName: 'Purpose',
3799
+ name: 'billingPurpose',
3800
+ type: 'options',
3801
+ options: [
3802
+ { name: 'Wallet Top-Up', value: 'wallet_topup', description: 'Add credit to the pre-paid wallet' },
3803
+ { name: 'Add Card', value: 'add_card', description: 'Save a card on file (hosted Stripe page)' },
3804
+ ],
3805
+ displayOptions: { show: { resource: ['billing'], operation: ['createCheckout'] } },
3806
+ default: 'wallet_topup',
3807
+ required: true,
3808
+ },
3809
+ {
3810
+ displayName: 'Method',
3811
+ name: 'billingMethod',
3812
+ type: 'options',
3813
+ options: [
3814
+ { name: 'Card', value: 'card', description: 'Hosted Stripe Checkout page' },
3815
+ { name: 'Pix', value: 'pix', description: 'Pix copy-and-paste code and QR (BRL workspaces only)' },
3816
+ ],
3817
+ displayOptions: {
3818
+ show: { resource: ['billing'], operation: ['createCheckout'], billingPurpose: ['wallet_topup'] },
3819
+ },
3820
+ default: 'card',
3821
+ },
3822
+ {
3823
+ displayName: 'Amount',
3824
+ name: 'billingAmount',
3825
+ type: 'number',
3826
+ typeOptions: { minValue: 0, numberPrecision: 2 },
3827
+ description: 'Amount to add to the wallet, in the workspace currency (major units, e.g. 50.00)',
3828
+ displayOptions: {
3829
+ show: { resource: ['billing'], operation: ['createCheckout'], billingPurpose: ['wallet_topup'] },
3830
+ },
3831
+ default: 0,
3832
+ required: true,
3833
+ },
3834
+ {
3835
+ displayName: 'Amount',
3836
+ name: 'billingAmount',
3837
+ type: 'number',
3838
+ typeOptions: { minValue: 0, numberPrecision: 2 },
3839
+ description: 'Amount to add to the wallet, in the workspace currency (major units, e.g. 50.00)',
3840
+ displayOptions: { show: { resource: ['billing'], operation: ['createPaymentIntent'] } },
3841
+ default: 0,
3842
+ required: true,
3843
+ },
3844
+ {
3845
+ displayName: 'Success URL',
3846
+ name: 'billingSuccessUrl',
3847
+ type: 'string',
3848
+ description: 'Where the hosted page sends the browser after paying. Card only — a Pix has no redirect.',
3849
+ displayOptions: {
3850
+ show: { resource: ['billing'], operation: ['createCheckout'] },
3851
+ hide: { billingMethod: ['pix'] },
3852
+ },
3853
+ default: '',
3854
+ },
3855
+ {
3856
+ displayName: 'Cancel URL',
3857
+ name: 'billingCancelUrl',
3858
+ type: 'string',
3859
+ description: 'Where the hosted page sends the browser on cancel. Card only — a Pix has no redirect.',
3860
+ displayOptions: {
3861
+ show: { resource: ['billing'], operation: ['createCheckout'] },
3862
+ hide: { billingMethod: ['pix'] },
3863
+ },
3864
+ default: '',
3865
+ },
3866
+ {
3867
+ displayName: 'Top-Up ID',
3868
+ name: 'billingTopupId',
3869
+ type: 'string',
3870
+ description: 'orderId returned by Create Checkout (Wallet Top-Up) or Create Payment Intent',
3871
+ displayOptions: { show: { resource: ['billing'], operation: ['getTopup'] } },
3872
+ default: '',
3873
+ required: true,
3874
+ },
3875
+ {
3876
+ displayName: 'Setup Intent ID',
3877
+ name: 'billingSetupIntentId',
3878
+ type: 'string',
3879
+ placeholder: 'seti_...',
3880
+ description: 'setupIntentId from Create Card Setup Intent (a Stripe seti_… id; anything else is 400 INVALID_SETUP_INTENT_ID)',
3881
+ displayOptions: { show: { resource: ['billing'], operation: ['syncCardSetupIntent'] } },
3882
+ default: '',
3883
+ required: true,
3884
+ },
3885
+ {
3886
+ displayName: 'Payment Intent ID',
3887
+ name: 'billingPaymentIntentId',
3888
+ type: 'string',
3889
+ placeholder: 'pi_...',
3890
+ description: 'paymentIntentId from Create Payment Intent (a Stripe pi_… id; anything else is 400 INVALID_PAYMENT_INTENT_ID)',
3891
+ displayOptions: { show: { resource: ['billing'], operation: ['syncPaymentIntent'] } },
3892
+ default: '',
3893
+ required: true,
3894
+ },
3895
+ {
3896
+ displayName: 'Save Card',
3897
+ name: 'billingSaveCard',
3898
+ type: 'boolean',
3899
+ description: 'Whether the card used also becomes the workspace\'s saved card',
3900
+ displayOptions: { show: { resource: ['billing'], operation: ['createPaymentIntent'] } },
3901
+ default: false,
3902
+ },
3903
+ {
3904
+ displayName: 'Idempotency Key',
3905
+ name: 'billingIdempotencyKey',
3906
+ type: 'string',
3907
+ description: 'Optional. Sent as the Idempotency-Key header (max 255 characters, no control characters). REUSE THE SAME KEY when retrying: within 24 hours the same key and body return the SAME orderId, paymentIntentId and clientSecret (Idempotent-Replayed: true) and create nothing. Same key with a DIFFERENT body → 409 IDEMPOTENCY_KEY_REUSED; first call still running → 409 IDEMPOTENCY_KEY_IN_USE; invalid → 400 IDEMPOTENCY_KEY_INVALID. Empty: every run creates a new order.',
3908
+ displayOptions: { show: { resource: ['billing'], operation: ['createPaymentIntent'] } },
3909
+ default: '',
3910
+ },
3911
+ // ----------------------------------
3912
+ // Workspace Operations (/v1/workspaces) — ACCOUNT KEY ONLY (ps_account_…, Profile → API).
3913
+ // The principal is a USER: any other key or token is 403 ACCOUNT_KEY_REQUIRED. The
3914
+ // credential's Workspace ID is ignored here.
3915
+ // ----------------------------------
3916
+ {
3917
+ displayName: 'Operation',
3918
+ name: 'operation',
3919
+ type: 'options',
3920
+ noDataExpression: true,
3921
+ displayOptions: { show: { resource: ['workspace'] } },
3922
+ options: [
3923
+ {
3924
+ name: 'Create',
3925
+ value: 'create',
3926
+ description: 'Create a workspace owned by the account key\'s user, plus its first (primary) ps_workspace_ key. Answers 201 {id, name, plan, createdAt, role: OWNER, apiKey: {id, name, key, prefix, last4, isPrimary, createdAt} | null} — apiKey.key is shown ONLY here; null means the workspace exists but the key failed (mint one with Workspace API Key → Create, do NOT run Create again). Not idempotent. 409 WORKSPACE_LIMIT_REACHED at the owned-workspace limit.',
3927
+ action: 'Create a workspace',
3928
+ routing: {
3929
+ request: { method: 'POST', url: '/workspaces' },
3930
+ send: { preSend: [workspaceCreatePreSend] },
3931
+ },
3932
+ },
3933
+ {
3934
+ name: 'Get Many',
3935
+ value: 'getAll',
3936
+ description: 'The workspaces the account key\'s user is an active member of: {data: [{id, name, role, plan, createdAt}]}. Use an id as the credential\'s Workspace ID.',
3937
+ action: 'Get many workspaces',
3938
+ routing: { request: { method: 'GET', url: '/workspaces' } },
3939
+ },
3940
+ ],
3941
+ default: 'getAll',
3942
+ },
3943
+ {
3944
+ displayName: 'Name',
3945
+ name: 'workspaceName',
3946
+ type: 'string',
3947
+ description: 'Workspace name (required)',
3948
+ displayOptions: { show: { resource: ['workspace'], operation: ['create'] } },
3949
+ default: '',
3950
+ required: true,
3951
+ },
3952
+ // ----------------------------------
3953
+ // Workspace API Key Operations (/v1/workspaces/{id}/api-keys) — ACCOUNT KEY ONLY, acting
3954
+ // with the user's LIVE role in that workspace (ADMIN and up; not a member → 403
3955
+ // WORKSPACE_MEMBERSHIP_REQUIRED).
3956
+ // ----------------------------------
3957
+ {
3958
+ displayName: 'Operation',
3959
+ name: 'operation',
3960
+ type: 'options',
3961
+ noDataExpression: true,
3962
+ displayOptions: { show: { resource: ['workspaceApiKey'] } },
3963
+ options: [
3964
+ {
3965
+ name: 'Create',
3966
+ value: 'create',
3967
+ description: 'Mint a NAMED ps_workspace_ key (never the primary). Answers 201 {apiKey: {id, name, key, prefix, last4, isPrimary: false, createdAt}} — apiKey.key is shown ONLY here. 409 WORKSPACE_KEY_LIMIT_REACHED at the limit.',
3968
+ action: 'Create a workspace API key',
3969
+ routing: {
3970
+ request: {
3971
+ method: 'POST',
3972
+ url: '=/workspaces/{{encodeURIComponent($parameter.workspaceApiKeyWorkspaceId)}}/api-keys',
3973
+ },
3974
+ send: { preSend: [workspaceApiKeyCreatePreSend] },
3975
+ },
3976
+ },
3977
+ {
3978
+ name: 'Get Many',
3979
+ value: 'getAll',
3980
+ description: 'The workspace\'s tenant keys, MASKED: {data: [{id, name, prefix, last4, isPrimary, createdAt, lastUsedAt}]}.',
3981
+ action: 'Get many workspace API keys',
3982
+ routing: {
3983
+ request: {
3984
+ method: 'GET',
3985
+ url: '=/workspaces/{{encodeURIComponent($parameter.workspaceApiKeyWorkspaceId)}}/api-keys',
3986
+ },
3987
+ },
3988
+ },
3989
+ {
3990
+ name: 'Revoke',
3991
+ value: 'revoke',
3992
+ description: 'Revoke a NAMED workspace key, effective on its next request. Answers {id, revokedAt}. The primary key cannot be revoked (409 PRIMARY_KEY_NOT_REVOCABLE — rotate it instead); an unknown id is 404 API_KEY_NOT_FOUND.',
3993
+ action: 'Revoke a workspace API key',
3994
+ routing: {
3995
+ request: {
3996
+ method: 'DELETE',
3997
+ url: '=/workspaces/{{encodeURIComponent($parameter.workspaceApiKeyWorkspaceId)}}/api-keys/{{encodeURIComponent($parameter.workspaceApiKeyId)}}',
3998
+ },
3999
+ },
4000
+ },
4001
+ ],
4002
+ default: 'getAll',
4003
+ },
4004
+ {
4005
+ displayName: 'Workspace ID',
4006
+ name: 'workspaceApiKeyWorkspaceId',
4007
+ type: 'string',
4008
+ description: 'data[].id from Workspace (Account Key) → Get Many',
4009
+ displayOptions: { show: { resource: ['workspaceApiKey'] } },
4010
+ default: '',
4011
+ required: true,
4012
+ },
4013
+ {
4014
+ displayName: 'Name',
4015
+ name: 'workspaceApiKeyName',
4016
+ type: 'string',
4017
+ description: 'Key name (required)',
4018
+ displayOptions: { show: { resource: ['workspaceApiKey'], operation: ['create'] } },
4019
+ default: '',
4020
+ required: true,
4021
+ },
4022
+ {
4023
+ displayName: 'API Key ID',
4024
+ name: 'workspaceApiKeyId',
4025
+ type: 'string',
4026
+ description: 'data[].id from Get Many',
4027
+ displayOptions: { show: { resource: ['workspaceApiKey'], operation: ['revoke'] } },
4028
+ default: '',
4029
+ required: true,
4030
+ },
3077
4031
  ],
3078
4032
  };
3079
4033
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",