Skip to main content الرئيسية المنشئون jeremylongshore tons-of-skills-marketplace navan-multi-env-setup
navan-multi-env-setup Set up dev/staging/prod environment separation for Navan integrations without a sandbox API.
Use when configuring multiple environments, building CI test pipelines, or setting up local development.
Trigger with "navan environments", "navan multi env", "navan dev setup", "navan mock server".
الانتقال إلى التثبيت سوق المهارات اكتشف واستكشف مهارات الذكاء الاصطناعي التي بناها المجتمع.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
نسخ Promptعرض تفاصيل Prompt يتجاوز الأمر المباشر Prompt المخصّص للمراجعة. افحص المصدر قبل تشغيله.
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace --skill navan-multi-env-setupيبقى الأمر في سطر واحد. مرّر أفقيًا لمراجعته كاملًا قبل النسخ.
تفضّل نسخة محلية؟ نزّل الملفات المتاحة حاليًا لدى SkillsMP.
تحميل Zip جاري التحميل... المزيد من هذا المستودع langchain-deploy-integration Deploy a LangChain 1.0 / LangGraph 1.0 app to Cloud Run, Vercel, or LangServe correctly — with timeouts sized for chain length, cold-start mitigation, SSE anti-buffering headers, and Secret Manager over .env. Use when prepping a first production deploy, debugging a stream that hangs behind a proxy, or diagnosing p99 latency spikes. Trigger with "langchain deploy", "langchain cloud run", "langchain vercel python", "langchain langserve", or "langchain docker".
langchain-langgraph-agents Build a correct LangGraph 1.0 ReAct agent with create_react_agent — typed tools, error propagation, recursion caps, and stop conditions that actually stop. Use when writing a first tool-calling agent, migrating from AgentExecutor or initialize_agent, or diagnosing an agent that loops on vague prompts. Trigger with "langgraph agent", "create_react_agent", "langgraph tool calling", "AgentExecutor migration", or "agent loop cost".
langchain-langgraph-human-in-loop Build LangGraph 1.0 human-in-the-loop approval flows with interrupt_before /
interrupt_after and Command(resume=...) — JSON-serializable state, clean
resume semantics, and UI wiring for approval decisions. Use when adding an
approval gate before an expensive tool call, wiring a Slack/web UI for agent
approvals, or debugging a graph that crashes on interrupt.
Trigger with "langgraph human in loop", "langgraph interrupt_before",
"langgraph approval flow", "Command resume", "langgraph HITL".
name navan-multi-env-setup description Set up dev/staging/prod environment separation for Navan integrations without a sandbox API.
Use when configuring multiple environments, building CI test pipelines, or setting up local development.
Trigger with "navan environments", "navan multi env", "navan dev setup", "navan mock server".
allowed-tools Read, Write, Edit, Bash(npm:*), Grep version 1.7.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","navan","travel"] compatibility Designed for Claude Code
Navan Multi-Environment Setup
Overview
Navan does not offer a sandbox or staging API — every call hits production data with real corporate bookings and expense records. This creates risk for development and testing: a bug in a sync script could modify live itineraries, and CI pipelines cannot safely run integration tests. This skill implements environment isolation using separate OAuth apps, environment variable validation, a local development proxy, and a CI mock server.
Prerequisites
Navan admin access to create multiple OAuth apps (Admin > Travel admin > Settings > Integrations)
Node.js 18+ for proxy and mock server
Understanding of OAuth 2.0 client credentials flow (see navan-install-auth)
.env management tooling (dotenv, direnv, or cloud secret manager)
Instructions
Step 1: Create Per-Environment OAuth Apps
Create separate API credentials in the Navan admin dashboard for each environment. This provides natural isolation — the dev app can have read-only scopes while production gets full access.
NAVAN_ENV=development
NAVAN_CLIENT_ID=dev-client-id-xxxxx
NAVAN_CLIENT_SECRET=dev-client-secret-xxxxx
NAVAN_API_BASE=https://api.navan.com/v1
NAVAN_READ_ONLY=true
NAVAN_ENV=staging
NAVAN_CLIENT_ID=stg-client-id-xxxxx
NAVAN_CLIENT_SECRET=stg-client-secret-xxxxx
NAVAN_API_BASE=https://api.navan.com/v1
NAVAN_READ_ONLY=false
NAVAN_ENV=production
NAVAN_CLIENT_ID=prod-client-id-xxxxx
NAVAN_CLIENT_SECRET=prod-client-secret-xxxxx
NAVAN_API_BASE=https://api.navan.com/v1
NAVAN_READ_ONLY=false
Step 2: Build an Environment-Aware Client
import { config } from 'dotenv' ;
interface NavanConfig {
env : string ;
clientId : string ;
clientSecret : string ;
apiBase : string ;
: ;
}
( ): {
envFile = ;
({ : envFile });
required = [ , , ];
( key required) {
(!process. [key]) {
( );
}
}
{
: process. . || ,
: process. . !,
: process. . !,
: process. . !,
: process. . ===
};
}
{
: ;
: | = ;
( ) {
. = ();
. ( );
}
( : , : , ?: ): < > {
( . . && method !== ) {
( );
}
(! . ) {
. = . ();
}
response = ( , {
method,
: {
: ,
:
},
: body ? . (body) :
});
(!response. ) {
( );
}
response. ();
}
(): < > {
res = ( , {
: ,
: { : },
: ({
: ,
: . . ,
: . .
})
});
{ access_token } = res. ();
access_token;
}
}
readOnly
boolean
function
loadConfig
NavanConfig
const
`.env.${process.env.NODE_ENV || 'development' } `
config
path
const
'NAVAN_CLIENT_ID'
'NAVAN_CLIENT_SECRET'
'NAVAN_API_BASE'
for
const
of
if
env
throw
new
Error
`Missing ${key} in ${envFile} `
return
env
env
NAVAN_ENV
'development'
clientId
env
NAVAN_CLIENT_ID
clientSecret
env
NAVAN_CLIENT_SECRET
apiBase
env
NAVAN_API_BASE
readOnly
env
NAVAN_READ_ONLY
'true'
class
NavanClient
private
config
NavanConfig
private
accessToken
string
null
null
constructor
this
config
loadConfig
console
log
`Navan client initialized [${this .config.env} ] readOnly=${this .config.readOnly} `
async
request
method
string
path
string
body
object
Promise
any
if
this
config
readOnly
'GET'
throw
new
Error
`Write operations blocked in ${this .config.env} (read-only mode)`
if
this
accessToken
this
accessToken
await
this
authenticate
const
await
fetch
`${this .config.apiBase} ${path} `
headers
'Authorization'
`Bearer ${this .accessToken} `
'Content-Type'
'application/json'
body
JSON
stringify
undefined
if
ok
throw
new
Error
`Navan API error: HTTP ${response.status} on ${method} ${path} `
return
json
private
async
authenticate
Promise
string
const
await
fetch
'https://api.navan.com/ta-auth/oauth/token'
method
'POST'
headers
'Content-Type'
'application/x-www-form-urlencoded'
body
new
URLSearchParams
grant_type
'client_credentials'
client_id
this
config
clientId
client_secret
this
config
clientSecret
const
await
json
return
Step 3: Create a Local Development Proxy import express from 'express' ;
const proxy = express ();
proxy.use (express.json ());
proxy.all ('/navan/*' , async (req, res) => {
const navanPath = req.path .replace ('/navan' , '' );
const method = req.method ;
console .log (`[PROXY] ${method} ${navanPath} ` );
if (req.body && Object .keys (req.body ).length > 0 ) {
console .log (`[PROXY] Body:` , JSON .stringify (req.body , null , 2 ));
}
if (process.env .NAVAN_READ_ONLY === 'true' && method !== 'GET' ) {
console .log (`[PROXY] BLOCKED: ${method} ${navanPath} (read-only mode)` );
return res.status (403 ).json ({
error : 'Write operation blocked in development mode' ,
method, path : navanPath
});
}
try {
const response = await fetch (`https://api.navan.com/v1${navanPath} ` , {
method,
headers : {
'Authorization' : req.headers .authorization as string ,
'Content-Type' : 'application/json'
},
body : ['POST' , 'PUT' , 'PATCH' ].includes (method)
? JSON .stringify (req.body ) : undefined
});
const data = await response.json ();
console .log (`[PROXY] Response: ${response.status} ` );
res.status (response.status ).json (data);
} catch (err : any ) {
console .error (`[PROXY] Error:` , err.message );
res.status (502 ).json ({ error : 'Proxy error' , message : err.message });
}
});
proxy.listen (4000 , () => console .log ('Navan dev proxy on http://localhost:4000' ));
Step 4: Build a CI Mock Server import express from 'express' ;
const mock = express ();
mock.use (express.json ());
const mockData = {
users : [
{ id : 'user-001' , email : 'traveler@company.com' , role : 'traveler' , department : 'engineering' }
],
trips : [
{ id : 'trip-001' , traveler_id : 'user-001' , status : 'confirmed' , total : 450.00 }
],
expenses : [
{ id : 'exp-001' , submitter_id : 'user-001' , amount : 125.50 , status : 'submitted' }
]
};
mock.post ('/ta-auth/oauth/token' , (req, res ) => {
res.json ({ access_token : 'mock-token-ci' , expires_in : 3600 , token_type : 'Bearer' });
});
mock.get ('/v1/users' , (req, res ) => {
res.json ({ data : mockData.users , total : mockData.users .length , has_more : false });
});
mock.get ('/v1/trips' , (req, res ) => {
res.json ({ data : mockData.trips , total : mockData.trips .length , has_more : false });
});
mock.get ('/v1/expenses' , (req, res ) => {
res.json ({ data : mockData.expenses , total : mockData.expenses .length , has_more : false });
});
mock.all ('*' , (req, res ) => {
console .log (`[MOCK] Unhandled: ${req.method} ${req.path} ` );
res.status (501 ).json ({ error : 'Not implemented in mock' , path : req.path });
});
const port = process.env .MOCK_PORT || 4001 ;
mock.listen (port, () => console .log (`Navan mock server on http://localhost:${port} ` ));
Step 5: Wire Mock Server into CI
- name: Start Navan mock server
run: |
node navan-mock-server.js &
sleep 2
env:
MOCK_PORT: 4001
- name: Run integration tests
run: npm test
env:
NAVAN_API_BASE: http://localhost:4001/v1
NAVAN_CLIENT_ID: ci-test-client
NAVAN_CLIENT_SECRET: ci-test-secret
NODE_ENV: test
Output A complete environment isolation strategy for Navan integrations: separate OAuth apps per environment with scoped permissions, an environment-aware client with write protection, a local dev proxy for request logging and mutation blocking, and a CI-ready mock server that eliminates production API dependencies from automated tests.
Error Handling Error Code Solution Missing env vars N/A Config loader throws on startup; check the correct .env.<environment> file exists Write blocked in read-only 403 Expected in dev mode; switch to staging/prod for write operations Mock endpoint not found 501 Add the endpoint to mock server; check test expectations match mock data Proxy connection refused 502 Ensure the proxy server is running; check port availability Wrong environment loaded N/A Verify NODE_ENV matches the intended .env.<environment> file
Examples Validate environment configuration:
NODE_ENV=staging node -e "
require('dotenv').config({ path: '.env.staging' });
console.log('ENV:', process.env.NAVAN_ENV);
console.log('READ_ONLY:', process.env.NAVAN_READ_ONLY);
console.log('CLIENT_ID:', process.env.NAVAN_CLIENT_ID?.slice(0, 8) + '...');
"
Run tests against mock server locally:
MOCK_PORT=4001 node navan-mock-server.js
NAVAN_API_BASE=http://localhost:4001/v1 npm test
Resources
Next Steps After setting up environments, see navan-security-basics for credential rotation across all environments, or navan-ci-integration for building the full CI/CD pipeline with Navan API tests.