Contracts

Set a document's contract terms

Changed on

Creates the document's contract terms, or changes only the attributes sent (see the request body for what null does). external_references, when sent, replaces the whole list. Records a document_contract_updated event when the terms change; a retry that changes nothing records none. The body must be a JSON object with at least one attribute. With parent_document_id, the document is instead linked as an amendment, renewal or termination of that contract (or of any document in its family, resolved to the root) and the other attributes are the terms it changes; a later PUT on a pending amendment merges into that delta (a null drops a key) and parent_document_id: null unlinks it; every change to the link records document_contract_amendment_updated on this document. The delta applies to the parent once the document is certificated (at once, if it already is), in signing order (the order the documents' certifications were recorded in, fixed for each once it is; a certificated document with none recorded waits, and is placed by its certification time an hour on): instruments signed earlier apply first, one that cannot holds the later ones back, and an instrument signed before one already applied is blocked instead of applied over it. Applying records document_contract_amended; an applied amendment is read-only. A cancelled, declined or expired document takes no new terms and no new link; terms or a link already on one stay and can still change. Send the updated_at you read with the write to have it refused (409) if the contract or link changed meanwhile. Needs a plan with contract tracking (403 otherwise).

Copy as Markdown Open in ChatGPT Open in Claude

put/v1/accounts/{accountId}/documents/{documentId}/contract

Request

  • Base URL
    https://api.assinafy.com.br
  • URL
    https://api.assinafy.com.br/v1/accounts/{accountId}/documents/{documentId}/contract
  • Auth
    • HTTP bearer
    • or API key in header X-Api-Key

Path parameters

accountIdstring required

Workspace account ID.

documentIdstring required

Document ID.

Request body

status'draft' | 'active' | 'expired' | 'terminated'

On creation any status, so a contract that ended before it was tracked is registered as it ended: expired needs an end_date in the past, terminated its end_date; neither is walked by the lifecycle. Afterwards only draft or active (a contract in force never goes back to draft): expired and terminated are set by the lifecycle and the terminate endpoint; a closed contract is reopened by renewing it.

counterparty_namestring nullable

Emoji are kept; other characters outside the 3-byte range are dropped.

counterparty_taxpayer_idstring nullable

A valid CPF or CNPJ, formatted or not.

valuenumber nullable

Two decimal places at most.

currencystring nullable

Three letters, such as BRL or USD, stored in capitals; BRL when a value is set without one.

start_datestring date nullable

YYYY-MM-DD, from the year 1000.

end_datestring date nullable

YYYY-MM-DD, on or after start_date.

auto_renewboolean

Whether the hourly run starts the next term the day after end_date, by renewal_term_months, instead of expiring the contract.

renewal_term_monthsinteger nullable

How far a renewal by the term moves end_date; 12 when unset.

notice_period_daysinteger nullable

Days before end_date the notice period starts (document_contract_renewal_notice); none when unset.

owner_idstring nullable

An active member of this workspace.

metadataobject nullable

Your own fields: up to 50 keys of 1 to 40 letters, digits, _, - or ., each holding plain text of at most 500 characters; no number under a key ending in _at, or stuck_since.

parent_document_idstring nullable

Links the document as an amendment of this contract document, or of any document in its family (resolved to the root); null unlinks a pending amendment. With it, the other attributes are the terms the instrument changes, not terms of its own; on a pending amendment a null value drops that term from the delta rather than clearing it on the parent.

relation_type'amendment' | 'renewal' | 'termination'

Required on the first link. amendment may change value, currency, start_date (effective from, display only), end_date, auto_renew, renewal_term_months, notice_period_days, counterparty_name, counterparty_taxpayer_id and metadata; renewal only end_date and value; termination only end_date (the effective date).

updated_atstring date-time

