@saleslane/sdk
v1.0.0
Published
JavaScript SDK for the Saleslane API (RS256 signed requests)
Downloads
106
Maintainers
Readme
@saleslane/sdk
JavaScript SDK for the Saleslane API. Handles RS256 JWT signing automatically.
Installation
npm install @saleslane/sdkUsage
const { SaleslaneClient } = require('@saleslane/sdk');
const client = new SaleslaneClient({
baseUrl: 'https://your-instance.saleslane.nl',
apiRecordId: process.env.SALESLANE_API_RECORD_ID,
privateKey: process.env.SALESLANE_PRIVATE_KEY,
});
const me = await client.getMe();
console.log(me.data);Authentication
Every request is signed with an RS256 JWT:
- GET requests: params are signed and sent as
?signed=<jwt> - POST/PUT/PATCH/DELETE: the body is signed and sent as the JWT string
You need an API record ID and the matching RSA private key. Register the public key on the API record in Saleslane.
Methods
| Method | Description |
|--------|-------------|
| getMe() | Get the authenticated API record |
| revokeMe() | Deactivate the API record (irreversible) |
| getContactByPhone({ phoneNumber }) | Look up contacts by E.164 phone number |
| addTransactionTag({ referenceId, tag, ... }) | Add a tag to a subtransaction |
| listUsers() | List all users |
| listTeams() | List all teams |
Low-level Exports
const { signPayload, createSignedHooks } = require('@saleslane/sdk');
const token = signPayload(payload, privateKey, apiRecordId);
const hooks = createSignedHooks(privateKey, apiRecordId);License
ISC
