Executors
Executors in Scheduler0 define where and how your scheduled jobs will be executed. They provide the execution environment and infrastructure needed to run your jobs, supporting various execution types including webhooks and cloud functions.
Overview
Executors act as the bridge between Scheduler0's scheduling system and your actual job execution infrastructure. They define the target environment, authentication details, and execution parameters needed to run your jobs successfully.
Executor Structure
{
"id": 1,
"accountId": 123,
"name": "Production Webhook Executor",
"type": "webhook_url",
"cloudProvider": null,
"region": null,
"cloudResourceUrl": null,
"webhookUrl": "https://api.example.com/webhook",
"webhookMethod": "POST",
"webhookSecret": "secret_key_123",
"cloudApiKey": null,
"cloudApiSecret": null,
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": null,
"createdBy": "user123",
"modifiedBy": null,
"deletedBy": null
}
Fields
- id: Unique identifier for the executor
- accountId: ID of the account that owns this executor
- name: Human-readable name for the executor
- type: Type of executor (webhook_url, cloud_function)
- cloudProvider: Cloud provider for cloud function executors (aws, azure, gcp)
- region: Cloud region where the executor is located
- cloudResourceUrl: URL or identifier of the cloud resource
- webhookUrl: URL for webhook-based execution
- webhookMethod: HTTP method for webhook calls (GET, POST, PUT, DELETE)
- webhookSecret: Secret key for webhook authentication
- cloudApiKey: API key for cloud provider authentication
- cloudApiSecret: API secret for cloud provider authentication
- dateCreated: Timestamp when the executor was created
- dateModified: Timestamp when the executor was last modified
- createdBy: Identifier of the user who created the executor
- modifiedBy: Identifier of the user who last modified the executor
- deletedBy: Identifier of the user who deleted the executor
Executor Types
1. Webhook URL Executor
Webhook executors send HTTP requests to specified URLs when jobs are triggered.
Configuration
{
"name": "API Webhook Executor",
"type": "webhook_url",
"webhookUrl": "https://api.example.com/webhook",
"webhookMethod": "POST",
"webhookSecret": "your_secret_key"
}
Use Cases
- REST API endpoints
- Microservice endpoints
- Third-party service integrations
- Custom application endpoints
Request Payload
When a job is executed, the webhook executor sends the complete job object as the request payload:
{
"id": 123,
"projectId": 456,
"executorId": 789,
"spec": "0 2 * * *",
"data": "{\"action\": \"process_data\", \"target\": \"database\"}",
"startDate": "2024-01-15T00:00:00Z",
"endDate": "2024-12-31T23:59:59Z",
"retryMax": 3,
"timezone": "UTC",
"timezoneOffset": 0,
"status": "active",
"executionId": "abc123",
"accountId": 1,
"dateCreated": "2024-01-15T10:30:00Z"
}
The data field contains the job-specific data as a JSON string, which you can parse in your webhook handler.
2. Cloud Function Executor
Cloud function executors invoke serverless functions on cloud platforms.
AWS Lambda
{
"name": "AWS Lambda Executor",
"type": "cloud_function",
"cloudProvider": "aws",
"region": "us-east-1",
"cloudResourceUrl": "arn:aws:lambda:us-east-1:123456789012:function:my-function",
"cloudApiKey": "AKIAIOSFODNN7EXAMPLE",
"cloudApiSecret": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
}
Azure Functions
{
"name": "Azure Function Executor",
"type": "cloud_function",
"cloudProvider": "azure",
"cloudResourceUrl": "https://myfunctionapp.azurewebsites.net/api/myfunction",
"cloudApiKey": "your_function_key"
}
Google Cloud Functions
{
"name": "GCP Function Executor",
"type": "cloud_function",
"cloudProvider": "gcp",
"region": "us-central1",
"cloudResourceUrl": "https://us-central1-myproject.cloudfunctions.net/myfunction",
"cloudApiKey": "your_service_account_key"
}
Payload Format
All executors (webhooks, AWS Lambda, Azure Functions, and GCP Functions) receive the complete job object as their payload. Here's what the job object looks like:
{
"id": 123,
"projectId": 456,
"executorId": 789,
"spec": "0 2 * * *",
"data": "{\"action\": \"process_data\", \"target\": \"database\"}",
"startDate": "2024-01-15T00:00:00Z",
"endDate": "2024-12-31T23:59:59Z",
"retryMax": 3,
"timezone": "UTC",
"timezoneOffset": 0,
"status": "active",
"executionId": "abc123...",
"accountId": 1,
"dateCreated": "2024-01-15T10:30:00Z",
"createdBy": "user123"
}
Note: The data field contains job-specific data as a JSON-encoded string. Parse it in your handler to access your custom job data.
Creating Executors
Webhook Executor
curl -X POST "https://api.scheduler0.com/v1/executors" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Secret-Key: YOUR_API_SECRET" \
-d '{
"name": "Production API Executor",
"type": "webhook_url",
"webhookUrl": "https://api.example.com/webhook",
"webhookMethod": "POST",
"webhookSecret": "secret_key_123",
"createdBy": "user123"
}'
Node.js Client Example
const Scheduler0Client = require('@scheduler0/node-client');
const client = new Scheduler0Client({
apiKey: 'your_api_key',
apiSecret: 'your_secret_key',
baseURL: 'https://api.scheduler0.com/v1'
});
// Create a webhook executor
const executor = await client.executors.create({
name: "Production API Executor",
type: "webhook_url",
webhookUrl: "https://api.example.com/webhook",
webhookMethod: "POST",
webhookSecret: "secret_key_123",
createdBy: "user123"
});
console.log('Created executor:', executor.data);
AWS Lambda Executor
curl -X POST "https://api.scheduler0.com/v1/executors" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Secret-Key: YOUR_API_SECRET" \
-d '{
"name": "Data Processing Lambda",
"type": "cloud_function",
"cloudProvider": "aws",
"region": "us-east-1",
"cloudResourceUrl": "arn:aws:lambda:us-east-1:123456789012:function:data-processor",
"cloudApiKey": "AKIAIOSFODNN7EXAMPLE",
"cloudApiSecret": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"createdBy": "user123"
}'
Node.js Client Example
// Create an AWS Lambda executor
const lambdaExecutor = await client.executors.create({
name: "Data Processing Lambda",
type: "cloud_function",
cloudProvider: "aws",
region: "us-east-1",
cloudResourceUrl: "arn:aws:lambda:us-east-1:123456789012:function:data-processor",
cloudApiKey: "AKIAIOSFODNN7EXAMPLE",
cloudApiSecret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
createdBy: "user123"
});
console.log('Created Lambda executor:', lambdaExecutor.data);
Managing Executors
Listing Executors
curl -X GET "https://api.scheduler0.com/v1/executors?limit=10&offset=0" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-API-Secret: YOUR_API_SECRET"
Node.js Client Example
// List all executors
const executors = await client.executors.list(10, 0);
console.log(`Found ${executors.data.length} executors`);
Updating Executors
curl -X PUT "https://api.scheduler0.com/v1/executors/1" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Secret-Key: YOUR_API_SECRET" \
-d '{
"name": "Updated Executor Name",
"webhookUrl": "https://new-api.example.com/webhook",
"modifiedBy": "user123"
}'
Node.js Client Example
// Update an executor
const updatedExecutor = await client.executors.update(1, {
name: "Updated Executor Name",
webhookUrl: "https://new-api.example.com/webhook",
modifiedBy: "user123"
});
console.log('Updated executor:', updatedExecutor.data);
Deleting Executors
curl -X DELETE "https://api.scheduler0.com/v1/executors/1" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Secret-Key: YOUR_API_SECRET" \
-d '{
"deletedBy": "user123"
}'
Node.js Client Example
// Delete an executor
await client.executors.delete(1, {
deletedBy: "user123"
});
console.log('Executor deleted successfully');
API Reference
For complete API documentation, see the Scheduler0 API Reference.
Related Components
- Jobs - Individual scheduled tasks that use executors
- Projects - Organizational units for jobs
- Credentials - Authentication for API access