TorqueTorque

Search docs

Search Torque documentation pages & sections

Webhooks SDK

torque-webhooks helps merchants verify inbound Torque → merchant webhook signatures & push order status updates to Torque via POST /api/webhooks/order-update. Outbound payment webhooks from Torque to your server are not deployed on the hosted app yet.

Installation

yarn add torque-webhooks

Exports

ExportPurpose
verifyWebhookSignature()HMAC-SHA256 verify for inbound Torque → merchant webhooks
pushOrderUpdate()POST /api/webhooks/order-update with x-order-webhook-secret
createTorqueWebhooksFromEnv()Client from env vars
handleWebhook(): torque-webhooks/nextjsNext.js inbound webhook Route Handler

Push Order Status to Torque

After checkout, sync fulfillment status from your backend to Torque. Valid status values:

created | paid | shipped | delivered | cancelled | refunded

fulfillment.ts
import { createTorqueWebhooksFromEnv } from 'torque-webhooks'

await createTorqueWebhooksFromEnv().pushOrderUpdate({
  orderId: 'ord_123',
  status: 'shipped',
  customerData: { email: 'customer@example.com' },
  metadata: { carrier: 'ups', trackingId: '1Z…' },
})

Authenticates with x-order-webhook-secret & your business API credentials from env.

Verify Inbound Webhooks (When Outbound Ships)

When Torque sends outbound events to your server, verify the x-torque-signature header with HMAC-SHA256. The handler is ready in the SDK; the hosted sender is not live yet.

app/api/webhooks/torque/route.ts
import { handleWebhook } from 'torque-webhooks/nextjs'

export const POST = handleWebhook({
  secret: process.env.TORQUE_WEBHOOK_SECRET!,
  onEvent: async (event) => {
    switch (event.type) {
      case 'order.completed':
        await fulfillOrder(event.orderId)
        break
      // …
    }
  },
})

Integrator platform webhooks

Business API integrators can receive outbound events configured in Business Settings → API Integration. Verify X-Torque-Signature (HMAC-SHA256 of the raw body) with verifyWebhookSignature / parseIntegratorWebhookEvent from torque-webhooks.

EventWhen
end_user.deposit.detectedDeposit observed for a provisioned partner end-user wallet
desk.angle.publishedNew desk trade angle published (item is IntelligenceItemV1)

Discover configuration (without secrets) via GET /api/v1/accounts/business webhooks.*.

Questions or corrections? hello@torque.fi