Skip to content

Create function triggers

View .md
POST

Subscribe a function to one or more event types, optionally scoped to specific senders. Provide eventTypes and senderIds (use null in senderIds for all senders); a trigger is created for each event type and sender combination.

The special event type cron runs the function on a schedule instead of a messaging event: include a cron field with a 5-field UTC cron expression (minimum granularity one minute). A cron trigger ignores the sender axis, and a function may hold several cron triggers with different expressions. The function receives an event with type: "cron" and data.cron.

Authorization

  • Authorizationheaderrequired

    Bearer YOUR_API_KEY. Create a key in the dashboard.

Path parameters

  • functionIdstringrequired

    Zavu Function ID.

Body

application/json

  • eventTypesstring[]required

    Event types to subscribe to.

  • senderIdsstring[]required

    Senders to scope the triggers to. Use null for all senders.

  • cronstring

    Required when eventTypes includes cron: a 5-field cron expression (minute hour day-of-month month day-of-week), evaluated in UTC.

Responses

201Triggers created.
  • addedintegerrequired
  • skippedintegerrequired

    Number of triggers that already existed.

  • triggersobject[]required
    10 properties
    • idstringrequired
    • functionIdstringrequired
    • eventTypestringrequired

      Event type that fires the function. See GET /v1/functions/event-types for the supported list. The special type cron fires on a schedule instead of a messaging event and carries a cron expression.

    • senderIdstringnullable

      Restrict the trigger to a single sender. Null means all senders in the project.

    • activebooleanrequired
    • createdAtstring<date-time>required
    • updatedAtstring<date-time>required
    • cronstringnullable

      5-field cron expression (minute hour day-of-month month day-of-week), evaluated in UTC. Present only on cron triggers.

    • nextRunAtstring<date-time>nullable

      Next scheduled fire time. Present only on cron triggers.

    • lastRunAtstring<date-time>nullable

      Last time the schedule fired. Null until the first fire.

400Invalid request.
  • codestringrequired
  • messagestringrequired
  • detailsobject
401Unauthorized.
  • codestringrequired
  • messagestringrequired
  • detailsobject
404Function not found.
  • codestringrequired
  • messagestringrequired
  • detailsobject