Update a mail trigger
const url = 'https://example.com/v1/mail-triggers/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"flowId":"example","flowVersion":"example","agentId":"example","agentVersion":"example","config":{"mailbox":{"app":"google","as":"company","connectionId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"},"folder":"example","pollSeconds":1,"runsPerHour":1},"label":"example","toolsAllowedUnattended":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://example.com/v1/mail-triggers/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "flowId": "example", "flowVersion": "example", "agentId": "example", "agentVersion": "example", "config": { "mailbox": { "app": "google", "as": "company", "connectionId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }, "folder": "example", "pollSeconds": 1, "runsPerHour": 1 }, "label": "example", "toolsAllowedUnattended": [ "example" ] }'Changes what it runs (which needs execute on the new target, and must be the project’s to reach), its mailbox (replaced whole), folder, pace or label (null clears it). A new company mailbox’s connection is decided as at registration: the one connectionId names, else the project’s only one; another connection, or one named where none was, is another mailbox. The company’s mailbox it reads now, sent again with no connectionId, is the same mailbox: it keeps the one it reads with, or stores the only one. To watch the inbox again, name it as the folder: INBOX on Gmail, inbox on Outlook. No edit moves the owner: a personal trigger’s change is its owner’s (who needs write on the project) or a project admin’s, a shared one’s is a project admin’s, and the company’s mailbox, before or after, takes a project admin. Only a personal trigger’s owner chooses what it reads from a person’s mailbox, another of their mailboxes or another folder: anyone else, a project admin included, gets a 403, and may take the trigger over to watch their own. A project admin’s other changes to a person’s trigger, such as what it runs, its pace or a move to the company’s mailbox, keep its owner, so its runs go on acting as that person, and they’re audited as trigger-changed-for-owner, naming the trigger’s version after each. Since no edit moves the owner, with an authorization store a new target (another flow or agent) must be one the owner can run, a person or a service account, else 409 trigger-owner-cannot-run-target; that’s not checked when the caller is the owner, nor for an owner that was unregistered or removed. toolsAllowedUnattended replaces the list ([] clears it; absent keeps it, a new version too), and a new target or mailbox while it lists any must name it again. Naming a list takes admin on the project; a personal trigger’s owner may name [] with their own new target or mailbox.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Change what it runs (the target fields, as at registration, which also needs execute on the new target), its mailbox (replaced whole), folder, pace or label. A personal trigger’s change is its owner’s or a project admin’s; a shared one’s, a project admin’s; and the company’s mailbox, before or after, takes a project admin. The owner stays.
object
Responses
Section titled “Responses”Updated mail trigger.
A mail trigger: each new mail in its mailbox’s folder starts a run of its agent or flow, with the mail as the run’s input, as its owner. In such a run, every call that changes something, or uses the run’s own mailbox, waits for a person’s yes unless the trigger lists it (toolsAllowedUnattended).
object
Example
{ "owner": { "kind": "user", "isProjectAccount": true }, "mailbox": { "app": "google", "as": "company" }, "status": "active"}A body that fails validation (bad-input): runAsServiceAccountId or runAsProject (the owner changes only by POST …/owner), a person’s mailbox for a shared trigger, a connectionId for a person’s mailbox or naming a person’s own live connection of the app, or a new target or mailbox without the list it holds. Or reference-out-of-scope: the new target isn’t the project’s to reach. Nothing changes.
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" }}permission-denied: the caller may not make this change to the mail trigger (the message says what it takes). Without an authorization store, key-project-mismatch (details.keyProjectId, details.projectId): the API key or session is limited to another project than the trigger’s (with a store, that is permission-denied).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}No mail trigger with that id. Or the new mailbox’s connectionId isn’t one of the project’s company connections of the app (connection-not-found, details.field config.mailbox.connectionId).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}A new target the trigger’s owner can’t run (trigger-owner-cannot-run-target), with an authorization store. Or a new company mailbox names no connection and the project has several of the app (connection-not-chosen, with details.choices and details.field as at registration). Or an Idempotency-Key reused with a different body. 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" }}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/mail-triggers/{triggerId}: Fetch a mail triggerPOST /v1/mail-triggers/{triggerId}/pause: Pause a mail triggerPOST /v1/mail-triggers/{triggerId}/resume: Resume a mail triggerPOST /v1/mail-triggers/{triggerId}/unregister: Soft-delete a mail trigger (tombstone)- Error code
authz-backend-unavailable - Error code
bad-input - Error code
connection-not-chosen - Error code
connection-not-found - Error code
database-busy - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
key-project-mismatch - Error code
permission-denied - Error code
rate-limit-exceeded - Error code
reference-out-of-scope - Error code
request-too-large - Error code
tenant-state-unavailable - Error code
trigger-owner-cannot-run-target - Every error code