---
source: https://carbone.io/examples/master-services-agreement/
title: "Contract Automation Software: MSA and SOW in Word | Carbone"
description: "Contract generation from CRM or CLM data with the Carbone API: a master services agreement, order form and SOW in Word, with clauses toggled by JSON."
generated_at: "2026-11-17"
---

# Master services agreement

Order form and statement of work from CRM or CLM data

[![Master services agreement: DOCX generated from a DOCX template and JSON data](/examples/master-services-agreement/thumb-result.webp)](/examples/master-services-agreement/result.docx "Download the generated document")

[Download template](/examples/master-services-agreement/template.docx)

[Sample data](/examples/master-services-agreement/data.json)

[Download the generated DOCX](/examples/master-services-agreement/result.docx)

- **Template:** DOCX
- **Export as:** PDF, DOCX, ODT, HTML, PNG [+25 more](/documentation/developer/http-api/generate-reports.md#output-file-type)
- **Carbone:** 5.18+

Features

-   [Conditional block](/documentation/design/conditions/conditional-blocks.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Array filter](/documentation/design/repetitions/filtering.md)
-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Aggregation](/documentation/design/computation/aggregation.md)
-   [Math](/documentation/design/computation/simple-mathematics.md)
-   [Date](/documentation/design/formatters/date.md)
-   Table of contents
-   Cross-reference
-   Header and footer

## Generate master services agreements from your CRM or CLM

Service companies sign a master services agreement (MSA) once with each customer, then an order form and a statement of work (SOW) for each project. Legal writes and approves the clauses; sales and delivery fill in the deal: parties, signatories, services, fees, term, milestones. Contract automation software joins the two. The CRM or the contract lifecycle management (CLM) system sends the deal terms to the Carbone API as JSON, and gets back the Word document to negotiate and sign. This is document assembly: the clause text stays in the template that legal owns, and the data carries the deal terms and decides which clauses apply.

