> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/vercel/workflow/llms.txt
> Use this file to discover all available pages before exploring further.

# resumeHook / resumeWebhook

> Resume workflows by sending data to hooks and webhooks

## Overview

`resumeHook()` and `resumeWebhook()` allow you to resume paused workflows by sending data from external contexts like API routes or server actions. These functions deliver payloads to hooks created with `createHook()` or `createWebhook()`.

## resumeHook

Resume a workflow by sending data to a hook identified by its token.

### Signature

```typescript theme={null}
function resumeHook<T = any>(
  tokenOrHook: string | Hook,
  payload: T,
  encryptionKeyOverride?: CryptoKey
): Promise<Hook>
```

### Parameters

<ParamField path="tokenOrHook" type="string | Hook" required>
  The unique token identifying the hook, or the hook object itself
</ParamField>

<ParamField path="payload" type="T" required>
  The data payload to send to the hook. Must be serializable.
</ParamField>

<ParamField path="encryptionKeyOverride" type="CryptoKey">
  Optional encryption key override for the payload
</ParamField>

### Returns

<ResponseField name="Hook" type="Promise<Hook>">
  Promise resolving to the hook object containing `runId`, `token`, and `metadata`
</ResponseField>

### Example

```typescript theme={null}
import { resumeHook } from 'workflow/api';

// In an API route
export async function POST(request: Request) {
  const { token, data } = await request.json();
  
  try {
    const hook = await resumeHook(token, data);
    return Response.json({ 
      success: true,
      runId: hook.runId 
    });
  } catch (error) {
    return new Response('Hook not found', { status: 404 });
  }
}
```

## resumeWebhook

Resume a workflow via a webhook by sending an HTTP request. This function processes the incoming request and sends the response.

### Signature

```typescript theme={null}
function resumeWebhook(
  token: string,
  request: Request
): Promise<Response>
```

### Parameters

<ParamField path="token" type="string" required>
  The unique token identifying the webhook
</ParamField>

<ParamField path="request" type="Request" required>
  The incoming HTTP request object
</ParamField>

### Returns

<ResponseField name="Response" type="Promise<Response>">
  Promise resolving to the HTTP response from the workflow's `respondWith()` call
</ResponseField>

### Example

```typescript theme={null}
import { resumeWebhook } from 'workflow/api';

// In an API route that handles webhook callbacks
export async function POST(
  request: Request,
  { params }: { params: { token: string } }
) {
  return await resumeWebhook(params.token, request);
}
```

## Common Use Cases

### Manual Approval Flow

```typescript theme={null}
// Workflow with hook
export async function approvalWorkflow(orderId: string) {
  'use workflow';
  
  const hook = createHook<{ approved: boolean }>({
    token: `approval-${orderId}`
  });
  
  const decision = await hook;
  
  if (decision.approved) {
    // Process order
  }
}

// API route to approve
import { resumeHook } from 'workflow/api';

export async function POST(request: Request) {
  const { orderId, approved } = await request.json();
  
  await resumeHook(`approval-${orderId}`, { approved });
  
  return Response.json({ success: true });
}
```

### Webhook Integration

```typescript theme={null}
// Workflow with webhook
export async function paymentWorkflow(checkoutId: string) {
  'use workflow';
  
  const webhook = createWebhook({
    token: `payment-${checkoutId}`
  });
  
  const paymentData = await webhook.then(async (req) => {
    const body = await req.json();
    await req.respondWith(new Response('OK', { status: 200 }));
    return body;
  });
  
  // Process payment confirmation
}

// API route to handle webhook
import { resumeWebhook } from 'workflow/api';

export async function POST(
  request: Request,
  { params }: { params: { checkoutId: string } }
) {
  return await resumeWebhook(`payment-${params.checkoutId}`, request);
}
```

## Related

* [createHook()](/api-reference/workflow/create-hook) - Create hooks in workflows
* [createWebhook()](/api-reference/workflow/create-webhook) - Create webhooks in workflows
* [defineHook()](/api-reference/workflow/define-hook) - Type-safe hook definitions
* [Hooks Guide](/concepts/hooks) - Understanding hooks and webhooks


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.