AI-powered API testing workflow built with n8n, JavaScript, OpenAI, and Postman.
The workflow automatically executes REST API tests, validates HTTP status codes and real response time, classifies failures, and uses AI to generate QA analysis only when a test fails.
Webhook
↓
Start Timer
↓
HTTP Request
↓
JavaScript Validation
↓
IF
├── FAIL → OpenAI Analysis → Edit Fields
└── PASS → Edit Fields
↓
Respond to Webhook
- Automated REST API testing
- Expected vs actual HTTP status validation
- Real API response-time measurement
- Configurable
maxResponseTime - Automatic PASS / FAIL detection
- Separate
statusPassedandresponseTimePassedchecks - Failure classification with
failureReason - AI analysis triggered only for failed tests
- Structured JSON QA reports
- Postman webhook integration
The workflow records the request start time before the API call:
requestStartedAt: Date.now()and calculates the actual API response time after the request:
const responseTime = Date.now() - requestStartedAt;The test passes only when both checks succeed:
const statusPassed = actualStatus === expectedStatus;
const responseTimePassed = responseTime <= maxResponseTime;
const passed = statusPassed && responseTimePassed;Example request:
{
"testName": "API response time test",
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET",
"expectedStatus": 200,
"maxResponseTime": 2000
}{
"expectedStatus": 200,
"actualStatus": 200,
"maxResponseTime": 2000,
"responseTime": 81,
"statusPassed": true,
"responseTimePassed": true,
"result": "PASS",
"failureReason": "NONE"
}{
"expectedStatus": 200,
"actualStatus": 200,
"maxResponseTime": 1,
"responseTime": 58,
"statusPassed": true,
"responseTimePassed": false,
"result": "FAIL",
"failureReason": "RESPONSE_TIME"
}When a test fails, it is automatically routed to OpenAI for additional QA analysis and investigation recommendations.
The workflow can classify failures as:
NONE
STATUS_CODE
RESPONSE_TIME
STATUS_AND_RESPONSE_TIME
- n8n
- JavaScript
- OpenAI
- Postman
- REST API
- Webhooks
- JSON
This project demonstrates practical experience with:
- QA automation
- API testing
- workflow automation
- response-time validation
- JavaScript validation logic
- conditional AI execution
- AI-assisted failure analysis
- structured QA reporting
README.md
workflow.json
n8n-workflow-scrin.png
The exported workflow.json can be imported into another n8n instance after configuring the required credentials.
Built an AI-powered API QA workflow that automates REST API validation, measures real response time, detects functional and performance failures, and uses OpenAI to generate actionable QA analysis only when failures occur.
