PD

PayDirect Blog

Unleashing New Powers: Automation and Webhook Enhancements on PayDirect

PD

PayDirect Team

Jun 1, 2026·4 min read

Unleashing New Powers: Automation and Webhook Enhancements on PayDirect

Hey, fellow developers! Gather 'round because we’ve got some hot-off-the-presses updates that are going to make your life not just easier, but let’s face it, way cooler. You know that feeling when you deploy something awesome and want to flex a bit to your dev squad? Well, get ready to flex those enhancements on PayDirect — our beloved crypto settlement platform on Base (Ethereum L2). 🚀

What’s New: Action Endpoints and Webhooks Galore

So, what’s cooking in this latest update? Well, thanks to our friends at GlobalVentures.com, we’ve beefed up the platform with shiny new action endpoints and webhook events for deployment and automation. It’s like giving PayDirect its very own superhero cape. 🦸‍♂️

Cancel Automations Like a Pro

First up, let’s talk about the new capability to cancel automations. We’ve got a nifty new endpoint that lets you do just that. Check out this snippet from app/api/v1/actions/automations/[id]/cancel/route.ts:

export async function POST(
  request: NextRequest,
  { params }: { params: Promise<{ id: string }> },
) {
  const auth = await authenticateApiKey(request);
  if (isAuthError(auth)) return auth;

  const rateLimited = checkRateLimit(auth);
  if (rateLimited) return rateLimited;

  const { id } = await params;
  try {
    const cancelled = await OnchainAutomationService.cancel(auth.workspaceId, id);
    if (!cancelled) {
      return NextResponse.json(
        { error: "Automation not found or already cancelled" },
        { status: 404, headers: getRateLimitHeaders(auth) },
      );
    }

    WebhookEngine.deliverEvent(auth.workspaceId, "automation.cancelled", cancelled).catch(() => {});
    logApiResponse(auth, 200, { automationId: id, status: "cancelled" });

    return NextResponse.json(
      { automation: cancelled, timestamp: new Date().toISOString() },
      { headers: getRateLimitHeaders(auth) },
    );
  } catch (err) {
    console.error("[API] POST /v1/actions/automations/[id]/cancel error:", err);
    return NextResponse.json(
      { error: "Failed to cancel automation" },
      { status: 500, headers: getRateLimitHeaders(auth) },
    );
  }
}

Why does this matter? Let’s say you’ve got an automation running wild, and it’s time to put a stop to it faster than you can spell "catastrophe". Now you can call this endpoint and bam — you’re back in control.

Create and List Automations Like a Wizard

Next, we’ve added the power to create and list automations. Yep, it’s like adding spells to your dev wand. Here’s a peek into app/api/v1/actions/automations/route.ts:

export async function POST(request: NextRequest) {
  const auth = await authenticateApiKey(request);
  if (isAuthError(auth)) return auth;

  try {
    const body = await request.json();
    const triggerType = typeof body.triggerType === "string" ? body.triggerType : "";
    if (!["interval", "condition"].includes(triggerType)) {
      return NextResponse.json(
        { error: "triggerType is required and must be interval or condition" },
        { status: 400, headers: getRateLimitHeaders(auth) },
      );
    }

    const action = body.action || {};
    const actionType = typeof action.type === "string" ? action.type : "";
    if (!["transfer", "swap", "deploy"].includes(actionType)) {
      return NextResponse.json(
        { error: "action.type is required and must be transfer, swap, or deploy" },
        { status: 400, headers: getRateLimitHeaders(auth) },
      );
    }

    // Create the automation
    const record = await OnchainAutomationService.create({
      workspaceId: auth.workspaceId,
      triggerType,
      actionType,
      actionPayload: action.payload || {},
    });

    return NextResponse.json(
      { automation: record, timestamp: new Date().toISOString() },
      { status: 201, headers: getRateLimitHeaders(auth) },
    );
  } catch (err) {
    console.error("[API] POST /v1/actions/automations error:", err);
    return NextResponse.json(
      { error: "Failed to create automation" },
      { status: 500, headers: getRateLimitHeaders(auth) },
    );
  }
}

Why You Should Care

These updates are more than just a fancy addition—they’re a game-changer for managing your crypto transactions and AI-powered projects. Automations can now be fine-tuned and controlled at will, while the enhanced webhook events ensure you’re always in the loop when stuff happens. It’s like having a crystal ball, but for your crypto operations.

Wrap-Up: Get Your Hands Dirty

Ready to dive in and explore these features? The new endpoints and webhook enhancements are live, and it’s time to level up your PayDirect experience. Whether you’re deploying, swapping, or simply managing automations, these tools are here to make it as smooth as a perfectly executed git merge. 😎

So, what are you waiting for? Check out the updated docs, give the new endpoints a spin, and let us know what you think. Your feedback shapes the future of PayDirect, and we’re all ears.

Happy coding and until next time, keep pushing those commits like a boss! 💪

Check out the docs | View the complete diff | Join the community

Tip the Author

Powered by PayDirect on Base

Enjoyed this post? Send a tip using crypto. We eat our own dog food.

USDC

More from PayDirect

Powered by ContentAgent