Skip to main content
PATCH/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.

Parameters
name *path

The function's name.

A module's operation is named <module>:<operation>.

triggerId *path

The trigger's id, a UUID.

projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
eventsany

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"[]
filterany

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: pathPrefix, a literal prefix of the object's path (no wildcards); contentType, an exact type such as image/png or a family such as image/*; sizeBytes, an inclusive { min, max } range.

Null or absent fires on every matching event.

One of: object
or: null
enabledboolean

Turns the trigger on or off.

logOkInvocationsboolean

Whether successful invocations are logged as well as failed ones.

Responses
HTTPK9O CodeDescription
200Success
400K9O_INVALID_REQUEST_SHAPEThe body supplies none of events, filter, enabled and logOkInvocations, or does not match the schema.
400K9O_INVALID_FIELD_VALUEThe project slug, the function name or the trigger id is not a valid identifier.
400K9O_POLICY_UNKNOWN_OPERATORThe filter uses an operator outside the JSON-policy grammar.
401K9O_UNAUTHENTICATEDThe caller presented no authenticated session.
403K9O_ACCESS_DENIEDThe caller has no access to this project.
403K9O_IAM_POLICY_DENIEDThe bound IAM policy ceiling denies updating function triggers; the default floor is PROJECT_ADMIN.
404K9O_FUNCTION_NOT_FOUNDNo function with that name exists in this project, or it is retired.
404K9O_TRIGGER_NOT_FOUNDNo event trigger with that id is attached to this function (a scheduled trigger's id is not found here).
Response body (200)
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: insert, update, delete and upsert on a collection; on a bucket, object.created (an upload, an overwrite included), object.deleted (a delete through the API) and object.expired (removed by the bucket's deleteAfterDays).

A function that receives object.deleted or object.expired can't read the object any more.

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
TypeScript
// 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

Request example
{
  "filter": {
    "eq": [
      "resource.status",
      "archived"
    ]
  },
  "enabled": true
}
Response example (200)
{
  "data": {
    "id": "string",
    "functionName": "string",
    "collection": "string",
    "bucket": "string",
    "events": [
      "insert"
    ],
    "enabled": false,
    "logOkInvocations": false,
    "createdAt": "string"
  }
}

More in Compute & Automation