curl --request POST \
--url https://api.example.com/api/automations/{id}/run{
"success": true,
"processed": 123,
"sent": 123,
"skipped": 123,
"failed": 123,
"errors": [
{}
],
"message": "<string>",
"timestamp": "<string>"
}Execute a marketing automation manually
curl --request POST \
--url https://api.example.com/api/automations/{id}/run{
"success": true,
"processed": 123,
"sent": 123,
"skipped": 123,
"failed": 123,
"errors": [
{}
],
"message": "<string>",
"timestamp": "<string>"
}POST /api/automations/{id}/run
curl -X POST https://your-domain.com/api/automations/123e4567-e89b-12d3-a456-426614174000/run \
-H "Cookie: your-session-cookie"
{
"success": true,
"processed": 45,
"sent": 42,
"skipped": 2,
"failed": 1,
"errors": [
"Failed to send to +34612345678: Invalid phone number"
],
"timestamp": "2026-03-04T10:30:00.000Z"
}
{
"success": true,
"message": "Automation is not active",
"processed": 0,
"sent": 0,
"skipped": 0,
"failed": 0,
"timestamp": "2026-03-04T10:30:00.000Z"
}
{
"success": false,
"error": "Automation not found",
"timestamp": "2026-03-04T10:30:00.000Z"
}
{
"error": "Automation ID is required",
"timestamp": "2026-03-04T10:30:00.000Z"
}
export const maxDuration = 300; // 5 minutes
runAutomationCheck() server action:
import { runAutomationCheck } from '@/app/actions/automations';
export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const { id: automationId } = await params;
const result = await runAutomationCheck(automationId);
if (result.error) {
return NextResponse.json({
success: false,
error: result.error,
timestamp: new Date().toISOString()
}, { status: 500 });
}
return NextResponse.json({
success: true,
processed: result.processed || 0,
sent: result.sent || 0,
skipped: result.skipped || 0,
failed: result.failed || 0,
errors: result.errors || [],
timestamp: new Date().toISOString()
});
}
automation_logslogger.info("Automation executed successfully", "AutomationsAPI", {
automationId,
processed: result.processed,
sent: result.sent,
skipped: result.skipped,
failed: result.failed
});