1. Default module
Calven Developer Docs
beta
  • latest
  • beta
  • Default module
    • Access Control
    • Overview
    • SDKs
    • HMAC Authentication
    • Basic Authentication
    • Calven Data Models
    • Changelog
    • Authentication
      • Generate a token with an API key and HMAC
      • Generate a token with an API key and client secret
    • Presence
      • Presence Overview
      • Submit presence events
      • Submit presence events (Basic auth)
    • Occupancy
      • Occupancy Overview
      • Submit occupancy events
    • Time Off
      • Submit time off updates
    • Access Credentials
      • Submit access credentials
    • Warehouse - Basic Auth
      • Warehouse API (Basic Auth)
      • Users (Basic auth)
      • Groups (Basic auth)
      • Locations (Basic auth)
      • Desks (Basic auth)
      • Bookings & Attendance (Basic auth)
      • Presence (Basic auth)
      • User Actions Log (Basic auth)
      • Events (Basic auth)
    • Warehouse - HMAC Auth
      • Warehouse API (HMAC Auth)
      • Users
      • Groups
      • Locations
      • Desks
      • Bookings & Attendance
      • Presence
      • User Actions Log
      • Events
    • Hierarchy Information
      • Org Hierarchy Information Overview
      • Submit group hierarchy relationships
      • Submit group hierarchy relationships (Basic auth)
    • User Attributes
      • User Attributes Overview
      • Write directory user attributes
      • Write directory user attributes (Basic auth)
    • Visitor Management
      • Submit visitor arrival events
      • Submit visitor arrival events (Basic auth)
    • Parking
      • Retrieve parking bookings
      • Retrieve parking bookings (Basic auth)
    • Service Requests
      • Service Offerings
      • Service Offering
      • Submit a service request
      • Service Request
      • Update a service request
    • Schemas
      • Schemas
      • PresenceEventDto
      • CreatePresenceEventDto
      • SourceEventResultCode
      • SourceEventResultDto
      • CreatePresenceEventResponseDto
      • ApiServiceException
      • VisitorArrivalEventDto
      • CreateVisitorArrivalEventDto
      • CreateVisitorArrivalEventResponseDto
      • OccupancyEventDto
      • CreateOccupancyEventDto
      • CreateOccupancyEventResponseDto
      • AuthRequestDto
      • AuthResponseDto
      • OAuthRequestDto
      • OAuthResponseDto
      • AccessCredentialUpdateResultCodes
      • AccessCredentialUpdateResult
      • AccessCredentialUpdateResponse
      • AccessCredential
      • AccessCredentialUpdate
      • AccessCredentialUpdateRequest
      • DWChangeLogPreferenceAllocationDto
      • DWChangeLogAutoBookingReasonDto
      • DWChangeLogUserResponseDto
      • DWUserBookingAttendanceResponseDto
      • DWPresenceResponseDto
      • DWEventsResponseDto
      • DWUsersResponseDto
      • DWGroupsResponseDto
      • DWLocationsResponseDto
      • DWDesksResponseDto
      • TimeOffRequestBodyDto
      • TimeOffResponseDto
      • DMGroupRelationshipDto
      • PutDMGroupHierarchyRelationshipBodyDto
      • DMPostUserAttributesRecordDto
      • DMPostUserAttributesBodyDto
      • ResultCodes
      • DMPostUserAttributesRecordResponseDto
      • DMPostUserAttributesResponseDto
      • ParkingBookingReportPrincipalDto
      • ParkingBookingReportSpotDto
      • ParkingBookingReportZoneDto
      • ParkingBookingReportAreaDto
      • GetParkingBookingReportResponseDto
      • ServiceOfferingPageDto
  1. Default module

SDKs

Node.js SDK

A Calven API SDK is available for node.js via NPM - https://www.npmjs.com/package/@calven-code/calvenapi

Installation

npm install @calven-code/calvenapi

Usage

The library provides clients for the following Calven API services:

  • Occupancy events
  • Presence events
  • Timeoff notification events

The library exposes the CalvenAPI class, which provides static factory methods for creating clients for the above services.

Each method accepts an API Key and an API key secret. You can optionally provide the base URL for the Calven API. If you do not provide a base URL, the client will use the default Calven API URL.

Occupancy client

import { randomUUID as uuid } from 'node:crypto'
import { CalvenAPI, CalvenOccupancyEvent, CalvenLocationType } from '@calven-code/calvenapi'

const occupancyClient = CalvenAPI.occupancyClient(apiKey,apiSecret)

const occupancyEvent: CalvenOccupancyEvent = {
  eventId: uuidv4(),
  timestamp: new Date(),
  locationId: 'DF253A05-573C-4A9F-BFF8-64795029572D',
  locationType: CalvenLocationType.LOCATION,
  occupied: true,
  occupancy: 5,
}

const occupancyResult = await occupancyClient.sendOccupancy('my-source-id',[occupancyEvent])

Presence client

import { randomUUID as uuid } from 'node:crypto'
import { CalvenClient, CalvenPresenceEvent, CalvenLocationType } from '@calven-code/client'

const presenceClient = CalvenClient.presenceClient(apiKey,apiSecret)

const presenceEvent: CalvenPresenceEvent = {
  eventId: uuidv4(),
  timestamp: new Date(),
  sourceUserId:'1234',
  userEmail:'Mary.Jones@example.com',
  locationId: 'DF253A05-573C-4A9F-BFF8-64795029572D',
  locationType: CalvenLocationType.LOCATION
}

const presenceResult = await presenceClient.sendPresence('my-source-id',[presenceEvent])

Timeoff client

import { randomUUID as uuid } from 'node:crypto'
import { CalvenClient, CalvenTimeOffEvent, CalvenTimeOffEventType } from '@calven-code/client'

const timeoffClient = CalvenClient.timeoffClient(apiKey,apiSecret)

const timeOffEvent: CalvenTimeOffEvent = {
  eventId:uuidv4(),
  startDate: new Date('02-26-2023'),
  endDate: new Date('02-27-2023'),
  email:'Mary.Jones@example.com',
  eventType: CalvenTimeOffEventType.SCHEDULED,
  timeOffType: CalvenTimeOffType.LEAVE
}

const timeOffResult = await timeoffClient.sendTimeoff([timeOffEvent])

Endpoint and region selection

The Calven API is available in multiple regions. You can specify the region to use by passing an optional CalvenClientConfig when creating a client. If you do not specify a region, the client will use the default region, which is the US.

For example, to select the Australian region:

import { CalvenAPIRegion, CalvenClient, CalvenLocationType, CalvenPresenceEvent, } from '@calven-code/client'

const presenceClient = CalvenClient.presenceClient(apiKey,apiSecret, { 
    region: CalvenAPIRegion.AU
})

You can also pass a baseUrl in the CalvenClientConfig to specify a custom Calven API URL. The default value is the production Calven endpoint.

Modified at 2026-11-19 01:51:20
Previous
Overview
Next
HMAC Authentication
Built with