Google Sheets Integration

Calculate U.S. surplus lines taxes directly in your spreadsheets with custom functions. No automation platform requiredโ€”just use our pre-configured template!

โšก 2-Minute Setup with Template

Copy our ready-to-use template, add your API key, and start calculating! Works like built-in Excel functionsโ€”type =CALCULATE_TAX("Texas", 10000) and get instant results. No Zapier or Make.com account needed!

๐Ÿ“Š Get Free Template

Pre-configured with all functions + 5 example worksheets

What's Included in the Template?

  • โœ… All 8 Custom Functions Pre-Installed โ€” Calculate taxes, get rates, fetch state data, look up historical rates
  • โœ… 5 Ready-to-Use Worksheets โ€” Quick start, bulk calculator, rate lookup, detailed breakdown, reference guide
  • โœ… Works Like Built-in Functions โ€” Familiar spreadsheet formula syntax
  • โœ… No Code Copying Required โ€” Just add your API key and go
  • โœ… Perfect for Manual Workflows โ€” One-off calculations and bulk processing
  • โœ… Same Pricing โ€” $0.38 per calculation (same as REST API)
  • โœ… 100 Free Calculations โ€” Included when you sign up

Prerequisites

Before installing, ensure you have:

  1. Google Account

    Access to Google Sheets via your Google/Workspace account

  2. API Key

    Get your API key at app.surpluslinesapi.com. New accounts include 100 free queries.

Quick Start (Using Template)

Get started in just 2 minutes with our pre-configured template!

Step 1: Copy the Template

  1. Click the button below to open our template
  2. Click File โ†’ Make a copy
  3. Give your copy a name (e.g., "Surplus Lines Calculator 2026")
๐Ÿ“Š Copy Template

Step 2: Get Your API Key

  1. Go to app.surpluslinesapi.com
  2. Sign in or create an account (100 free queries included)
  3. Copy your API key from the dashboard

Step 3: Add Your API Key to Your Copy

  1. In your Google Sheet copy, click Extensions โ†’ Apps Script
  2. Find line 22:
    const API_KEY = 'YOUR_API_KEY_HERE';
  3. Replace YOUR_API_KEY_HERE with your actual API key
  4. Click the Save icon (๐Ÿ’พ)
  5. Close the Apps Script tab

Step 4: Start Calculating!

Explore the 5 pre-configured worksheets:

  • Quick Start โ€” Basic tax calculations
  • Bulk Calculator โ€” Process multiple states at once
  • Rate Lookup โ€” All 53 states with tax rates
  • Detailed Breakdown โ€” Premium + Tax + Total Due
  • Reference Guide โ€” Function examples and syntax

Keep Your API Key Secure

Your API key is stored in the Apps Script code and is only accessible to you. For shared spreadsheets, consider using Google Apps Script's Properties Service to store your API key securely (see documentation below).


Alternative: Manual Installation

Prefer to install the script manually? Skip to manual installation instructions

Testing Your Setup

Using the Template (Automatic)

The template includes pre-configured examples that will automatically calculate once you add your API key:

  1. Open the "Quick Start" tab
  2. The formulas should automatically run
  3. If you see #ERROR!, click the cell and authorize:
    • Click "Review Permissions"
    • Select your Google account
    • Click "Allow"
  4. Formulas should now work across all worksheets!

Test in Apps Script Editor (Optional)

  1. In the Apps Script editor, find the function testApiConnection()
  2. Select it from the function dropdown
  3. Click the Run button (โ–ถ๏ธ)
  4. Check the Execution log at the bottom
  5. You should see "โœ… SUCCESS! API is working correctly"

Quick Test in Any Sheet

Try this formula in any cell:

=CALCULATE_TAX("California", 10000)

Expected Result: 318

โš ๏ธ Important: Use Double Quotes!