In this example, Brackwell Data Services, a fictional data engineering firm in New York, contracts with Wrenfield Freight Holdings for a fixed-fee implementation project, 12 months of managed data operations and 4 days of training. The 13-page agreement has a cover, the order form with the signature blocks, 14 clauses of standard terms, the SOW and a service level schedule. The clauses follow the structure of open standard agreements, like the [Common Paper](https://commonpaper.com/standards/professional-services-agreement/) and [Bonterms](https://bonterms.com/forms/professional-services-agreement-v1-2/) professional services agreements, with original text written for this sample. The data protection clause refers to a data processing addendum, which carries the terms of [GDPR Article 28(3)](https://eur-lex.europa.eu/eli/reg/2016/679/oj) when the GDPR applies. The document is a sample, not legal advice: have counsel approve your own clauses.

In this example, you will:

-   Keep the data protection clause, the service level schedule and the governing law clauses that match the data
-   Keep the clause numbers, the cross-references and the table of contents right when clauses are removed
-   Repeat the services, the deliverables, the milestones and the project team
-   Compute the fees, the totals, the end of the term and the non-renewal deadline
-   Print the contract reference and "Page X of Y" in the header and footer

## The agreement, part by part

| Part | Content | What Carbone does |
| --- | --- | --- |
| Cover | Reference, effective date, governing law, order value, parties with entity type, address and notice contact, contents | Prints the parties, sums the order, rebuilds the contents |
| Order form | Start date, initial term, renewal, data processing, service levels, payment terms, purchase order, fees, signature blocks | Computes the end date and the non-renewal deadline, prints one row per service, removes the rows that do not apply |
| Master services agreement | Definitions, services, term and renewal, fees and payment, confidentiality, intellectual property, warranties, indemnities, limitation of liability, data protection, insurance, termination, governing law and jurisdiction, general terms | Keeps the data protection clause when personal data is processed, prints the clauses of the chosen governing law |
| Statement of work | Objectives, scope, deliverables, milestones with acceptance criteria and payments, acceptance, assumptions, change control, project team | Prints one row per deliverable, milestone and team member, totals the milestone payments |
| Service level schedule | Support hours, severity targets, data availability, service credits | Prints the schedule only when the order includes a managed service |

## How to automate a master services agreement in Word

### 1\. Number the clauses with Word, not with the data

The clause titles have the Heading 2 style, linked to a multilevel list: `1` for the clause, `1.1` for the Clause Text style and `(a)` for the Clause List style. Word computes the numbers, so the next clauses move up when one is removed. The references to other clauses are Word cross-references (Insert > Cross-reference > Numbered item > Paragraph number (full context)), like "Clause 12" in clause 3.1 and the surviving clauses in 12.5. The cover holds a [table of contents](/documentation/design/template-formats/docx.md#chapters-and-table-of-contents) of the Heading 1 and Heading 2 titles.

Carbone updates the table of contents and the cross-references in the generated document. With `"processesPersonalData": false`, clause 10 disappears, Insurance becomes clause 10, the survival clause cites 11.4, 12 and 13, and the contents lose one line.

### 2\. Keep a clause only when it applies

-   The data protection clause sits between `{d.agreement.processesPersonalData:ifEQ(true):showBegin}`, at the end of clause 9.4, and `{d.agreement.processesPersonalData:showEnd}`, at the end of clause 10.3. Both tags end paragraphs that hold text, so a removed [conditional block](/documentation/design/template-formats/docx.md#conditions-conditional-blocks) leaves no empty line. The definitions of Personal Data and of the DPA end with `{d.agreement.processesPersonalData:ifEQ(false):drop(p)}`, and the data processing row of the order form with `:drop(row)`.
-   Each governing law paragraph ends with `{d.agreement.governingLaw:ifNE('new-york'):drop(p)}` or `{d.agreement.governingLaw:ifNE('england-wales'):drop(p)}` ([smart conditions](/documentation/design/conditions/smart-conditions.md#drop-keep-element)). New York law brings the courts of New York County and a jury trial waiver. `"england-wales"` brings the courts of England and Wales, the carve-out for death, personal injury and fraud in clause 9.3(e), and the Contracts (Rights of Third Parties) Act 1999 in the third-party rights clause.
-   The service level schedule sits between `{d.orderForm.services[type=managed].code:ifEM:hideBegin}` and `{d.orderForm.services[type=managed].code:ifEM:hideEnd}`. The [array search](/documentation/design/substitutions/array-search.md#simple-filters) `[type=managed]` looks for a managed service in the order. Without one, the schedule, clause 2.5, the related definitions and the renewal and service level rows of the order form disappear.

### 3\. Repeat the services, the milestones and the team

Each table repeats a row with a [loop](/documentation/design/template-formats/docx.md#loops): `{d.orderForm.services[i].name}` in the row of the order lines, `{d.orderForm.services[i+1].code}` in the row below, which Carbone removes. The deliverables, the milestones, the project team, the severity levels and the service credits work the same way. The scope and the assumptions are arrays of strings, repeated as bullets: `{d.sow.inScope[i]}` and `{d.sow.inScope[i+1]}` in two consecutive list items ([lists](/documentation/design/template-formats/docx.md#loops-lists)).

### 4\. Compute the fees and the dates

-   `{d.orderForm.services[i].quantity:mul(.unitPrice):formatC}` prints the amount of each line, and `{d.orderForm.services[].quantity:mul(.unitPrice):aggSum:formatC}` the total, $250,600.00, on the order form and on the cover ([aggregators](/documentation/design/computation/aggregation.md)).
-   `{d.orderForm.startDate:addD(.termMonths, month):subD(1, day):formatD(LL)}` prints the end of the initial term: January 3, 2028 for 12 months from January 4, 2027. Adding `:subD(..agreement.renewalNoticeDays, day)` before `:formatD` gives the non-renewal deadline, November 4, 2027 ([date formatters](/documentation/design/formatters/date.md#addd-amount-unit-patternin)).
-   In the SOW, `{d.sow.milestones[].amount:aggSum:formatC}` totals the milestone payments, which match the fixed fee of the order line, and `{d.sow.milestones[i=-1].dueDate:formatD(LL)}` prints the date of the last milestone as the target go-live.

### 5\. Print the reference and the page numbers

The header prints `{d.agreement.reference}` beside "Master Services Agreement" and "Confidential", and the footer prints "Page X of Y" with the Word `PAGE` and `NUMPAGES` fields ([headers and footers](/documentation/design/template-formats/docx.md#headers-and-footers)). The cover has a different first page, without the header. Render the same template with `"convertTo": "pdf"` for the copy to sign.

## Related Examples

- [Solar quote with datasheets](/examples/quote-with-datasheet/index.md): DOCX template to PDF.
- [Branded service invoice](/examples/s-invoice/index.md): DOCX template to PDF.
- [Project status report](/examples/mission-report/index.md): DOCX template to PDF.

## Related topics

- [CSRD sustainability statement](/examples/csrd-sustainability-report/index.md)
- [Prescription with medication schedule](/examples/prescription/index.md)
- [Temperature monitoring report](/examples/sensor-readings/index.md)
- [GHS safety data sheet](/examples/safety-data-sheet/index.md)
- [DPE energy performance certificate](/examples/dpe-energy-performance-certificate/index.md)
- [EU energy label](/examples/eu-energy-label/index.md)
