Configure the TypeScript client
Configure shared or isolated Business API clients with server-side credentials.
Configure a shared client
Set credentials and base URL
Configure one shared client during application startup:
import { orvelt } from '@orvelt/business';
export const businessClient = orvelt({
apiKey: process.env.ORVELT_BUSINESS_API_KEY!,
});The production base URL is https://api.orvelt.com/v1. Pass baseUrl when your service uses a staging environment or local proxy:
import { orvelt } from '@orvelt/business';
orvelt({
apiKey: process.env.ORVELT_BUSINESS_API_KEY!,
baseUrl: process.env.ORVELT_API_BASE_URL,
});Keep configuration server-side
orvelt trims the key and base URL and rejects an empty value. Keep both values in server environment variables.
Use separate clients
Isolate environments or organizations
Use createBusinessClient when one process talks to more than one environment or organization. Pass the returned client to an individual operation:
Use an isolated client for a project request.
import { createBusinessClient, goals } from '@orvelt/business';
const client = createBusinessClient({
apiKey: process.env.ORVELT_BUSINESS_API_KEY!,
baseUrl: process.env.ORVELT_API_BASE_URL,
});
const result = await goals.list(
{ projectId: 'PROJECT_ID' },
{ client },
);curl --request GET \\
--url "$ORVELT_API_BASE_URL/project/PROJECT_ID/goals" \\
--header "x-api-key: $ORVELT_BUSINESS_API_KEY"Bind a project ID
When several requests target the same project, use useProject to bind the project ID once. It is a plain factory and does not require React:
import { useProject } from '@orvelt/business';
const project = useProject('PROJECT_ID');
const result = await project.opinions.respond({
id: 'OPINION_ID',
content: 'Thanks for sharing your feedback.',
});Per-request options, including a custom client, remain the second argument to each operation.
The isolated client does not replace the package-level client. This makes it safe to keep credentials for separate tenants in separate request paths.
Configure Fetch behavior
Set headers, Fetch, or thrown errors
The client accepts the generated Fetch configuration options, including fetch, headers, and throwOnError:
import { orvelt } from '@orvelt/business';
orvelt({
apiKey: process.env.ORVELT_BUSINESS_API_KEY!,
headers: { 'x-request-id': 'REQUEST_ID' },
throwOnError: true,
});Use throwOnError only when your application has a consistent exception boundary. The default result form is easier to inspect at each call site.