API Academy
🌐 English
  • 🌐 English
  • 🌐 繁體中文
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Testing APIs
  • Introduction
  • Table of Contents
  • API Academy
    • Get Started
      • What is an API?
      • How Does an API Work?
      • How to Call an API?
      • How to Read an API Documentation?
      • Chapter Summary
      • Get realtime weather
    • API Fundamentals
      • API Funtamentals: Overview
      • Method & Path
      • Parameters
      • Request Body
      • Responses
      • API Specification & OAS
      • Chapter Summary
    • Working with APIs
      • Working with APIs: Overview
      • Making Requests from Spec
      • Environments and Variables
      • Chaining Multiple Endpoints
      • Handling Authentication
      • Handling API Signatures
      • Introduction to Scripts
      • Chapter Summary
    • Mocking APIs
      • Mocking APIs: Overview
      • Smart Mock
      • Mock Expectations
      • Cloud Mock
      • Mock Scripts
      • Chapter Summary
    • Designing APIs
      • Designing APIs: Overview
      • Introduction to API Design
      • Creating Your First API Project
      • Analyzing Requirements and Planning Your API
      • Designing Data Models
      • Designing Endpoints
      • Using Components and Reusability
      • Setting Up Authentication
      • API Design Guidelines
      • Chapter Summary
    • Developing APIs
      • Developing APIs: Overview
      • Setup: Install Your AI Coding Assistant
      • Quick Start: From Spec to Running API in 30 Minutes
      • Understanding the Generated Code
      • Testing Your API with Apidog
      • Deployment: Put Your API Online
      • Chapter Summary
    • Testing APIs
      • Testing APIs: Overview
      • Getting Started: Your First Test Scenario
      • Integration Testing and Data Passing
      • Dynamic Values
      • Assertions and Validations
      • Flow Control: If, For, ForEach
      • Data-Driven Testing
      • Performance Testing
      • Test Reports and Analysis
      • CI/CD Integration
      • Scheduled Tasks and Automation
      • Advanced Testing Strategies
      • Chapter Summary
    • API Documentations
      • API Documentations: Overview
      • Publishing Your First API Doc
      • Customizing Documentation Appearance
      • Interactive Features for Consumers
      • Advanced Publishing Settings
      • Managing API Versions
      • Chapter Summary
    • Advanced API Technologies
      • API Technologies: Overview
      • GraphQL
      • gRPC
      • WebSocket
      • Socket.IO
      • Server-Sent Events (SSE)
      • SOAP
      • Chapter Summary
    • API Lifecycle
      • API Lifecycle: Overview
      • Stages of the API Lifecycle
      • API Governance
      • API Security Best Practices
      • Monitoring and Analytics
      • API Versioning Strategies
      • The Future of APIs
      • Chapter Summary
    • API Security
      • API Security: Overview
      • API Security Fundamentals
      • Authentication vs Authorization
      • Understanding OAuth 2.0 and OpenID Connect
      • JSON Web Tokens (JWT)
      • OWASP API Security Top 10
      • Encryption and HTTPS
      • Chapter Summary
    • API Tools
      • API Tools: Overview
      • The Evolution of API Tools
      • API Clients
      • Command Line Tools (cURL, HTTPie)
      • API Design and Documentation Tools
      • API Mocking Tools
      • API Testing Tools
      • All-in-One API Platforms
      • Chapter Summary
    • API Gateway
      • API Gateway: Overview
      • What is an API Gateway?
      • Key Features of API Gateways
      • API Gateway vs Load Balancer vs Service Mesh
      • Popular API Gateway Solutions
      • The BFF (Backend for Frontend) Pattern
      • Chapter Summary
  • Modern Pet Store
    • Pet
      • Get Pet
      • Update Pet
      • Delete Pet
      • Create Pet
      • List Pets
      • Upload Pet Image
    • User
      • Update User
      • Get User
      • Delete User
      • Login
      • Logout
      • Create User
    • Store
      • List Inventory
      • Create Order
      • Get Order
      • Delete Order
      • Callback Example
      • Pay for an Order
    • Payments
      • Pay Order
    • Chat
      • Create Chat Completion
    • Webhooks
      • Pet Adopted Event
      • New Pet Available Event
  • Schemas
    • Pet
    • Category
    • User
    • ApiResponse
    • OrderPayment
    • Tag
    • Order
    • Links-Order
    • PetCollection
    • Bank Card
    • Bank Account
    • Links
    • Error
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Testing APIs