Google Sheets requires double quotes (") for strings, not single quotes ('). Using single quotes will result in a parse error.

CALCULATE_TAX(state, premium)

Calculate total tax amount for a state and premium. Returns a single number.

Parameters

Parameter Type Description
state Text State name or 2-letter code (e.g., "Texas" or "TX", "California" or "CA")
premium Number Premium amount in dollars

Returns

Total tax amount (single number). API response includes state_code (e.g., "CA").

Example

=CALCULATE_TAX("California", 10000)
=CALCULATE_TAX("CA", 10000)   // State codes work too!

Returns: 318

API Response (Internal)

{
  "success": true,
  "state": "California",
  "state_code": "CA",
  "premium": 10000,
  "total_tax": 318,
  "total_due": 10318,
  "account": {
    "balance": "0.00",
    "free_queries_remaining": 99,
    "was_free_query": true
  }
}

CALCULATE_TAX_DETAILS(state, premium, [multiline])

Get detailed breakdown including state, premium, total tax, and total due.

Parameters

Parameter Type Description
state Text State name or 2-letter code (e.g., "California" or "CA")
premium Number Premium amount in dollars
multiline Boolean Optional. If TRUE, returns data in multiple rows; if FALSE (default), returns data in one row (horizontal)

Returns

Tax breakdown (horizontal by default or vertical if multiline=TRUE). Includes state_code in API response.

Example (Single Row - Default)

=CALCULATE_TAX_DETAILS("California", 10000)
=CALCULATE_TAX_DETAILS("CA", 10000)   // State codes work too!

Returns (4 cells horizontally):

California    10000    318    10318

Example (Multi-Row)

=CALCULATE_TAX_DETAILS("California", 10000, TRUE)

Returns (4 cells vertically):

State: California
Premium: 10000
Total Tax: 318
Total Due: 10318

CALCULATE_WITH_PREMIUM(state, premium)

Calculate tax and return premium, total tax, and total due in a horizontal row.

Parameters

Parameter Type Description
state Text State name
premium Number Premium amount in dollars

Returns

Array with [premium, total_tax, total_due] in 3 horizontal columns

Example

=CALCULATE_WITH_PREMIUM("California", 10000)

Returns (3 cells horizontally):

10000    318    10318

(Premium, Total Tax, Total Due)

GET_TAX_RATE(state)

Get just the tax rate percentage for a state.

Parameters

Parameter Type Description
state Text State name or 2-letter code (e.g., "California" or "CA")

Returns

Tax rate as a percentage (e.g., 3 for 3%). API response includes state_code.

Example

=GET_TAX_RATE("California")
=GET_TAX_RATE("TX")   // State codes work too!

Returns: 3 (for California), 4.85 (for Texas)

GET_STATES()

Get list of all supported states and territories as 2-letter postal codes.

Parameters

None

Returns

Vertical array of 53 postal codes (one per cell)

Example

=GET_STATES()

Returns (1 column, 53 rows):

AL
AK
AZ
...
TX
...
WY

GET_RATES()

Get tax rates for all states.

Parameters

None

Returns

3-column array with state names, state codes, and tax rates (53 rows ร— 3 columns)

Example

=GET_RATES()

Returns (3 columns, 53 rows):

Texas         TX    4.85
California    CA    3
New York      NY    3.6
...

GET_RATES_DETAILS()

Get detailed rate information for all states including tax rate, stamping fee, filing fee, service fee, surcharge, regulatory fee, fire marshal tax, SLAS clearinghouse fee, flat fee, and legislative source.

Parameters

None

Returns

Multi-column array with all rate details (53 rows ร— 12 columns, including state_code)

Example

=GET_RATES_DETAILS()

Returns (53 rows with 12 columns each):

State         | Code | Tax Rate | Stamping Fee | Filing Fee | Service Fee | Surcharge | Regulatory Fee | Fire Marshal Tax | SLAS Fee | Flat Fee | Legislative Source
Texas         | TX   | 4.85%    | 0.04%        | null       | null        | null      | null           | null             | null     | null     | https://...
California    | CA   | 3%       | 0.18%        | null       | null        | null      | null           | null             | null     | null     | https://...
New York      | NY   | 3.6%     | 0.15%        | null       | null        | null      | null           | null             | $25      | null     | https://...
...

GET_HISTORICAL_RATE(state, date)

Look up tax rates that were in effect on a specific date. Perfect for policy audits, renewals, and historical compliance verification.

New Feature

Historical rates allow you to calculate taxes using the rates that were in effect at a specific point in timeโ€”essential for policy audits and retroactive calculations.

Parameters

Parameter Type Required Description
state Text Yes State name or 2-letter code (e.g., "Iowa" or "IA", "Texas" or "TX")
date Date/Text No The date for which to retrieve historical rates (YYYY-MM-DD format or cell reference to a date). Defaults to today's date if not provided.

Returns

Tax rate that was in effect on the specified date (single number as percentage). API response includes state_code.

Example

=GET_HISTORICAL_RATE("Iowa", "2025-06-15")
=GET_HISTORICAL_RATE("IA", "2025-06-15")   // State codes work too!

Returns: 0.95 (representing 0.95% tax rate in effect on that date)

Use Cases

  • Policy Audits โ€” Verify taxes were calculated correctly using rates in effect at policy inception
  • Renewals โ€” Compare current rates to prior year rates for renewal quotes
  • Compliance โ€” Document historical rate information for regulatory filings
  • Retroactive Calculations โ€” Calculate taxes for backdated policies

Usage Examples

Common use cases for the Google Sheets functions:

Simple Tax Calculation Table

A (State) B (Premium) C (Tax)
Texas 10000 =CALCULATE_TAX(A2, B2)
California 25000 =CALCULATE_TAX(A3, B3)

Complete Breakdown with Premium

A (State) B (Premium) C-E (Results)
California 10000 =CALCULATE_WITH_PREMIUM(A2, B2)

Formula in C2 will populate C2:E2 with: 10000 | 318 | 10318

Rate Lookup Table

A (State) B (Rate %)
Texas =GET_TAX_RATE(A2)
California =GET_TAX_RATE(A3)

Combining with Other Formulas

// Add 5% markup to tax
=CALCULATE_TAX(A2, B2) * 1.05

// Total all taxes
=SUM(C2:C10)    // where C2:C10 contain CALCULATE_TAX formulas

// Conditional calculation
=IF(B2>10000, CALCULATE_TAX(A2, B2), 0)

Pro Tips

  • Drag Formulas Down โ€” Copy formulas down to calculate taxes for multiple rows
  • Copy Values Only โ€” For large spreadsheets, copy calculated values and paste as "Values only" to avoid repeated API calls
  • Performance โ€” Functions make live API calls (1-2 seconds each)

Error Handling

Common Errors

Error Solution
Formula parse error Use double quotes (") not single quotes (') for strings
ERROR: Please configure your API key Replace YOUR_API_KEY_HERE with your actual API key in the script
ERROR: State is required State parameter is empty or missing
ERROR: Premium must be greater than 0 Premium must be a positive number
ERROR: State 'X' not found Check state name spelling. Use full state name (e.g., "Texas") or 2-letter code (e.g., "TX")
ERROR: Invalid or inactive API key Verify your API key at app.surpluslinesapi.com

API Error Codes

Code Description
NO_API_KEY X-API-Key header is required
INVALID_API_KEY Invalid or inactive API key
NO_STATE State parameter missing
INVALID_STATE State name not recognized
INVALID_PREMIUM Premium must be positive number

FAQ

How much does each calculation cost?

$0.38 per calculation (same as the REST API). New accounts include 100 free queries.

Do formulas recalculate automatically?

Yes. Functions run when the cell is created, sheet is opened/reloaded, referenced cells change, or manual recalculation (Ctrl+R or Cmd+R).

Can I use this in shared spreadsheets?

Yes. Shared spreadsheets use the owner's API key and credits. For advanced security, see the README for using Google Apps Script Properties Service.

What's the difference between CALCULATE_TAX and CALCULATE_TAX_DETAILS?

CALCULATE_TAX returns just the total tax number. CALCULATE_TAX_DETAILS returns state, premium, total tax, and total due in separate cells.

Can I process multiple policies at once?

Yes! Drag formulas down to calculate taxes for multiple rows. Each row makes one API call.

Where is my API key stored?

In the Apps Script code, accessible only to the spreadsheet owner. For shared sheets, consider using Properties Service for secure storage.

Manual Installation (Advanced)

If you prefer not to use the template, you can manually install the script:

Step 1: Get Your API Key

  1. Go to app.surpluslinesapi.com
  2. Sign in or create an account
  3. Copy your API key from the dashboard

Step 2: Install the Script

  1. Open a new Google Sheet or existing sheet
  2. Click Extensions โ†’ Apps Script
  3. Delete any existing code in the editor
  4. Copy the script code from the documentation (surplus-lines-tax.gs)
  5. Paste the entire script into the Apps Script editor
  6. Find line 22: const API_KEY = 'YOUR_API_KEY_HERE';
  7. Replace YOUR_API_KEY_HERE with your actual API key
  8. Click the Save icon (๐Ÿ’พ)
  9. Close the Apps Script tab

Step 3: Use the Functions

Start using the 7 custom functions in your spreadsheet. See the Functions Reference for examples.

Pricing

Google Sheets integration follows the same pricing as the REST API:

Free Tier 100 free queries for new accounts
Per Query $0.38 per calculation
Monthly Minimum $18/month (after free tier)
Initial Deposit $50 (credited to your balance)

Get Your API Key View Full Documentation ๐Ÿ“Š Get Free Template