/navan-pack:navan-webhooks-eventsfrom navan-pack
Sets up webhook listeners for real-time Navan event notifications including booking lifecycle, expense workflow, and travel disruptions. Covers endpoint registration, payload signature verification, event routing, and idempotent processing.
Ships in navan-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Navan supports asynchronous event delivery via callback URLs registered through the REST API. Since there is no public SDK, webhook handlers receive raw HTTP POST requests with JSON payloads. This skill covers endpoint setup, payload verification, event routing, and idempotent processing for the key event types: booking lifecycle, expense workflow, and travel disruptions.
navan-install-auth)const response = await fetch('https://api.navan.com/v1/webhooks', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://your-domain.com/webhooks/navan',
events: [
'booking.created',
'booking.updated',
'booking.cancelled',
'expense.submitted',
'expense.approved',
'expense.rejected',
'trip.disrupted'
],
secret: process.env.NAVAN_WEBHOOK_SECRET
})
});
const webhook = await response.json();
console.log('Webhook registered:', webhook.id);
import crypto from 'node:crypto';
function verifySignature(payload: string, signature: string, secret: string): boolean {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
import express from 'express';
const app = express();
// Track processed events for idempotency
const processedEvents = new Set<string>();
app.post('/webhooks/navan', express.raw({ type: 'application/json' }), async (req, res) => {
const signature = req.headers['x-navan-signature'] as string;
const rawBody = req.body.toString();
// Verify authenticity
if (!verifySignature(rawBody, signature, process.env.NAVAN_WEBHOOK_SECRET!)) {
return res.status(401).json({ error: 'Invalid signature' });
}
// Acknowledge immediately — process async
res.status(200).json({ received: true });
const event = JSON.parse(rawBody);
// Idempotency check — Navan may retry on timeout
if (processedEvents.has(event.id)) return;
processedEvents.add(event.id);
// Route by event type
switch (event.type) {
case 'booking.created':
await handleNewBooking(event.data);
break;
case 'expense.submitted':
await handleExpenseSubmission(event.data);
break;
case 'trip.disrupted':
await handleDisruption(event.data);
break;
default:
console.log('Unhandled event type:', event.type);
}
});
async function handleNewBooking(data: {
booking_id: string;
traveler_email: string;
trip_type: 'flight' | 'hotel' | 'car';
total_cost: number;
currency: string;
}) {
// Notify travel manager, update internal systems
console.log(`New ${data.trip_type} booking: ${data.booking_id} — $${data.total_cost}`);
}
async function handleExpenseSubmission(data: {
expense_id: string;
submitter_email: string;
amount: number;
category: string;
}) {
// Route to approval workflow
console.log(`Expense submitted: ${data.expense_id} — $${data.amount} (${data.category})`);
}
async function handleDisruption(data: {
trip_id: string;
disruption_type: 'cancellation' | 'delay' | 'gate_change';
severity: 'low' | 'medium' | 'high';
affected_travelers: string[];
}) {
// Trigger alerts for high-severity disruptions
if (data.severity === 'high') {
console.log(`ALERT: ${data.disruption_type} affecting ${data.affected_travelers.length} travelers`);
}
}
A running webhook endpoint that receives real-time Navan events, verifies payload authenticity, deduplicates retries, and routes events to typed handler functions. The handler acknowledges receipt immediately (HTTP 200) and processes events asynchronously to avoid timeout-triggered retries.
| Error | Code | Solution |
|---|---|---|
| Invalid signature | 401 | Verify NAVAN_WEBHOOK_SECRET matches the secret used during registration |
| Endpoint unreachable | N/A | Ensure HTTPS is valid and publicly accessible; check firewall rules |
| Duplicate events | N/A | Implement idempotency using event ID tracking (Set, Redis, or database) |
| Payload timeout | 408 | Respond with 200 before processing; handle work asynchronously |
| Webhook disabled | 410 | Re-register the callback URL; Navan disables after repeated failures |
List registered webhooks:
curl -s -H "Authorization: Bearer $NAVAN_ACCESS_TOKEN" \
https://api.navan.com/v1/webhooks | python3 -m json.tool
Delete a webhook:
curl -s -X DELETE \
-H "Authorization: Bearer $NAVAN_ACCESS_TOKEN" \
https://api.navan.com/v1/webhooks/WEBHOOK_ID
Test with ngrok for local development:
ngrok http 3000
# Use the HTTPS URL as your callback URL when registering
After setting up webhooks, see navan-rate-limits to add throttling to your event processing pipeline, or navan-security-basics for credential rotation and SSO hardening.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
26 skills in this plugin
/navan-ci-integrationUse when setting up CI/CD pipelines that validate Navan API integrations, run booking data health checks, or generate automated compliance reports.
Trigger with "navan ci integration" or "navan pipeline" or "navan github actions".
/navan-common-errorsDiagnose and fix common Navan API errors with targeted fix procedures.
Use when an API call returns an unexpected HTTP error or when debugging production failures.
Trigger with "navan error", "fix navan", "debug navan", "navan 401", "navan 403", "navan 429".
/navan-core-workflow-aManage the complete Navan travel booking lifecycle via REST API.
Use when building travel dashboards, automating trip reporting, or syncing booking data to internal systems.
Trigger with "navan travel workflow", "navan booking management", "navan trip retrieval".
/navan-core-workflow-bManage Navan expense reporting, transaction data, and ERP synchronization.
Use when building expense pipelines, automating approval workflows, or syncing transactions to accounting systems.
Trigger with "navan expense management", "navan expense workflow", "navan transaction sync".
/navan-cost-tuningUse when optimizing travel spend with Navan's policy engine, analyzing booking patterns for savings, and configuring the Navan Rewards program.
Trigger with "navan cost tuning" or "navan travel savings" or "navan spend optimization".
/navan-data-handlingExtract and transform Navan booking and transaction data using pagination, filtering, and data pipeline connectors.
Use when building data warehouses, analytics dashboards, or debugging data quality issues with Navan data.
Trigger with "navan data handling", "navan data extraction", "navan pagination".
npx claudepluginhub flight505/skill-forge --plugin navan-packOther plugins' skills for the same job