Contract Metadata Extraction: Extract Parties, Dates, and Renewal Terms With Python
Extract parties, dates, renewal terms, and contract value from four different contracts with one Unsiloed schema, then use Python to build a contract register and compute each notice deadline. Every field keeps the page and passage it came from.


Contract metadata such as end dates, renewal terms, and notice periods is split across summary tables, numbered clauses, and footer paragraphs, and the layout can differ in every agreement.
In this guide, we use one Unsiloed extraction schema to collect the same facts from every contract, including their source pages and passages. Then we use Python to build a table for those facts and compute the last day to give notice before a renewal.

What Is Contract Metadata
In contract management, metadata means the structured data recorded about a contract: the type of agreement, the parties, key dates, renewal and termination terms, value, and governing law. Little of it lives in the file itself. A PDF's own properties hold a title and a creation date, so the facts stay in the clauses until someone reads them and records each one as a field.
Storing those fields apart from the document lets a team search, sort, and get alerted on contracts without opening each one. Ongoing duties, such as delivery or reporting requirements, are usually tracked separately as obligations.
Common Contract Metadata Fields With Examples
The same fields let us compare different kinds of contracts. For this example, we look at four Alder Quay Manufacturing LLC contracts, each with a different business case.
| Contract | Other Party | Where the Facts Appear |
|---|---|---|
| Software subscription | Larchlight Software LLC | Summary table, followed by renewal clauses |
| Mutual non-disclosure agreement (NDA) | Cairnwick Design LLC | Numbered clauses covering shared confidential information |
| Equipment lease | Fennbar Equipment LLC | Separate clauses for delivery, duration, and rent |
| Supplier agreement | Vesperkiln Components LLC | Separate clauses for dates, orders, and renewal |
The next table lists the fields a contract register usually tracks. Each row explains what the field means and gives an example value from one of the four contracts.
| Field | Plain Meaning | Example |
|---|---|---|
| Contract type | The kind of agreement | Software subscription |
| Parties | The people or companies entering the agreement | Alder Quay Manufacturing LLC and Larchlight Software LLC |
| Effective date | When the agreement starts to apply | January 15, 2026, for the subscription |
| Term | The period the agreement runs | 36 months from delivery for the lease |
| Expiration date | The scheduled end of the term | February 28, 2027, for the NDA |
| Automatic renewal (evergreen) | Extension into another term unless someone takes the required action to stop it | Successive 12-month terms for the subscription |
| Non-renewal notice period | How far ahead someone must notify the other party to prevent the next term | Notice received at least 60 calendar days before the subscription term ends |
| Termination for convenience | A right to end the agreement without having to show the other party did something wrong | The NDA allows it with 30 days of written notice |
| Governing law | The jurisdiction's laws chosen to govern the agreement | New York for the subscription |
| Contract value | The monetary amount stated for the agreement or a defined period | USD 24,000 for the subscription's initial term |
Stopping a renewal and ending a contract early are different actions. The NDA's 30-day early-ending rule belongs in the termination field, not the renewal notice field. Its contract value is unstated, so that field should be null, meaning no value was supplied.
The subscription specifies a receipt deadline in Section 3.
Either party may prevent renewal by written notice received at least 60 calendar days before the end of the then-current term.
A date can also depend on an event. Section 3 of the lease starts this way.
The term begins on the date the equipment is delivered.
That clause continues with a 36-month duration that ends on the day before the 36-month anniversary of delivery. The delivery date belongs in a separate acceptance certificate. Keeping the clause text alongside a date that can be null preserves the rule without substituting the signing or effective date.
Extract the Same Fields From Every Contract
The schema assigns a data type to each field. Names tie a row to an agreement, and timing fields support deadline calculations. Value and governing-law fields make the register useful for finance and legal review.
Keep the original wording for duration, renewal, early termination, and value. A number alone would lose conditions such as "received," "calendar days," or "for the initial term." Dates use ISO format (YYYY-MM-DD), durations use whole months or days, and automatic renewal uses true or false. An unstated renewal rule stays null, which is different from an explicit false.
Download the subscription, NDA, lease, and supplier agreement into one folder. The snippets need Python with requests installed and an Unsiloed API key in the UNSILOED_API_KEY environment variable.
To work from saved results, download subscription.json, nda.json, lease.json, and supply.json into that folder and skip to the register section.
Create schema.py in the folder.
def field(kind, description):
return {"type": [kind, "null"], "description": description + " Null if unstated."}
properties = {
"parties": field("string", "Full legal names of both contracting parties, separated by ' / ', customer or buyer first"),
"effective_date": field("string", "Date the agreement takes effect, YYYY-MM-DD"),
"term_text": field("string", "Verbatim passage defining the initial term start and end"),
"term_start": field("string", "Initial term start as YYYY-MM-DD. Null if dependent on an event with no stated date"),
"initial_end": field("string", "Explicit initial expiration date as YYYY-MM-DD. Do not calculate a date"),
"term_months": field("integer", "Explicit initial duration in months. Do not calculate from dates"),
"renewal_text": field("string", "Verbatim renewal and non-renewal notice wording"),
"auto_renew": field("boolean", "True for automatic renewal, false for explicit no renewal"),
"renewal_months": field("integer", "Months in each automatic renewal term"),
"notice_days": field("integer", "Calendar days of notice to prevent renewal. Exclude early termination notice"),
"convenience_text": field("string", "Verbatim permission or prohibition of termination for convenience"),
"value_text": field("string", "Verbatim contract value wording, including currency and period"),
"governing_law": field("string", "Named jurisdiction whose laws govern the agreement"),
}
schema = {"type": "object", "properties": properties,
"required": list(properties), "additionalProperties": False}
Every key is required in the response, but each value can be null. The schema asks for an explicit initial end date rather than a calculated one. We use Python for date arithmetic after extraction.
Send the PDFs and Keep Their Citations
Create extract.py beside schema.py. The extraction endpoint accepts a PDF and the schema, then returns a job ID, an identifier used to check progress. We check that job every three seconds until it finishes. We select the gamma model and set enable_citations to request page locations. Keep the uploaded filename's .pdf extension.
import json, os, time
from pathlib import Path
import requests
from schema import schema
BASE = "https://prod.visionapi.unsiloed.ai"
headers = {"api-key": os.environ["UNSILOED_API_KEY"]}
def extract(name):
with open(f"{name}.pdf", "rb") as f:
response = requests.post(f"{BASE}/v2/extract", headers=headers,
files={"pdf_file": (f"{name}.pdf", f, "application/pdf")},
data={"schema_data": json.dumps(schema), "model": "gamma",
"enable_citations": "true"})
response.raise_for_status()
job_id = response.json()["job_id"]
while True:
response = requests.get(f"{BASE}/extract/{job_id}", headers=headers)
response.raise_for_status()
job = response.json()
if job["status"] in ("failed", "review"):
raise SystemExit(f"Check extraction job: {job['status']}")
if job["status"] == "completed":
return job["result"]
time.sleep(3)
for name in ("subscription", "nda", "lease", "supply"):
Path(f"{name}.json").write_text(json.dumps(extract(name), indent=2))
Run the extraction from the folder containing the PDFs.
python3 extract.py
The four saved JSON files contain the same fields. Each file is that contract's metadata record, kept apart from the PDF, with every value pointing back to the passage it came from. Each field wraps its value with a score and a citation. A citation can be null, including for absent values. The grounding_score expresses confidence in locating the value in the document. The extraction_score expresses confidence in the extracted value. Both use a zero-to-one scale and help prioritize review. Neither proves correctness.
Here is the subscription's term_text field.
{
"score": {
"grounding_score": 0.98,
"extraction_score": 0.98
},
"value": "January 15, 2026 through January 14, 2027, inclusive",
"citation": {
"bbox": [
186,
167,
428,
183
],
"page": 1,
"page_width": 612.0,
"page_height": 792.0
}
}
The citation identifies page 1. Its bbox, or bounding box, gives the rectangle around the passage as left, top, right, and bottom coordinates measured from the top-left corner. The page dimensions let a viewer scale that rectangle. Keep the PDFs and JSON files beside the register so reviewers can follow a calculated date back to its wording.

