Firma lets you add legally binding e-signatures to anything built on Gemini. Use the Gemini API’s function calling to let your AI agents send signing requests on demand, connect Firma’s MCP servers to the Gemini CLI so the AI generates accurate integration code, or wire up webhooks to track completions. This guide covers all three.Documentation Index
Fetch the complete documentation index at: https://docs.firma.dev/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Firma account with an API key
- A Google AI Studio account with a Gemini API key, or Gemini Code Assist installed in your IDE
- At least one Firma template with signing fields configured
Firma uses the raw API key as the
Authorization header value - do not prefix it with Bearer. This differs from the Gemini API itself, which uses x-goog-api-key.Getting started
- Function calling
- Gemini CLI via MCP
Function calling lets a Gemini model decide when to call your code. You declare a function the model can call, and when the user asks it to send a contract, Gemini returns a structured tool call that your app executes against the Firma API.This path is the right fit for AI agents, chatbots, and any app where a natural-language user request should turn into a signing request.A user message like “Send the consulting agreement to alice@acme.com” will trigger the function call. The model returns the structured
Step 1: Store your API keys
Keep both your Gemini API key and your Firma API key in environment variables. Never put them in frontend code.Step 2: Declare a function and handle tool calls
Declare the function in the shape Gemini expects, then run a chat loop that handles the tool call by hitting Firma’screate-and-send endpoint.The
create-and-send endpoint creates the signing request and sends it to recipients in a single API call. If you need the model to draft a request for review before sending, use POST /signing-requests to create a draft, then POST /signing-requests/{id}/send once approved.Step 3: Wire it into your app
CallhandleUserMessage from your backend whenever the user sends a chat message. Gemini decides on its own when the request warrants a signing flow:functionCall, your code executes it against Firma, and the follow-up turn lets Gemini summarize the result back to the user.Python alternative
The same flow with the Python SDK:Webhook integration
To track signing events in real time, register a Firma webhook pointing at an endpoint in your app. Here is a minimal handler forsigning_request.completed:
Embedded signing
For apps where signers complete documents inside your UI instead of opening a Firma-hosted page, thecreate-and-send response includes first_signer.id (the signing_request_user_id) and a ready-made first_signer.signing_link. Load the signer URL in an iframe:
Tips
- Use function calling for runtime agents, MCP for build time. Function calling is what your deployed app uses to actually send documents. The MCP servers are what you and the Gemini CLI use to build that integration.
- Pass
template_idas a tool arg, not a free-form string. Templates are the safest way to constrain what the model can send. Let the model pick a template ID from a short, named list you control. - Validate before sending. For higher-stakes documents, branch on a confirmation step. Use
POST /signing-requeststo create a draft, surface it to the user, then callPOST /signing-requests/{id}/sendonly after they confirm. - Workspaces for multi-tenant apps. If you are building a SaaS product on top of Gemini, give each end customer their own Firma workspace so templates and usage stay isolated.
Next steps
- API authentication - API keys and workspace scoping
- Webhooks guide - Event types, payloads, and signature verification
- Embedded signing - In-app signing experience
- Creating workspaces - Multi-tenant setups for SaaS apps
- MCP integration - Full MCP server reference with all 84 tools
- Complete setup guide - End-to-end Firma integration walkthrough
- API reference - Full endpoint documentation