nortra-crm-sdk
v1.2.0
Published
Isomorphic JavaScript SDK for Nortra CRM
Downloads
423
Readme
Nortra CRM SDK
Isomorphic JavaScript SDK for Nortra CRM. Works seamlessly in the browser, Node.js, and edge runtimes.
Overview
A comprehensive SDK to integrate CRM functionalities effortlessly into your JavaScript or TypeScript applications.
Key Features
- Isomorphic Support: Run anywhere - browsers, Node.js, and edge environments.
- TypeScript Native: First-class TypeScript support with exported types.
- Promise-based API: Modern
async/awaitsupport out of the box.
Installation
Install using npm:
npm install nortra-crm-sdkOr using yarn:
yarn add nortra-crm-sdkQuick Start
Initialize the SDK and submit a lead:
import { NortraCRM } from 'nortra-crm-sdk';
// Initialize with both Workspace ID and API Key
NortraCRM.init({
workspaceId: 'your-workspace-id',
apiKey: 'your-api-key', // Required
});
// Submit a new lead
const result = await NortraCRM.submitLead({
email: '[email protected]',
fullName: 'Jane Doe',
phone: '+1 555 000 0000',
property: 'Contact Page',
notes: 'Interested in the Pro plan',
});
if (result.success) {
console.log('Lead submitted successfully!');
} else {
console.error('Failed to submit lead:', result.error);
}Configuration Reference
NortraCRM.init(config)
Must be called once prior to using any SDK methods (e.g., during application boot).
| Parameter | Type | Required | Description |
| ------------- | -------- | -------- | ------------------------------------------------ |
| workspaceId | string | Yes | Your unique Nortra workspace identifier. |
| apiKey | string | Yes | API key for authenticated requests. |
API Reference
NortraCRM.submitLead(leadData)
Submits lead information to your CRM. Returns a Promise<LeadResponse>.
Note: If the SDK was not initialized with both workspaceId and apiKey, this method will return a failed LeadResponse indicating the initialization error without making a network request.
| Parameter | Type | Required | Description |
| ---------------- | -------- | -------- | ------------------------------------------------ |
| email | string | Yes | Lead's email address. |
| fullName | string | No | Lead's full name. |
| phone | string | No | Lead's phone number. |
| property | string | No | Source property (default: "Website Form"). |
| notes | string | No | Free-text notes or additional details. |
| externalLeadId | string | No | Your own ID to correlate leads across systems. |
LeadResponse
The structure of the response returned by submitLead:
{
success: boolean;
error?: string; // Present if the request fails
status?: number; // HTTP status code if the request fails
}Environment Examples
React Integration
import { NortraCRM } from 'nortra-crm-sdk';
// Initialize once at the root of your application
NortraCRM.init({
workspaceId: import.meta.env.VITE_WORKSPACE_ID,
apiKey: import.meta.env.VITE_API_KEY
});
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
const form = new FormData(e.currentTarget);
const result = await NortraCRM.submitLead({
email: form.get('email') as string,
fullName: form.get('name') as string,
});
if (!result.success) {
alert(`Error: ${result.error}`);
}
}Node.js / Server-side
import { NortraCRM } from 'nortra-crm-sdk';
NortraCRM.init({
workspaceId: process.env.NORTRA_WORKSPACE_ID,
apiKey: process.env.NORTRA_API_KEY
});
const result = await NortraCRM.submitLead({
email: '[email protected]'
});HTML + CDN (No Bundler)
<script src="https://unpkg.com/nortra-crm-sdk"></script>
<script>
NortraCRM.NortraCRM.init({
workspaceId: 'your-workspace-id',
apiKey: 'your-api-key'
});
</script>TypeScript
Full TypeScript support is built-in. No external @types package is necessary.
import { NortraCRM, LeadData, LeadResponse } from 'nortra-crm-sdk';License
MIT
