SaaS COGS: what goes in cost of revenue, with an example
SaaS COGS is what it costs to run the product for paying customers. What goes in, what stays out, and how one quarter goes from 88% to 67% gross margin.
By The LedgerIt team7 min read
SaaS COGS, usually labeled cost of revenue, is what it costs to deliver the product to customers who are already paying: production hosting, the people who support customers and keep the service running, software built into the product, and payment processing. Building the next version, selling it and running the company stay in operating expenses, below gross profit.
The line matters because gross margin is computed from it, and gross margin is one of the first numbers an investor checks. A seed company that books only its AWS bill in cost of revenue can show 88% when the honest figure is 67%, as the worked example below shows. Neither number changes the net loss; only one survives diligence.
What counts as SaaS COGS
SaaS COGS is every cost that goes up or down with serving current customers and would stop the service if you cut it. The usual lines are production hosting and data, customer support staff, the share of engineers' time spent running production, third-party services built into the product, payment processing, and amortization of the platform's capitalized software.
A public example helps. Datadog's Form 10-K for 2025 says its cost of revenue covers costs "related to providing subscription services to paying customers." The list that follows includes:
- data center and networking expenses;
- compensation, stock-based compensation included, for customer experience and technical operations staff;
- payments to outside service providers and payment processing fees;
- amortization of capitalized internally developed software and acquired developed technology;
- allocated overhead.
Two items on that list are easy to miss at a startup. People costs are fully loaded: salary, payroll tax, benefits and stock-based compensation follow the person into the function they work in. And overhead such as rent and company-wide software is allocated by headcount, so a support team's share of it sits in cost of revenue too.
What stays out of cost of revenue
Anything spent to win new customers, build new product or run the company stays out. Sales engineers and account managers are sales and marketing; development and staging environments are research and development; finance, legal and company-wide tools are general and administrative. Interest expense sits below operating income altogether.
The test that settles most cases is a question about current customers: if you stopped paying for this tomorrow, would the service they already pay for get worse? Production databases, the on-call rotation and the support inbox pass. A staging cluster, a sales demo environment, a design tool and a recruiter do not.
Engineers are the common gray area. An engineer who builds features is research and development; the hours the same engineer spends on call for production, fixing incidents or scaling the database are cost of revenue. Split the cost by a reasonable, written estimate of time, and use the same estimate every month.
How to calculate SaaS gross margin
Gross profit is revenue minus cost of revenue, and gross margin is gross profit as a percentage of revenue. Use GAAP revenue for the period, not ARR or bookings, so both halves of the fraction cover the same months and the same contracts. Compute it monthly and quarterly from closed books.
Datadog's 10-K uses exactly those definitions and reports a gross margin of 80% for 2025 and 81% for 2024, on $686,957 thousand of cost of revenue in 2025. The denominator matters as much as the numerator: annual prepayments are earned month by month, so the revenue in this calculation is what was recognized in the period, not the cash collected.
| Line | Formula |
|---|---|
| Gross profit | Revenue − cost of revenue |
| Gross margin | Gross profit ÷ revenue |
A worked example: one seed quarter, classified twice
A seed company earns $300,000 of revenue in the third quarter of 2026. Its books put the whole $36,000 AWS bill in cost of revenue and everything else in operating expenses, so gross margin reads 88%. Sorting the same costs by the test above moves $64,000 into cost of revenue and brings gross margin to 67%.
The costs that move, and where each one belongs:
| Cost for the quarter | Amount | Booked in | Belongs in |
|---|---|---|---|
| Production hosting (AWS) | $30,000 | Cost of revenue | Cost of revenue |
| Development and staging environments (AWS) | $6,000 | Cost of revenue | Research and development |
| Customer support, fully loaded | $30,000 | General and administrative | Cost of revenue |
| Half of the site reliability engineer, on call for production | $25,000 | Research and development | Cost of revenue |
| Email and SMS APIs sent for customers | $9,000 | Research and development | Cost of revenue |
| Payment processing fees | $6,000 | General and administrative | Cost of revenue |
And the result:
| As booked | Classified | |
|---|---|---|
| Revenue | $300,000 | $300,000 |
| Cost of revenue | $36,000 | $100,000 |
| Gross profit | $264,000 | $200,000 |
| Gross margin | 88.0% | 66.7% |
| Operating expenses | Higher by $64,000 | Lower by $64,000 |
| Net loss | Unchanged | Unchanged |
Rounded, that is 88% against 67%. Nothing was spent differently and the net loss is identical; only the line where each cost sits changed. That is why an investor who sees 88% at seed asks what is in cost of revenue before believing it, and why rebuilding the split during diligence is slower than keeping it from the start.
What the SEC's Regulation S-X asks for
Regulation S-X sets the line items on a public company's income statement. Rule 5-03 asks for costs applicable to sales and revenues to be stated separately by kind, including cost of tangible goods sold and cost of services, matching how revenue is stated. It names the captions, not which SaaS costs go in them.
A private startup does not file under Regulation S-X, but acquirers, auditors and later-stage investors read statements against what public companies show. Two parts of the rule carry over well:
- Costs follow revenue. Revenues from services are stated separately from other classes of revenue, and the related costs are stated the same way. A SaaS company with meaningful implementation or consulting fees shows subscription revenue and professional services revenue, each with its own cost of revenue.
- Small classes can be combined. A class of revenue that is not more than 10 percent of the total may be combined with another class, and its costs combined in the same manner. A professional services line under 10% of revenue can ride with subscriptions.
Splitting services out matters for margin, not only presentation. Implementation work is mostly people's time, so its margin moves differently from software's, and blending the two hides both.
How to set up COGS in your books
Write a one-page cost of revenue policy, then make the chart of accounts and the payroll setup enforce it. Separate cost of revenue accounts for hosting, support, technical operations, embedded third-party services and payment processing let the classification happen when a bill is booked rather than at quarter end.
The pieces that make it hold:
- Split cloud accounts by purpose. Production in one AWS or GCP account (or tagged project), development and staging in another, so the bill arrives already divided.
- Map every employee to a department. Payroll, benefits and stock-based compensation then follow the department. For people who split their time, record the percentage and the reason.
- Tag vendors once. Each recurring vendor gets a default account when it is set up, so this month's bill lands where last month's did.
- Keep the books on accrual. Gross margin by month needs hosting, payroll and revenue in the months they belong to, which cash-basis books do not give you.
- Change the policy rarely, and say when you do. If a cost moves between lines, restate the prior periods you present so the trend compares like with like.
Where the classification is a judgment call, such as how much of an engineer is on call, an accountant can sanity-check the policy before your first audit or priced round.
What to do this month
A cost of revenue policy takes an afternoon and pays off at every board meeting. The work is listing what you spend, sorting each line with the current-customer test, and setting up the accounts so the books keep the split without a spreadsheet.
- List every vendor and every person, with last quarter's cost, and mark each one cost of revenue or operating expense with the test above.
- Separate production from development in your cloud accounts or tags.
- Record the percentage of on-call engineering time you treat as cost of revenue, and why.
- Add separate cost of revenue accounts for hosting, support, technical operations, embedded services and payment processing.
- Recompute last quarter's gross margin on GAAP revenue and compare it with what your deck says.
- Split out professional services revenue and its costs if they are more than 10% of revenue.
LedgerIt keeps a startup's books on accrual and closes them each month, with every vendor and every person mapped to the line it belongs on, so gross margin comes out of the close rather than a quarter-end rebuild.