Optional precondition: the updated_at the client read the contract (or this document's amendment link) with, as the API returned it. If the contract or link changed since, nothing is written and the answer is 409 with code: ContractChanged. Not sent, or null: the write applies whatever changed meanwhile (last write wins). Compared to the second; a fraction of a second, as a JavaScript date prints it, is read and ignored. New terms and a first link have nothing to have read, so sending one answers 409; on a pending amendment, send the link's own updated_at (the GET on that document).

Example request

{
  "currency": "BRL",
  "external_references": [
    {
      "system": "hubspot",
      "id": "98765"
    }
  ],
  "updated_at": "2026-10-23T12:00:00Z"
}

Response

The contract terms as saved, or the amendment as linked

statusinteger

HTTP status code, mirrored in the body.

messagestring

Human-readable message; empty on success.

Example response

{
  "status": 200,
  "data": {
    "resource": "document_contract",
    "document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
    "status": "active",
    "counterparty_name": "Acme Ltda",
    "counterparty_taxpayer_id": "11222333000181",
    "value": 120000.5,
    "currency": "BRL",
    "start_date": "2026-11-01",
    "end_date": "2027-10-31",
    "auto_renew": true,
    "renewal_term_months": 12,
    "notice_period_days": 30,
    "term": 1,
    "owner_id": "d6zqpbyog2v3xvxerwn8la94",
    "metadata": {
      "crm_stage": "won"
    },
    "external_references": [
      {
        "system": "hubspot",
        "id": "98765"
      }
    ],
    "document": {
      "resource": "document",
      "id": "615601fab04c0a3147bb1246",
      "account_id": "d199996981dbd199996981db",
      "name": "document.pdf",
      "status": "metadata_ready",
      "artifacts": {
        "original": "https://api.assinafy.com.br/v1/documents/doc1/download/original"
      },
      "signing_url": "https://api.assinafy.com.br/v1/sign/doc1",
      "verification_code": "a3f1c9e07b2d4e8f9a6c5b1d0e7f3a2c9b8d4e6f",
      "verification_url": "https://www.assinafy.com.br/verificador/a3f1c9e07b2d4e8f9a6c5b1d0e7f3a2c9b8d4e6f",
      "declined_by": {
        "resource": "signer",
        "id": "62d6ee35c7741ca4006b9e11",
        "full_name": "John Signer",
        "email": "john@email.com",
        "whatsapp_phone_number": "+5548999990000",
        "government_id": "39053344705"
      },
      "assignment": {
        "resource": "assignment",
        "id": "615606ef81d199996981dbce",
        "document_id": "615601fab04c0a3147bb1246",
        "created_at": "2026-06-03T03:54:16Z",
        "sender_email": "sender@example.com",
        "method": "virtual",
        "signers": [
          {
            "resource": "signer",
            "id": "62d6ee35c7741ca4006b9e11",
            "full_name": "John Signer",
            "email": "john@email.com",
            "whatsapp_phone_number": "+5548999990000",
            "government_id": "39053344705",
            "verification_method": "Email",
            "notification_methods": [
              "Email"
            ],
            "step": 1,
            "identity_verification_status": "InReview",
            "notification_history": [
              {
                "event": "signature_request",
                "status": "sent",
                "sent_at": "2026-07-07T12:00:00Z"
              }
            ]
          }
        ],
        "items": [
          {
            "page": {
              "id": "615601faf166d6d1d8e7dc30",
              "number": 1,
              "height": 2100,
              "width": 1275,
              "download_url": "https://api.assinafy.com.br/v1/documents/doc1/pages/1a/download"
            }
          }
        ],
        "signing_urls": [
          {
            "url": "https://api.assinafy.com.br/v1/sign/doc1?email=joe@example.com"
          }
        ]
      },
      "pages": [
        {
          "id": "615601faf166d6d1d8e7dc30",
          "number": 1,
          "height": 2100,
          "width": 1275,
          "download_url": "https://api.assinafy.com.br/v1/documents/doc1/pages/1a/download"
        }
      ],
      "has_contract": true,
      "created_at": "2026-06-03T03:54:16Z",
      "updated_at": "2026-06-03T03:54:16Z"
    },
    "amendments": [
      {
        "resource": "document_contract_amendment",
        "document_id": "7c3d1e2f4a5b6c7d8e9f0a1b",
        "document_name": "Aditivo 1 - Contrato de prestação de serviços.pdf",
        "parent_document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
        "relation_type": "amendment",
        "number": 1,
        "status": "pending",
        "document_status": "pending_signature",
        "currency": "BRL",
        "terms": {
          "value": 130000,
          "end_date": "2028-06-30"
        },
        "changes": {
          "value": {
            "from": 120000.5,
            "to": 130000
          },
          "end_date": {
            "from": "2027-10-31",
            "to": "2028-06-30"
          },
          "term": {
            "from": 1,
            "to": 2
          }
        },
        "created_at": "2026-10-23T12:00:00Z",
        "updated_at": "2026-10-23T12:00:00Z"
      }
    ],
    "created_at": "2026-10-23T12:00:00Z",
    "updated_at": "2026-10-23T12:00:00Z"
  }
}

Changes