Build a Contract Register and Compute Notice Deadlines With Python
The register combines the four records into one table with a row per contract, the view a contract management system gives a legal or finance team. We use Python to compute the current term end and subtract the required notice period. For these contracts, notice must be received at least the stated number of calendar days before the term ends. Calendar days include weekends and holidays, so the receipt deadline is term_end - notice_days, with no extra day subtracted.
Use a fixed reporting date of November 1, 2026. For automatic renewals, assume no earlier termination or non-renewal notice has taken effect. If the contract was amended, reconcile the original and its changes before using these fields.
Resolve the Current Term Dates
Create metadata.py in the same folder. Preserve an explicit end date when one exists. For a duration measured in months, use the start date plus that duration, less one day, matching the lease's wording. Advance expired renewal terms until the reporting date falls within a term.
import csv, json
from datetime import date, timedelta
from pathlib import Path
TODAY = date(2026, 11, 1)
names = ("subscription", "nda", "lease", "supply")
contracts = {name: json.loads(Path(f"{name}.json").read_text()) for name in names}
def add_months(day, months):
if day.day > 28:
raise ValueError("review month-end rule")
year, month = divmod(day.year * 12 + day.month - 1 + months, 12)
return date(year, month + 1, day.day)
def term_end(v):
if v["initial_end"]:
end = date.fromisoformat(v["initial_end"])
elif v["term_start"] and v["term_months"]:
end = add_months(date.fromisoformat(v["term_start"]), v["term_months"]) - timedelta(days=1)
else:
raise ValueError("term date unresolved")
if v["auto_renew"] is None:
raise ValueError("renewal rule missing")
if v["auto_renew"]:
interval = v["renewal_months"]
if not interval or interval < 1:
raise ValueError("renewal interval missing")
next_start = end + timedelta(days=1)
while end < TODAY:
next_start = add_months(next_start, interval)
end = next_start - timedelta(days=1)
return end
The month helper sends anniversary dates after the 28th to review because months have different lengths. Contracts with business-day counting or different end-date rules need their own calculation. The lease has no delivery date, so it remains unresolved even though its duration is known.
Save the Register With Review Flags
Append this to metadata.py to collect one row per contract. Values below the 0.9 extraction-score cutoff hold back date calculations. Expected nulls, such as the renewal interval on a non-renewing contract, do not count as low-confidence values.
Grounding is checked only on the quoted passages. A value such as auto_renew: true or renewal_months: 12 is read from wording like "renews automatically for successive twelve-month terms" rather than copied from the page, so it scores low on grounding even when it is right. The passage it came from is the evidence a reviewer opens, so a poorly grounded passage adds a source-review flag.
PASSAGES = ("term_text", "renewal_text", "convenience_text", "value_text")
rows = []
for name, data in contracts.items():
v = {key: field["value"] for key, field in data.items()}
flags, end, deadline = [], None, None
present = [field for field in data.values() if field["value"] is not None]
low = any((f["score"]["extraction_score"] or 0) < 0.9 for f in present)
passages = [data[key] for key in PASSAGES if data[key]["value"] is not None]
if any((f["score"]["grounding_score"] or 0) < 0.9 for f in passages):
flags.append("check source")
if not v["value_text"]:
flags.append("value not stated")
try:
if low:
raise ValueError("low extraction score")
end = term_end(v)
if v["auto_renew"]:
if v["notice_days"] is None or v["notice_days"] < 0:
raise ValueError("notice period missing")
deadline = end - timedelta(days=v["notice_days"])
days_left = (deadline - TODAY).days
if days_left < 0:
flags.append("notice deadline passed")
elif days_left <= 30:
flags.append("notice due within 30 days")
else:
flags.append("no renewal")
except ValueError as error:
flags.append(str(error))
rows.append({"contract": name, "parties": v["parties"],
"effective_date": v["effective_date"], "value": v["value_text"],
"governing_law": v["governing_law"],
"term_end": end.isoformat() if end else "",
"give_notice_by": deadline.isoformat() if deadline else "",
"review": "; ".join(flags)})
Append this to save the complete register as a comma-separated values (CSV) file and print its deadline columns in order. Contracts without a notice deadline sort last.
rows.sort(key=lambda row: row["give_notice_by"] or "9999-12-31")
with open("contract-register.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=list(rows[0]))
writer.writeheader()
writer.writerows(rows)
for row in rows:
print(" | ".join(row[key] or "-" for key in
("contract", "term_end", "give_notice_by", "review")))
Run it from the same folder.
python3 metadata.py
The saved results produce this deadline view. The complete CSV register also holds each contract's parties, effective date, stated value, and governing law.
supply | 2026-11-30 | 2026-10-16 | notice deadline passed
subscription | 2027-01-14 | 2026-11-15 | notice due within 30 days
nda | 2027-02-28 | - | value not stated; no renewal
lease | - | - | term date unresolved
The supplier's initial term ended in 2025. Its current renewal term ends on November 30, 2026, so its 45-day receipt deadline is October 16. The subscription's term ends on January 14, 2027, which gives a 60-day deadline of November 15, 2026. A passed notice deadline stays visible rather than being moved into the next renewal period.

Flag What Needs a Person
Review flags preserve the distinction between missing information and a decision that needs attention.
- Low scores need a source check. Here, every quoted passage scored 0.98 for grounding and every value cleared the extraction cutoff, so no row carries that flag. Choose field-specific cutoffs using the confidence score thresholds guide.
- An unresolved date needs its missing input. The lease needs the delivery certificate before anyone can date its end.
- An absent field needs context. The NDA has no stated contract value, and its confidentiality duties continue after its fixed term ends.
- A passed or approaching notice deadline needs the contract owner's attention. Check whether notice was already given and follow the clause's delivery method. The date shown is a receipt deadline, so mailing on that day is not enough.
The register gives a contract owner or lawyer a list to check. It does not replace their review.
Next Steps
- Add the fields your team tracks, such as payment terms or a liability cap, to the schema. Each new field comes back with its own citation and scores.
- Load
contract-register.csvinto a database or contract management system, and turn eachgive_notice_bydate into a calendar reminder for the contract owner. - Reconcile amendments with the original agreement before trusting a term date, and track ongoing duties with obligation extraction.
- Read the extraction API reference for the full list of schema options and models.



