GitLaw How-To guides

GitLaw Public API Reference


Build custom integrations with the GitLaw Public API. Connect GitLaw to any system - your internal tools, Make, n8n, Pipedream, or anything else that can make HTTP requests.

Prefer no-code? Use our Zapier integration instead.

Overview

The GitLaw Public API lets external services trigger contract generation and document analysis. Send a request, and the API processes it and returns the result directly in the response.

What you can do:

  • Generate contracts and legal documents via AI
  • Analyze existing documents by referencing a file already in GitLaw
  • Upload new files for analysis by including base64-encoded content
  • Continue existing chat conversations or start new ones

Authentication

All API requests require an API key passed via the X-API-Key header:

X-API-Key: YOUR_API_KEY

Generate API keys in your GitLaw account settings. The full key is shown only once at creation - store it securely.

API Endpoint

POST /public-api/v1/chat/ask

Send a message to generate or analyze a contract.

Request Body

{  "message": "Create an NDA between Acme Corp and Beta Inc",  "fileId": "file-123",  "fileContent": "base64...",  "fileName": "doc.docx",  "chatId": "chat-456" }

Parameters

ParameterRequiredDescription
messageYesYour request or instruction for the AI
chatIdNoChat ID to continue an existing conversation. If omitted, a new chat is created
fileIdNoID of an existing file in GitLaw to use as context
fileContentNoBase64-encoded file content to upload as a new document
fileNameNoFilename for the uploaded file (required when using fileContent)

File Handling Rules

  • You can provide fileId, fileContent + fileName, or neither - but not both fileId and fileContent
  • If both fileId and fileContent are provided, the request is rejected with a 400 Bad Request error
  • If fileContent is provided, fileName must also be included (and vice versa)
  • Use fileId for files already in GitLaw
  • Use fileContent + fileName to upload a new file with your request

Response

The API processes the request and returns the result directly.

Success Response

{  "chatId": "chat_456",  "answer": "I've created an NDA between Acme Corp and Beta Inc...",  "fileId": "file_789",  "documentContent": "base64..." }

FieldDescription
chatIdThe chat where the conversation took place (existing or newly created)
answerThe AI's response text
fileIdID of the file used or created (if applicable)
documentContentBase64-encoded document content (if a document was generated)

Example: Create a Contract

Request

curl -X POST https://api.git.law/public-api/v1/chat/ask \  -H "X-API-Key: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "message": "Create an NDA between Acme Corp and Beta Inc"  }'

Response

{  "chatId": "chat_456",  "answer": "I've created an NDA between Acme Corp and Beta Inc...",  "fileId": "file_789",  "documentContent": "UEsDBBQAAAAI..." }

Example: Analyze an Existing Document

Request

curl -X POST https://api.git.law/public-api/v1/chat/ask \  -H "X-API-Key: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "message": "Review this contract and identify any problematic clauses",    "fileId": "file_existing_789"  }'

Response

{  "chatId": "chat_123",  "answer": "I've reviewed the contract. Here are the key issues I identified:\n\n1. The liability clause in Section 4.2 is unusually broad...",  "fileId": "file_existing_789" }

Example: Upload and Analyze a New File

Request

curl -X POST https://api.git.law/public-api/v1/chat/ask \  -H "X-API-Key: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "message": "Summarize this contract",    "fileContent": "UEsDBBQAAAAI...",    "fileName": "vendor-agreement.docx"  }'

Response

{  "chatId": "chat_789",  "answer": "Here is a summary of the vendor agreement...",  "fileId": "file_new_456",  "documentContent": "UEsDBBQAAAAI..." }

Example: Continue a Conversation

Request

curl -X POST https://api.git.law/public-api/v1/chat/ask \  -H "X-API-Key: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "chatId": "chat_456",    "message": "Now add a non-compete clause to the NDA"  }'

Response

{  "chatId": "chat_456",  "answer": "I've added a non-compete clause to the NDA...",  "fileId": "file_789",  "documentContent": "UEsDBBQAAAAI..." }

Error Handling

Common Errors

ErrorCauseSolution
400 - Missing messageRequired field not providedInclude a message in the request body
400 - Both fileId and fileContent providedThese fields are mutually exclusiveUse one or the other, not both
400 - fileContent without fileNamefileName is required when uploading a fileInclude fileName alongside fileContent
401 - UnauthorizedInvalid or expired API keyCheck your API key is correct and not expired
404 - Invalid fileIdFile doesn't exist or isn't accessibleVerify the file ID and your permissions
429 - Rate limitedToo many requestsWait before retrying

Best Practices

  1. Store your API key securely - It is shown only once at creation and cannot be recovered
  2. Use chatId to continue conversations - This preserves context from previous messages, producing better results
  3. Prefer fileId for existing files - Avoid re-uploading files that are already in GitLaw
  4. Handle errors gracefully - Check HTTP status codes and parse error responses
  5. Respect rate limits - Back off when you receive a 429 response

Questions?

If you encounter issues:

  1. Verify your API key is valid and not expired
  2. Ensure all required parameters are provided
  3. Check that fileId and fileContent are not used together
  4. Contact GitLaw support if problems persist

Sign up to source, customise, and store contracts for free

Sign Up