BlocktionBlocktion Docs

Documentation

Triggers

Automate workflows with webhook, schedule, data, and event-based triggers

What is a Trigger?

A trigger starts a workflow when a defined condition occurs, such as receiving a webhook, a scheduled time, a data change, or a custom event. Triggers manage activation, state, and metrics, and can be enabled, paused, resumed, or disabled.

Trigger Types

Webhook Triggers

HTTP webhook-based triggers

Examples:

GitHub WebhooksStripe EventsSlack Commands

Schedule Triggers

Time-based scheduled triggers

Examples:

Daily ReportsWeekly BackupsMonthly Cleanup

Data Triggers

Data change-based triggers

Examples:

Database ChangesFile UploadsAPI Responses

Event Triggers

Custom event-based triggers

Examples:

User ActionsSystem EventsCustom Events

Trigger States

INACTIVE

Trigger is not active

ACTIVE

Trigger is active and monitoring

PAUSED

Trigger is temporarily paused

ERROR

Trigger has an error condition

Trigger Configuration

Understanding how to configure different types of triggers

Webhook Triggers

  • • Configure webhook URL
  • • Set authentication method
  • • Define payload validation
  • • Handle retry logic

Schedule Triggers

  • • Set cron expressions
  • • Configure timezone
  • • Handle daylight saving
  • • Set execution limits

Data Triggers

  • • Monitor data changes
  • • Set change thresholds
  • • Configure polling intervals
  • • Handle data validation

Event Triggers

  • • Define event types
  • • Set event filters
  • • Configure event handlers
  • • Manage event queues

Overview

Triggers automate workflows based on various events like webhooks, schedules, data changes, or custom events.

Trigger Types

  • • Webhook - HTTP-based triggers
  • • Schedule - Time-based triggers
  • • Data - Data change triggers
  • • Event - Custom event triggers

Key Features

  • • Real-time event processing
  • • Flexible trigger conditions
  • • Health monitoring and metrics
  • • Automatic retry and error handling

Endpoints

POST/api/triggers

Create Trigger

Create and set up a new trigger

Request Body

{
  "trigger_id": "string (required)",
  "workflow_id": "string (required)",
  "block_id": "string (required)",
  "trigger_config": "object (required)"
}

Response

{
  "success": true,
  "message": "Trigger trigger_123456 created successfully",
  "trigger": {
    "trigger_id": "trigger_123456",
    "workflow_id": "workflow_789012",
    "block_id": "block_456",
    "trigger_type": "schedule",
    "status": "ACTIVE",
    "created_at": "2024-01-15T10:30:00Z",
    "last_triggered": null,
    "trigger_count": 0,
    "error_count": 0,
    "last_error": null
  }
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "trigger_id": "string (required)",
  "workflow_id": "string (required)",
  "block_id": "string (required)",
  "trigger_config": "object (required)"
}'
GET/api/triggers

List Triggers

List triggers with optional filtering

Query Parameters

workflow_id(string)Filter by workflow ID
trigger_type(string)Filter by trigger type
status(string)Filter by status

Response

{
  "triggers": [
    {
      "trigger_id": "trigger_123456",
      "workflow_id": "workflow_789012",
      "block_id": "block_456",
      "trigger_type": "schedule",
      "status": "ACTIVE",
      "created_at": "2024-01-15T10:30:00Z",
      "last_triggered": "2024-01-20T09:00:00Z",
      "trigger_count": 5,
      "error_count": 0,
      "last_error": null
    }
  ],
  "total_count": 1,
  "filters_applied": {
    "workflow_id": null,
    "trigger_type": null,
    "status": null
  }
}

cURL Example

curl -X GET "https://api.blocktion.io/api/triggers" \
  -H "Authorization: Bearer <your_access_token>"
GET/api/triggers/{trigger_id}

Get Trigger

Get detailed information about a specific trigger

Response

{
  "success": true,
  "trigger": {
    "trigger_id": "trigger_123456",
    "workflow_id": "workflow_789012",
    "block_id": "block_456",
    "trigger_type": "schedule",
    "status": "ACTIVE",
    "created_at": "2024-01-15T10:30:00Z",
    "last_triggered": "2024-01-20T09:00:00Z",
    "trigger_count": 5,
    "error_count": 0,
    "last_error": null
  }
}

cURL Example

curl -X GET "https://api.blocktion.io/api/triggers/{trigger_id}" \
  -H "Authorization: Bearer <your_access_token>"
POST/api/triggers/{trigger_id}/activate

Activate Trigger

Activate a trigger and start workflow execution

Request Body

