Skip to main content
Glama

update_document_fields

Update text fields in multiple SignNow documents to modify content, correct information, or prepare documents for signing.

Instructions

Update text fields in multiple documents (only individual documents, not document groups)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
update_requestsYesArray of document field update requests

Implementation Reference

  • Registration of the 'update_document_fields' tool using @mcp.tool decorator with name, description, and tags.
    @mcp.tool( name="update_document_fields", description="Update text fields in multiple documents (only individual documents, not document groups)", tags=["document", "fields", "update", "prefill"], )
  • The main handler function for the update_document_fields tool. It handles MCP context, authentication, client initialization, and delegates to the core _update_document_fields helper.
    def update_document_fields( ctx: Context, update_requests: Annotated[ list[UpdateDocumentFields], Field( description="Array of document field update requests", examples=[ [ { "document_id": "abc123", "fields": [ {"name": "FieldName1", "value": "New Value 1"}, {"name": "FieldName2", "value": "New Value 2"}, ], }, { "document_id": "def456", "fields": [{"name": "FieldName3", "value": "New Value 3"}], }, ], ], ), ], ) -> UpdateDocumentFieldsResponse: """Update text fields in multiple documents. This tool updates text fields in multiple documents using the SignNow API. Only text fields can be updated using the prefill_text_fields endpoint. IMPORTANT: This tool works only with individual documents, not document groups. To find out what fields are available in a document or document group, use the get_document tool first. Args: update_requests: Array of UpdateDocumentFields with document IDs and fields to update Returns: UpdateDocumentFieldsResponse with results for each document update """ headers = get_http_headers() token = token_provider.get_access_token(headers) if not token: raise ValueError("No access token available") # Initialize client and use the imported function from document module client = SignNowAPIClient(token_provider.signnow_config) return _update_document_fields(client, token, update_requests)
  • Core helper function that performs the actual API calls to prefill text fields in documents using SignNow client, handles multiple requests, and returns results with success/failure status.
    def _update_document_fields(client: SignNowAPIClient, token: str, update_requests: list[UpdateDocumentFields]) -> UpdateDocumentFieldsResponse: """ Update fields for multiple documents. This function updates text fields in multiple documents using the SignNow API. Only text fields can be updated using the prefill_text_fields endpoint. Args: client: SignNow API client instance token: Access token for authentication update_requests: List of UpdateDocumentFields with document IDs and fields to update Returns: UpdateDocumentFieldsResponse with results for each document update """ results = [] for update_request in update_requests: try: # Convert FieldToUpdate to PrefillTextField format prefill_fields = [] for field in update_request.fields: prefill_fields.append({"field_name": field.name, "prefilled_text": field.value}) # Create PrefillTextFieldsRequest from signnow_client.models.templates_and_documents import ( PrefillTextField, PrefillTextFieldsRequest, ) prefill_request = PrefillTextFieldsRequest(fields=[PrefillTextField(field_name=field.name, prefilled_text=field.value) for field in update_request.fields]) # Update fields using the client success = client.prefill_text_fields(token=token, document_id=update_request.document_id, request_data=prefill_request) results.append(UpdateDocumentFieldsResult(document_id=update_request.document_id, updated=success, reason=None)) # No reason needed for success except Exception as e: # Log error and mark as failed error_message = str(e) print(f"Failed to update fields for document {update_request.document_id}: {error_message}") results.append(UpdateDocumentFieldsResult(document_id=update_request.document_id, updated=False, reason=error_message)) return UpdateDocumentFieldsResponse(results=results)
  • Pydantic schema for UpdateDocumentFields input model defining document_id and list of fields to update.
    class UpdateDocumentFields(BaseModel): """Request model for updating document fields.""" document_id: str = Field(..., description="ID of the document to update") fields: list[FieldToUpdate] = Field(..., description="Array of fields to update with their new values")
  • Pydantic schema for UpdateDocumentFieldsResponse output model containing list of results for each update attempt.
    class UpdateDocumentFieldsResponse(BaseModel): """Response model for updating document fields.""" results: list[UpdateDocumentFieldsResult] = Field(..., description="Array of update results for each document")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mihasicehcek/sn-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server