/functions/{name}/triggers/{triggerId}Update Function Trigger
Partially updates an EVENT trigger.
Send at least one of events, filter (an object in the JSON-policy grammar, or null to clear it), enabled and logOkInvocations; an empty body is 400 K9O_INVALID_REQUEST_SHAPE.
The function and the collection are fixed at creation.
A scheduled trigger's id is 404 K9O_TRIGGER_NOT_FOUND here; update schedules with PATCH /@{projectSlug}/forge/schedules/{trgId}.
Requires PROJECT_ADMIN.
| name * | path | The function's name. A module's operation is named |
| triggerId * | path | The trigger's id, a UUID. |
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| events | any | Replaces the events that fire the trigger: record events on a collection trigger, object events on a bucket trigger. |
| One of: "insert" | "update" | "delete" | "upsert"[] | ||
| or: "object.created" | "object.deleted" | "object.expired"[] | ||
| filter | any | Replaces the filter; null removes it. A collection trigger takes a record predicate, a bucket trigger the object conditions. Conditions on the object event, all of which must hold: Null or absent fires on every matching event. |
| One of: object | ||
| or: null | ||
| enabled | boolean | Turns the trigger on or off. |
| logOkInvocations | boolean | Whether successful invocations are logged as well as failed ones. |
| HTTP | K9O Code | Description |
|---|---|---|
| 200 | Success | |
| 400 | K9O_INVALID_REQUEST_SHAPE | The body supplies none of events, filter, enabled and logOkInvocations, or does not match the schema. |
| 400 | K9O_INVALID_FIELD_VALUE | The project slug, the function name or the trigger id is not a valid identifier. |
| 400 | K9O_POLICY_UNKNOWN_OPERATOR | The filter uses an operator outside the JSON-policy grammar. |
| 401 | K9O_UNAUTHENTICATED | The caller presented no authenticated session. |
| 403 | K9O_ACCESS_DENIED | The caller has no access to this project. |
| 403 | K9O_IAM_POLICY_DENIED | The bound IAM policy ceiling denies updating function triggers; the default floor is PROJECT_ADMIN. |
| 404 | K9O_FUNCTION_NOT_FOUND | No function with that name exists in this project, or it is retired. |
| 404 | K9O_TRIGGER_NOT_FOUND | No event trigger with that id is attached to this function (a scheduled trigger's id is not found here). |
| data * | object | A function trigger: the function runs when a matching write lands in the collection, or a matching object event happens in the bucket. |
| id * | string <uuid> | The trigger's id, a UUID. |
| functionName * | string | The function the trigger runs. |
| collection * | any | The collection whose writes fire the trigger; null on a bucket trigger. |
| One of: string | ||
| or: null | ||
| bucket * | any | The bucket whose object events fire the trigger; null on a collection trigger. |
| One of: string | ||
| or: null | ||
| events * | any[] | The events that fire the trigger: A function that receives |
| One of: "insert" | "update" | "delete" | "upsert" | ||
| or: "object.created" | "object.deleted" | "object.expired" | ||
| filter * | any | The condition an event must match: a record predicate on a collection trigger, object conditions on a bucket trigger. Null when the trigger fires on every matching event. |
| One of: object | ||
| or: null | ||
| enabled * | boolean | Whether the trigger fires. |
| logOkInvocations * | boolean | Whether successful invocations are logged as well as failed ones. |
| createdAt * | string <date-time> | When the trigger was created. |
| meta * | any | |
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.functions.triggers.update('greet', '3f6c1e2a-8b4d-4c7e-9a1f-2d5b6c7e8f90', {
filter: {
eq: ['resource.status', 'archived']
},
enabled: true
})Showing example in TypeScript
{
"filter": {
"eq": [
"resource.status",
"archived"
]
},
"enabled": true
}{
"data": {
"id": "string",
"functionName": "string",
"collection": "string",
"bucket": "string",
"events": [
"insert"
],
"enabled": false,
"logOkInvocations": false,
"createdAt": "string"
}
}