Scheduled Tasks and Automation

APIs don't only break when you change code. They break when the database disk fills up, when a 3rd party license expires, or when the network fluctuates.
CI/CD protects you from bad code, but Scheduled Tasks protect you from bad environments.
In Apidog, Scheduled Tasks allow you to run your Test Scenarios automatically at specific intervals.

The Engine: Self-Hosted Runner#

Unlike some cloud-only tools, Apidog uses a Self-hosted Runner (General Runner) to execute scheduled tasks.

Why Self-Hosted?#

1.
Security: The runner sits inside your network (or VPC). It can access your internal Staging/Dev databases and local APIs (localhost) that the public cloud cannot reach.
2.
Control: You manage the resources and environment dependencies (like database drivers or SSL certificates).

Setting up a Runner#

Before creating a task, you need a runner online.
1.
Go to Settings (Team) > General Runner.
2.
Apidog provides a simple Docker command:
3.
Run this on your server (Linux/Mac/Windows).
4.
Once the runner status changes to "Started" in Apidog, you are ready to automate.
Deploy General Runner
See details: General Runner

Creating a Scheduled Task#

Once your "Engine" (Runner) is running, you can tell it what to do.
1.
Navigate to Testing > Scheduled Tasks.
2.
Click New Task.
New Scheduled Task

1. Select Scenarios#

Pick the Test Scenarios you created earlier (e.g., "User Lifecycle"). You can chain multiple scenarios together in one task.

2. Configure Environment & Variables#

This is a critical step. Since the task runs automatically, you must define:
Environment: Which environment to test against (e.g., Staging).
Test Data: If your scenario relies on CSVs, ensure they are configured.
Variable Scope:
When running multiple scenarios, you need to decide how variables are shared:
Share only in current scenario: Variables reset after each scenario.
Share across task: Scenario A can pass a {{token}} to Scenario B.

3. Set the Schedule#

Define when the "Engine" starts the car.
Frequency: Every X minutes/hours, or specific days/times.
Cron Expression: For advanced users needing complex schedules (e.g., "Every weekday at 9 AM").

4. Notifications#

A monitor is useless if nobody sees the red light.
Channels: Email, Slack, Microsoft Teams, DingTalk, etc.
Conditions:
Notify always: Good for daily reports.
Notify on failure: Anti-spam mode. Only bug you when something breaks.
Scheduled Task Config
See details: Scheduled Tasks

Real Case: Production Health Monitor#

Let's set up a "Smoke Test" that runs every 15 minutes to ensure critical paths are working.
Configuration:
Scenarios:
1.
GET /public-status (Fast check)
2.
POST /auth/login (Critical dependency check)
Runner: "Prod-Monitor-Runner" (A runner deployed in the Prod VPC).
Schedule: Every 15 minutes.
Notification: Slack Channel #ops-alerts (Only on Failure).
Now, if your Auth service goes down at 3 AM, the Runner detects the 500 Error and immediately pings Slack.

Key Takeaways#

Scheduled Tasks turn tests into monitors.
Self-Hosted Runners allow you to test internal/private network APIs securely.
Use Notifications effectively to alert the right people without noise.
Ensure Variable Scopes are correctly set if chaining multiple scenarios.

What's Next#

We have covered the entire lifecycle from the first click to 24/7 monitoring. We have one final chapter to discuss advanced strategies like security and contract testing.
Continue with β†’ Advanced Testing Strategies
Modified atΒ 2025-12-25 09:54:41
Previous
CI/CD Integration
Next
Advanced Testing Strategies
Built with