{
  "activation_data": "object (optional)",
  "activation_source": "string (optional)"
}

Response

{
  "success": true,
  "message": "Trigger trigger_123456 activated successfully",
  "session": {
    "session_id": "session_789",
    "workflow_id": "workflow_789012",
    "status": "pending"
  },
  "activation": {
    "activation_id": "activation_456",
    "workflow_id": "workflow_789012",
    "activated_at": "2024-01-15T10:30:00Z",
    "activation_source": "api"
  }
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/{trigger_id}/activate" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "activation_data": "object (optional)",
  "activation_source": "string (optional)"
}'
POST/api/triggers/{trigger_id}/pause

Pause Trigger

Pause a trigger

Response

{
  "success": true,
  "message": "Trigger trigger_123456 paused successfully"
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/{trigger_id}/pause" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>"
POST/api/triggers/{trigger_id}/resume

Resume Trigger

Resume a paused trigger

Response

{
  "success": true,
  "message": "Trigger trigger_123456 resumed successfully"
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/{trigger_id}/resume" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>"
DELETE/api/triggers/{trigger_id}

Delete Trigger

Delete a trigger

Response

{
  "success": true,
  "message": "Trigger trigger_123456 deleted successfully"
}

cURL Example

curl -X DELETE "https://api.blocktion.io/api/triggers/{trigger_id}" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>"
GET/api/triggers/metrics

Get Trigger Metrics

Get comprehensive trigger metrics

Response

{
  "success": true,
  "metrics": {
    "total_triggers": 10,
    "active_triggers": 8,
    "paused_triggers": 2,
    "total_activations": 150,
    "error_rate": 0.02
  }
}

cURL Example

curl -X GET "https://api.blocktion.io/api/triggers/metrics" \
  -H "Authorization: Bearer <your_access_token>"
POST/api/triggers/events/emit

Emit Event

Emit an event to trigger event-based triggers

Request Body

{
  "event_type": "string (required)",
  "event_data": "object (optional)",
  "event_source": "string (optional)",
  "event_id": "string (optional)"
}

Response

{
  "success": true,
  "message": "Event user_action emitted successfully",
  "activations_created": 2,
  "activations": [
    {
      "activation_id": "activation_123",
      "trigger_id": "trigger_456",
      "workflow_id": "workflow_789"
    }
  ]
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/events/emit" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "event_type": "string (required)",
  "event_data": "object (optional)",
  "event_source": "string (optional)",
  "event_id": "string (optional)"
}'
POST/api/triggers/webhooks/process

Process Webhook

Process a webhook request

Request Body

{
  "endpoint_path": "string (required)",
  "method": "string (required)",
  "headers": "object (optional)",
  "body": "bytes (optional)",
  "query_params": "object (optional)",
  "source_ip": "string (optional)"
}

Response

{
  "success": true,
  "result": {
    "processed": true,
    "activations_created": 1
  }
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/webhooks/process" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "endpoint_path": "string (required)",
  "method": "string (required)",
  "headers": "object (optional)",
  "body": "bytes (optional)",
  "query_params": "object (optional)",
  "source_ip": "string (optional)"
}'
GET/api/triggers/health

Health Check

Perform a health check on the trigger system

Response

{
  "success": true,
  "health": {
    "status": "healthy",
    "uptime": 3600,
    "active_triggers": 8
  }
}

cURL Example

curl -X GET "https://api.blocktion.io/api/triggers/health" \
  -H "Authorization: Bearer <your_access_token>"
POST/api/triggers/{trigger_id}/enable

Enable Trigger

Enable a trigger (make it active)

Request Body

{
  "user_id": "string (optional)",
  "reason": "string (optional)"
}

Response

{
  "success": true,
  "message": "Trigger enabled successfully"
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/{trigger_id}/enable" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "user_id": "string (optional)",
  "reason": "string (optional)"
}'
POST/api/triggers/{trigger_id}/disable

Disable Trigger

Disable a trigger (make it inactive)

Request Body

{
  "user_id": "string (optional)",
  "reason": "string (optional)"
}

Response

{
  "success": true,
  "message": "Trigger disabled successfully"
}

cURL Example

curl -X POST "https://api.blocktion.io/api/triggers/{trigger_id}/disable" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "user_id": "string (optional)",
  "reason": "string (optional)"
}'

Best Practices

Guidelines for creating and managing triggers effectively

Design

  • • Use descriptive trigger names
  • • Set appropriate timeouts
  • • Implement proper error handling
  • • Monitor trigger performance

Security

  • • Validate webhook signatures
  • • Use secure authentication
  • • Implement rate limiting
  • • Monitor for suspicious activity