Skip to main content

CRM Field Integration

Learn how to integrate sajn document fields with your CRM system, enabling you to create documents with editable fields, store field references, and update content directly from your CRM.

Overview

This guide covers a common integration pattern where you:
  1. Create a document with fields - Add TEXT or FORM fields to a document
  2. Store field references in your CRM - Save field IDs or keys for later access
  3. Update fields from your CRM - Sync changes back to sajn when CRM data changes
This pattern is useful for:
  • Contracts that pull customer data from your CRM
  • Proposals with pricing that updates based on CRM deals
  • Agreements with terms that vary per customer record

Understanding Field Identifiers

sajn provides two ways to reference fields when updating:

Field ID

A unique identifier returned when creating a field. Use this when you need to reference specific field instances.

Field Key

A custom identifier you assign when creating a field. Use this for a more readable, semantic approach.
Field keys must match the pattern ^[a-z0-9_-]*$ (lowercase letters, numbers, underscores, and hyphens only).

Step 1: Create Document with Fields

Create the Document

First, create a document that will contain your fields:
Response:
Use externalId to store your CRM record ID. This makes it easy to find the sajn document from your CRM later.

Add TEXT Fields

TEXT fields contain rich text content that you can update programmatically:
Response:

Add FORM Fields

FORM fields contain input elements that signers can fill out, or that you can pre-fill:

Step 2: Store Field References in Your CRM

After creating fields, store the references in your CRM so you can update them later.

Why Use Keys Instead of IDs?

Using field keys (like customer-name) instead of field IDs (like field_abc123) offers advantages:
We recommend using field keys for most integrations. They’re more maintainable and you don’t need to store additional IDs in your CRM.

Step 3: Update Fields from Your CRM

When data changes in your CRM, update the corresponding sajn fields.
Fields can only be updated when the document status is DRAFT. Once a document is sent for signing, fields cannot be modified.

Update TEXT Fields

Update text content using the field key:

Update FORM Fields

Update form input values using the subfield key:

Batch Update Multiple FORM Fields

To update several FORM subfields at once, use the batch endpoint PATCH /documents/{documentId}/fields with an updates array. This is the recommended way to sync multiple CRM values in one go.
Do not fire multiple single-key PATCH .../fields/key:<key> requests in parallel (e.g. with Promise.all). All FORM subfields are stored inside one underlying field, so concurrent single-key requests read-modify-write the same record and overwrite each other — only the last write survives. The batch endpoint applies every change against a single read, so nothing is lost.
The batch endpoint updates FORM subfield values by key. To update a TEXT field’s rich-text content, use the single-key PATCH .../fields/key:<key> endpoint shown above.

Complete Integration Example

Here’s a complete example of a CRM integration service:

Best Practices

Fields can only be updated when the document is in DRAFT status. Check the status before attempting updates to provide better error messages to your users.
Set up webhooks to receive notifications when documents are signed or updated. This enables you to update your CRM when document status changes.
See the Webhooks Guide for setup instructions.
Individual field updates may fail while others succeed. Handle errors per-field rather than failing the entire sync.
Choose descriptive field keys that match your CRM field names. This makes debugging and maintenance easier.

Troubleshooting

Field Not Found Error

Solution: Verify the field key exists. Retrieve the document to see available fields:

Cannot Update Field - Document Not in Draft

Solution: Once a document is sent for signing, fields cannot be modified. You would need to cancel the document, make changes, and resend.

Invalid Field Value

Solution: Ensure the value format matches the field type. Dates should be YYYY-MM-DD, numbers should be strings.

Next Steps

Create Documents

Learn more about document creation options

Templates and Forms

Use templates for consistent document structure

Webhooks

Set up webhooks for two-way CRM sync

Document Fields API

Full API reference for field operations