// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as ManageAPI from './manage'; import { Manage, ManageDeleteResponse, ManageUpdateParams, ManageUpdateResponse } from './manage'; import { APIPromise } from '../../core/api-promise'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; /** * Trigger management and execution */ export class TriggerInstances extends APIResource { manage: ManageAPI.Manage = new ManageAPI.Manage(this._client); /** * Retrieves all active trigger instances for your project. Triggers listen for * events from connected accounts (e.g., new emails, Slack messages, GitHub * commits) and can invoke webhooks or workflows. Use filters to find triggers for * specific users, connected accounts, or trigger types. * * @example * ```ts * const response = await client.triggerInstances.listActive(); * ``` */ listActive( query: TriggerInstanceListActiveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/api/v3.1/trigger_instances/active', { query, ...options }); } /** * Creates a new trigger instance or updates an existing one with the same * configuration. Triggers listen for events from external services (webhooks or * polling) and can invoke your workflows. If a matching trigger already exists and * is disabled, it will be re-enabled. Provide either a connected_account_id to pin * a specific user connection, or a user_id to auto-resolve the first active * connection for that user and the trigger's toolkit. * * @example * ```ts * const response = await client.triggerInstances.upsert( * 'slug', * ); * ``` */ upsert( slug: string, body: TriggerInstanceUpsertParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post(path`/api/v3.1/trigger_instances/${slug}/upsert`, { body, ...options }); } } export interface TriggerInstanceListActiveResponse { current_page: number; items: Array; total_items: number; total_pages: number; next_cursor?: string | null; } export namespace TriggerInstanceListActiveResponse { export interface Item { /** * Nano ID of the trigger instance */ id: string; /** * ID of the connected account this trigger is associated with */ connected_account_id: string; /** * UUID of the connected account this trigger is associated with */ connected_account_uuid: string; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use connected_account_id instead. */ connectedAccountId: string; /** * ISO 8601 timestamp when the trigger instance was disabled, if applicable */ disabled_at: string | null; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use disabled_at instead. */ disabledAt: string | null; /** * @deprecated DEPRECATED: This field exposes internal state and will be removed in * a future version. */ state: { [key: string]: unknown }; /** * Configuration for the trigger */ trigger_config: { [key: string]: unknown }; /** * Name of the trigger */ trigger_name: string; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use trigger_config instead. */ triggerConfig: { [key: string]: unknown }; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use trigger_name instead. */ triggerName: string; /** * ISO 8601 timestamp when the trigger instance was updated */ updated_at: string; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use updated_at instead. */ updatedAt: string; /** * ID of the user this trigger is associated with */ user_id: string; /** * Version of the trigger instance */ version: string; /** * Deprecated fields for the trigger instance */ deprecated?: Item.Deprecated; /** * Additional data associated with the trigger instance */ trigger_data?: string; /** * Unique identifier of the trigger instance */ uuid?: string; } export namespace Item { /** * Deprecated fields for the trigger instance */ export interface Deprecated { /** * Deprecated created_at for the trigger instance */ createdAt: string; } } } export interface TriggerInstanceUpsertResponse { /** * ID of the updated trigger */ trigger_id: string; } export interface TriggerInstanceListActiveParams { /** * Array of auth config IDs to filter triggers by */ auth_config_ids?: Array | null; /** * DEPRECATED: This parameter will be removed in a future version. Please use * auth_config_ids instead. */ authConfigIds?: Array | null; /** * Array of connected account IDs to filter triggers by */ connected_account_ids?: Array | null; /** * DEPRECATED: This parameter will be removed in a future version. Please use * connected_account_ids instead. */ connectedAccountIds?: Array | null; /** * Cursor for pagination. The cursor is a base64 encoded string of the page and * limit. The page is the page number and the limit is the number of items per * page. The cursor is used to paginate through the items. The cursor is not * required for the first page. */ cursor?: string; /** * DEPRECATED: This parameter will be removed in a future version. Please use * auth_config_ids instead. */ deprecatedAuthConfigUuids?: Array | null; /** * DEPRECATED: This parameter will be removed in a future version. Please use * connected_account_ids instead. */ deprecatedConnectedAccountUuids?: Array | null; /** * Number of items per page, max allowed is 1000 */ limit?: number | null; /** * When set to true, includes disabled triggers in the response. */ show_disabled?: boolean | null; /** * DEPRECATED: This parameter will be removed in a future version. Please use * show_disabled instead. */ showDisabled?: boolean | null; /** * Array of trigger IDs to filter triggers by */ trigger_ids?: Array | null; /** * Array of trigger names to filter triggers by. Case-insensitive (internally * normalized to uppercase). */ trigger_names?: Array | null; /** * DEPRECATED: This parameter will be removed in a future version. Please use * trigger_ids instead. */ triggerIds?: Array | null; /** * DEPRECATED: This parameter will be removed in a future version. Please use * trigger_names instead. */ triggerNames?: Array | null; /** * Array of user IDs to filter triggers by */ user_ids?: Array | null; } export interface TriggerInstanceUpsertParams { /** * Connected account nanoid. Optional when user_id is provided — the first active * connection for that user and the trigger's toolkit is auto-resolved. */ connected_account_id?: string; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use connected_account_id instead. */ connectedAuthId?: string; /** * Toolkit version specification. Supports "latest" string or a record mapping * toolkit slugs to specific versions. */ toolkit_versions?: string | { [key: string]: string } | null; /** * Trigger configuration */ trigger_config?: { [key: string]: unknown }; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use trigger_config instead. */ triggerConfig?: { [key: string]: unknown }; /** * The user id (entity id) that owns the connection. When connected_account_id is * omitted, the first active connection for this user and the trigger's toolkit is * auto-resolved (same as tool execution). When connected_account_id is also * provided and the project has 2FA enabled, user_id is validated against the owner * of that connection. */ user_id?: string; /** * @deprecated DEPRECATED: This parameter will be removed in a future version. * Please use toolkit_versions instead. */ version?: string; } TriggerInstances.Manage = Manage; export declare namespace TriggerInstances { export { type TriggerInstanceListActiveResponse as TriggerInstanceListActiveResponse, type TriggerInstanceUpsertResponse as TriggerInstanceUpsertResponse, type TriggerInstanceListActiveParams as TriggerInstanceListActiveParams, type TriggerInstanceUpsertParams as TriggerInstanceUpsertParams, }; export { Manage as Manage, type ManageUpdateResponse as ManageUpdateResponse, type ManageDeleteResponse as ManageDeleteResponse, type ManageUpdateParams as ManageUpdateParams, }; }