Skip to content

Contract API Changes

New Status: signing

Added signing status to the contract lifecycle.

Status transitions

signature → signing → completed
  • signature: configuring signatures (can add/remove internal signers)
  • signing: signatures in progress (cannot add/remove internal signers)

step-engine updates

  • THIRD_PARTY_STATUSES: includes signing
  • STATUS_ORDER: [..., 'signature', 'signing', 'completed']
  • STATUS_TO_STEP: { signing: 'signature' }

New Endpoints

Download individual document file

GET /contracts/:id/documents/:docId/download
Response: blob (application/pdf)

Download all provider documents as ZIP

GET /contracts/:id/providers/:providerId/documents/download
Response: blob (application/zip)

History Action Mapping

The backend must record history entries automatically when the corresponding endpoint is called.

Entry format

json
{
  "id": "uuid",
  "entityType": "contract",
  "entityId": "contract-uuid",
  "action": "part_added",
  "data": "Added provider 'Company XYZ' as provider",
  "metadata": {
    "partName": "Company XYZ",
    "partRole": "provider"
  },
  "updatedBy": "user-uuid",
  "updatedByName": "User Name",
  "updatedAt": "2026-02-10T12:00:00Z"
}

Action → Endpoint mapping

ActionEndpointData to record
contract_createdPOST /contractsContract name, selected workflow
contract_updatedPUT /contracts/:idChanged fields (diff)
title_changedPUT /contracts/:id (when name changes)Previous name → new name
status_changedPATCH /contracts/:id/statusPrevious status → new status
part_addedPOST /contracts/:id/partsPart name, role (borrower/provider/etc)
part_removedDELETE /contracts/:id/parts/:partIdRemoved part name
template_selectedPUT /contracts/:id (when templateId changes)Selected template name
variable_assignedPUT /contracts/:id (when variableValues changes)Variable name, assigned value
document_addedPUT /contracts/:id (when documentRequirements grows)Added document name
document_removedPUT /contracts/:id (when documentRequirements shrinks)Removed document name
step_completedPATCH /contracts/:id/steps/:key/completeCompleted step name
sent_to_reviewPATCH /contracts/:id/status (→ in_review)Number of reviewers
review_comment_addedPOST /contracts/:id/review/:itemId/commentComment text, contract item
review_comment_editedPATCH /contracts/:id/review/:itemId/comments/:commentIdPrevious text → new text
review_item_approvedPATCH /contracts/:id/review/:itemId/approveItem name, who approved
review_item_rejectedPATCH /contracts/:id/review/:itemId/rejectItem name, rejection reason
reviewer_addedPOST /contracts/:id/review/reviewersReviewer name, email
reviewer_removedDELETE /contracts/:id/review/reviewers/:idRemoved reviewer name
reviewer_reminder_sentPOST /contracts/:id/review/reviewers/:id/reminderNotified reviewer name
file_uploadedPOST /contracts/:id/documents/:docId/filesFile name, document, provider
file_deletedDELETE /contracts/:id/documents/:docId/files/:fileIdRemoved file name
upload_approvedPATCH /contracts/:id/documents/:docId/review (approved)Document name, provider
upload_rejectedPATCH /contracts/:id/documents/:docId/review (rejected)Document name, reason
provider_reminder_sentPOST /contracts/:id/providers/:id/reminderNotified provider name
signature_config_savedPUT /contracts/:id/signaturesNumber of groups, number of signers
signature_startedPOST /contracts/:id/signatures/startNumber of notified signers
signer_signedPOST /contracts/:id/signatures/:signerId/signSigner name
signer_rejectedPOST /contracts/:id/signatures/:signerId/rejectName, rejection reason
signer_reminder_sentPOST /contracts/:id/signatures/:signerId/reminderNotified signer name
contract_archivedPATCH /contracts/:id/status (→ archived)Who archived
contract_cancelledPATCH /contracts/:id/status (→ cancelled)Who cancelled
contract_completedPATCH /contracts/:id/status (→ completed)Completion date
contract_deletedDELETE /contracts/:idWho deleted

Contract Validity (Vigência)

The contract toolbar includes a validity date range (start date / end date) that defines the contract's effective period.

Fields

  • startDate (ISO 8601 string, required): contract validity start date
  • endDate (ISO 8601 string, required): contract validity end date

Both fields are required when creating a contract, just like the contract name.

API

Validity dates are saved via PUT /contracts/:id with startDate and endDate fields. The frontend debounces changes (1 second) before sending.

UI Behavior

  • Date range picker in the toolbar between title/workflow and progress
  • Disabled when contract is in a terminal status (completed, cancelled, archived)
  • The date range is required and cannot be cleared

History action

ActionEndpointData to record
validity_changedPUT /contracts/:id (when startDate/endDate changes)Previous range → new range

HistoryEntry type updates

Added optional fields to src/domain/history/types.ts:

  • action?: string, action identifier from the table above
  • metadata?: Record<string, unknown>, structured data about the action
  • updatedByName?: string, display name of the user who performed the action