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
| Parameter | Required | Description |
|---|---|---|
message | Yes | Your request or instruction for the AI |
chatId | No | Chat ID to continue an existing conversation. If omitted, a new chat is created |
fileId | No | ID of an existing file in GitLaw to use as context |
fileContent | No | Base64-encoded file content to upload as a new document |
fileName | No | Filename for the uploaded file (required when using fileContent) |
File Handling Rules
- You can provide
fileId,fileContent+fileName, or neither - but not bothfileIdandfileContent - If both
fileIdandfileContentare provided, the request is rejected with a400 Bad Requesterror - If
fileContentis provided,fileNamemust also be included (and vice versa) - Use
fileIdfor files already in GitLaw - Use
fileContent+fileNameto 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..." }
| Field | Description |
|---|---|
chatId | The chat where the conversation took place (existing or newly created) |
answer | The AI's response text |
fileId | ID of the file used or created (if applicable) |
documentContent | Base64-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
| Error | Cause | Solution |
|---|---|---|
400 - Missing message | Required field not provided | Include a message in the request body |
400 - Both fileId and fileContent provided | These fields are mutually exclusive | Use one or the other, not both |
400 - fileContent without fileName | fileName is required when uploading a file | Include fileName alongside fileContent |
401 - Unauthorized | Invalid or expired API key | Check your API key is correct and not expired |
404 - Invalid fileId | File doesn't exist or isn't accessible | Verify the file ID and your permissions |
429 - Rate limited | Too many requests | Wait before retrying |
Best Practices
- Store your API key securely - It is shown only once at creation and cannot be recovered
- Use
chatIdto continue conversations - This preserves context from previous messages, producing better results - Prefer
fileIdfor existing files - Avoid re-uploading files that are already in GitLaw - Handle errors gracefully - Check HTTP status codes and parse error responses
- Respect rate limits - Back off when you receive a
429response
Questions?
If you encounter issues:
- Verify your API key is valid and not expired
- Ensure all required parameters are provided
- Check that
fileIdandfileContentare not used together - Contact GitLaw support if problems persist