Skip to content

webteacup/litify-demo

Repository files navigation

Litify Demo — Tristar Integration

Next.js demo app for Salesforce/Litify integration: authentication, Litify data (Matters, Contacts), and Docrio org info from the connected environment.

Features

  • Salesforce OAuth 2.0 (client_credentials grant) — connect with Connected App client id/secret
  • Litify via Salesforce REST API — query Matters (litify_pm__Matter__c), Contacts, and arbitrary SOQL
  • Docrio Setup API — fetch your org’s dedicated Docrio API URL and document bucket (see Docrio Setup API); the Docrio base URL comes from the environment you connect to

Setup

  1. Copy env and set Salesforce credentials:

    cp .env.local.example .env.local

    Edit .env.local:

    • SALESFORCE_CLIENT_ID — Consumer Key from your Salesforce Connected App
    • SALESFORCE_CLIENT_SECRET — Consumer Secret
    • SALESFORCE_INSTANCE_URL — set if the token response has no instance_url
    • Optional: DOCRIO_SETUP_API_URL — override Docrio Setup API base (default below)
    • Optional: DOCRIO_API_KEY — required for Docrio files API (GET /api/litify/docrio/files?ids=...)
  2. Install and run:

    npm install
    npm run dev
  3. Open the app (e.g. http://127.0.0.1:8080), click Connect to Salesforce on the Dashboard, then use the sidebar to open the five endpoint pages: Matters (/matters), Contacts (/contacts), SObjects (/sobjects), Query (/query), or Docrio (/docrio).

API routes

Route Description
POST /api/auth/salesforce Get Salesforce access token (server uses .env credentials)
GET /api/litify/sobjects List Salesforce/Litify sobjects (schema discovery)
GET /api/litify/query?q=SOQL Run a SOQL query against the connected org
GET /api/litify/matters?limit=50 Litify Matters (litify_pm__Matter__c)
GET /api/litify/contacts?limit=50 Contacts
GET /api/litify/docrio/orginfo Docrio org info (Setup API with Salesforce Bearer token)
GET /api/litify/docrio/files?ids=id1,id2 Docrio files (uses AwsApiPrefix from orginfo + X-API-KEY)
  • SObjects: use /api/litify/sobjects to list all sobjects (standard and custom, including Litify objects).
  • Query: use /api/litify/query?q=<encoded SOQL> to run arbitrary SOQL (e.g. SELECT Id, Name FROM Account LIMIT 10).

All Litify/Docrio routes use server-side Salesforce auth (no token in the browser).

Docrio

Litify provides access via the Salesforce REST API and the Litify Docrio API (Litify API Integration Agreement).

1) Org info (Setup API)

Call the Setup API with your Salesforce access token (Bearer) to get org-specific endpoints and buckets:

curl -X GET 'https://2xm5rfl2q0.execute-api.us-east-2.amazonaws.com/v1/orginfo' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer <SALESFORCE_ACCESS_TOKEN>'

The response includes AwsApiPrefix, AwsId, BucketName, PdfBucketName, Licenses, Status, DocrioLicense, WopiUrl, etc. Use AwsApiPrefix as the base for Docrio API calls (e.g. files).

  • Setup API base: https://2xm5rfl2q0.execute-api.us-east-2.amazonaws.com/v1
  • Override with DOCRIO_SETUP_API_URL in .env.local if needed.

2) Files API

After org info, call the Docrio API for files using Salesforce access token (Bearer) and Docrio API key (X-API-KEY):

curl -i -X GET 'https://api.<AwsId>.genesisapi.com/v1/files?Ids=a1E1U000001juz6UAA' \
  -H 'Authorization: Bearer <SALESFORCE_ACCESS_TOKEN>' \
  -H 'X-API-KEY: <DOCRIO_API_KEY>'

In this app, GET /api/litify/docrio/files?ids=id1,id2 does the same: it fetches org info to get AwsApiPrefix, then calls GET {AwsApiPrefix}/files?Ids=... with the token and DOCRIO_API_KEY from .env.local.

Token endpoint

This app uses a fixed token URL:
https://jnylaw--august2025.sandbox.my.salesforce.com/services/oauth2/token

Authentication: client_credentials grant only (grant_type, client_id, client_secret).

References

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors