Welcome to your organization's API

The aim of this documentation is to familiarize you with your integration API, and provide the necessary documentation to get you developing quickly. All Lexamica integration APIs use the RPC protocol which you can learn more about here and/or read about REST vs RPC. You may find that many RPC APIs use either the JSON-RPC Protocol or the XL-RPC Protocol. While both of these protocols have merits, Lexamica integration APIs use a modified protocol that is more JSON-friendly to aid integrating developers while they get their integrations up and running.
An important concept to consider as you interact with this integration API is that Lexamica integration APIs are meant to be action-oriented in their approach to requests and responses. This means that the URLs you will call should tell you what kind of action you're requesting from the API. It may help you to think of the URL as the function call, and the request body as the function parameters. In this approach, Lexamica integration APIs are similar to Slack's RPC API.
Hopefully this information and context was helpful. If you have more questions, definitely reach out to your Lexamica technical contact, but for now, let's jump into the technical info.



API Security Scheme

Lexamica integration APIs require Bearer Tokens to make requests on behalf of user's in a Lexamica Law Firm. The only exception is the /integration/connect route which only uses auth credentials generated by Lexamica.

Bearer Token Security:

Bearer tokens should be included in the Authorization request header in the following format: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6Ikp...

Bearer tokens are generated on a user-by-user basis. When a user is added using the /integration/user.add route and activated using the /integration/user.enable route, they are eligible to have a token generated for them. See the section on User Management for a more in-depth look into how user token management works.

There are two ways to obtain a bearer token to use when making requests:

Credential Security:

Credentials should be included in the Authorization request header in the following format: Credentials key**secret. Make sure to include the ** delimiter between the key and secret. See the section on Establishing an integration connection for details on how to obtain credentials and how to use them.

Request Headers Expected

This section explains the minimal request headers expected and required by this integration API

Headers:

Response Headers Expected

This section details the response headers your platform can expect to receive from requests to this integration API

Headers:

Request Body Requirements

Here are some good rules of thumb for your request body

Setting up an integration connection flow

This flow will walk you through initializing a integration connection and generating credentials on Lexamica, and then finishing the connection from your integrating platform. In this example we will be connecting a Litify Integration, however the basic flow applies to all integrations.

  1. Go to the Integrations Page in Lexamica located in the Firm Management section of the Navigation Bar.

    Lexamica Integrations Page
  2. Click Connect on the applicable integration and wait for credentials to be generated

    Generate Integration Credentials
  3. Download the credentials generated (recommended) or simply copy and paste them somewhere. These credentials are not viewable once you exit the generation page.

    Save or Download Integration Credentials
  4. Finish the integration connection inside your integrating platform by sending a request to the /integration/connect route following the route documentation. Make sure to include your credentials as your authorization. See the Security Scheme section for instructions and formatting.

    Send the connection request to the integration API
  5. Capture the Bearer Token returned in the response. Congratulations, the organization's integration has been connected! Now proceed to the User Management section to add and activate all organization users.

    Save the returned bearer token to be used in user setup

Generating a JWT

JWTs are generated on a user-by-user basis. However, you can also only generate a global token for your default user connection. For more info on this, see the guide on User Management.

To generate a JWT, make a request following the documentation given for the /authentication/generate.token endpoint. Your Authorization header should contain the Lexamica Organization Credentials. If you don't know what those are or how to use them, see the Credentials portion of the Security Section. The user_id prop is the unique ID for an existing, active user connection.

A successful token generation request will return the access token for the specified user. One of the props returned will also be a expires_in prop that should be used to manage your tokens so that you don't generate a new token until the old one has almost expired.

Lexamica reserves the right to throttle your integration's use of the /authentication/generate.token endpoint if we determine that token expiration is not being respected. An example would be requesting a new token before every subsequent request without any regard for previous token lifespan.

User Management

This flow will walk you through adding and activating users to an existing organization integration connection. This flow assumes you have successfully established a organization integration connection. If you haven't, go to the Establishing an integration connection section and complete that first, then come back here.

What are integration users/connections?

Integration Users/Connections are representations of individual users who might all be using the organization's integration simultaneously. Each Bearer Token is encoded to a unique user_id within the organization. This allows auditing for which users perform various actions resulting in integration actions in Lexamica. This granularity also enables activating and deactivating of users individually. Thus, you could deactivate a certain user_id and keep all others active. This would cause that user to be unable to perform integration actions via the API, but would allow all other users to continue uninterupted. However, we also understand that your system may not care to distinguish between which users are performing integration actions. In that case, read on to our next question...

What if I don't want to add individual users?

Adding and managing individual user actions has a lot of benefits mentioned above. However, for a variety of reasons, you may just want to use a global connection for your platform. Fortunately, every time you connect an organization through the /integration/connect endpoint, a default connection is created with a random, unique user_id. This default connection ID will be listed in the users prop returned when an integration is first connected using the /integration/connect endpoint. This allows you to get a JWT encoded to the default connection using the /authentication/generate.token and use it globally in your platform for a particular organization. However, note that by doing this, you will not be able to get audits on which users perform actions as all actions will show as performed by the default user. You will also only be able to activate/deactivate your integration globally since there will no user granularity. This user connection scheme is most suited to platforms with rigorous internal user auditing and RBAC.

What are the endpoints to manage users?

/integration/user.add allows you to add one or more connections in a batch format. Each user connection requires a few data props:

/integration/user.remove allows you to remove any existing user connections in a batch format using their ID.

/integration/user.enable allows you to batch activate any existing user connections that are currently inactive.

/integration/user.disable allows you to batch deactivate (block) any existing user connections that are currently active.