Use cases
- White-label template editing: Let users edit templates under your brand
- Multi-tenant applications: Secure per-user template access without exposing API keys
- Embedded workflows: Seamless template creation within your product
- Time-limited access: Tokens expire automatically for security
How it works
- Your server requests a JWT token from Firma’s API using your API key
- Firma returns a short-lived JWT token with the template ID
- Your frontend embeds the editor with the JWT token
- The token expires automatically (configurable expiration)
Rate limit: JWT endpoints support 120 requests per minute per API key for high-volume applications.
JWT Authentication
Generate JWT token
Generate a JWT token for a specific template using the/generate-template-token endpoint.
Endpoint: POST /generate-template-token
Request body:
Implementation guide
Backend: Generate JWT token
Call the Firma API from your backend to generate a JWT token. Your backend endpoint should accept a template ID and return the JWT to your frontend. Node.js example:Frontend implementation — HTML / Vanilla JavaScript
Frontend implementation — React
Configuration Options
Instance Methods
Use
triggerClose() when your host application needs to close the editor from its own UI — for example, a parent navigation event or a “back” button:
postMessage events (editor → host)
Firma’s editor will emit postMessage events for important lifecycle actions. Below is a recommended, minimal event schema you can implement for reacting to editor saves and publishes. If you have a canonical schema in your platform, replace these with your official event names. Event envelope (window.postMessage payload):Client listener example (plain JS)
Token lifecycle management
JWT tokens are generated with sufficient expiration time for typical editing sessions. The editor will automatically handle token expiration.Automatic expiration
JWT tokens expire automatically based on theexpires_at timestamp. After expiration:
- The embedded editor will reject the token
- Users must request a new token to continue
- No API call needed — tokens expire passively
Rate limiting
See the guide on Rate Limits.Security best practices
✅ Do’s
- ✅ Generate tokens from your backend server
- ✅ Monitor rate limits
- ✅ Use HTTPS for all API requests
❌ Don’ts
- ❌ Don’t expose API keys in frontend code
- ❌ Don’t reuse tokens across users
- ❌ Don’t log JWT tokens (security risk)
- ❌ Don’t share tokens between different templates
Troubleshooting
Token expired error
Symptom: Editor shows “Token expired” or authentication error Solution:- Implement token refresh before expiration
- Generate a new token and reload the iframe
- Check system clock synchronization
401 Unauthorized
Symptom: JWT generation fails with 401 Possible causes:- Invalid or missing API key
- API key doesn’t have required permissions
- API key is disabled
404 Not Found
Symptom: Template not found when generating JWT Possible causes:- Template ID doesn’t exist
- Template belongs to different workspace
- Template was deleted
Rate limit exceeded
Symptom: 429 Too Many Requests Solution:- Implement token caching
- Increase token expiration time
- Wait for rate limit reset (check
X-RateLimit-Resetheader) - Implement retry logic with backoff
Next steps
- Embed signing interface for white-label signing (100 req/min)
- Send signing requests with custom templates (100 req/min)
- Set up webhooks to track template events (60 req/min)