Firma lets you add legally binding e-signatures to any Mocha application. Store your Firma API key as a secret, ask Mocha’s AI to call the API from your backend, and your users can send signing requests directly from your app. This guide covers how to integrate Firma using Mocha’s built-in backend functions and secrets manager. Since Mocha is AI-driven, most of the integration can be done by prompting the AI with the right instructions.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 Mocha account (the free plan includes 1 published app; paid plans add more published apps and custom domains)
- 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 many other APIs.Step 1: Store your Firma API key as a secret
- Open your project in Mocha
- Go to Settings → Secrets
- Add a new secret with the name
FIRMA_API_KEYand paste your Firma API key as the value
Step 2: Ask Mocha to build the signing request feature
Mocha generates backend code from natural language prompts. You don’t need to write code yourself. Instead, paste the following prompt into the Mocha chat:YOUR_TEMPLATE_ID with the ID of a template from your Firma dashboard. You can find it under Templates by clicking on a template and copying the ID from the URL.
Mocha’s AI will generate the backend function, create the frontend form, and wire them together. Test it in the preview before publishing.
The
create-and-send endpoint creates the signing request and sends it to recipients in one call. If you need to review or modify the request before sending, ask Mocha to use POST /signing-requests to create a draft first, then POST /signing-requests/{id}/send separately.Step 3: Track signing status with webhooks
Firma can notify your app when a document is signed, declined, or expires. To set this up:- Ask Mocha to create an API endpoint in your app that accepts POST requests. Use a prompt like:
- After publishing your app, copy the webhook URL:
https://your-app.mocha.app/api/webhook/firma - In the Firma dashboard, go to Settings → Webhooks and register this URL
Embedded signing
For apps where signers complete documents directly in your UI instead of via email, Firma provides an embeddable signing experience. Thecreate-and-send response includes a first_signer.id (the signing_request_user_id) and a ready-made first_signer.signing_link. Ask Mocha to add an iframe that loads the signing URL:
Bonus: Use Custom Knowledge for better AI results
Mocha’s Custom Knowledge feature lets you give the AI persistent context about your project. Adding Firma API details here helps Mocha generate more accurate code when you ask it to build signing features.- Open your project and go to the Custom Knowledge tab
- Add the following:
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
- Complete setup guide — end-to-end Firma integration walkthrough
- API reference — full endpoint documentation