# Look up payer IDs in Google Sheets

> Turn payer names to IDs (and the reverse) in Google Sheets using Stedi’s Payers API. No coding needed. Just follow the guide.

Published Sep 3, 2025

Category: Guide

You can turn payer names into payer IDs (or the reverse) in Google Sheets using the [Search Payers API endpoint](https://www.stedi.com/docs/healthcare/api-reference/get-search-payers). This guide tells you how.

Tip

If you just want a full list of Stedi’s payers in a spreadsheet-friendly format, you can download the latest payer CSV from the [Stedi Payer Network](https://www.stedi.com/healthcare/network) or use the [List Payers CSV endpoint](https://www.stedi.com/docs/healthcare/api-reference/get-payers-csv).

## Requirements

To use the [Search Payers API endpoint](https://www.stedi.com/docs/healthcare/api-reference/get-search-payers), you need a paid Stedi plan. If you don’t have one, upgrade to our [pay-as-you-go plan](https://www.stedi.com/pricing).

## Step 1. Create a production API key

1.  Log in to Stedi.

2.  Click your account name at the top right of the screen.

3.  Select **API Keys**.

4.  Click **Generate new API Key**.

5.  Enter a name for your API key.

6.  Select **Production** mode.

7.  Click **Generate**. Stedi generates an API key and allows you to copy it.

If you lose the API key, delete it and create a new one.

## Step 2. Open Google Sheets

In your Google Sheet spreadsheet, place your payer names or payer IDs in column A. You can mix them if desired. For example:

```text
Blue Cross Blue Shield of Michigan
Aetna
87726
```

How this may look in your spreadsheet:

Google Sheets example

## Step 3. Create the script

1.  In the Google Sheets menu, click **Extensions > Apps Script**.

2.  Delete what’s in the editor.

3.  Paste in the following code. Replace `YOUR_STEDI_API_KEY` with your Stedi API key.

    ```javascript
    /**
     * Returns the payer name and primary payer ID from Stedi's Payer Search API.
     * Usage: =STEDI_PAYER_INFO(A2)
     * Output: [[payer name, primary payer ID]]
     */
    function STEDI_PAYER_INFO(query) {
      if (!query) return [["", ""]];

      const cache = CacheService.getScriptCache();
      const cacheKey = `stedi_payer_${query}`;

      const cached = cache.get(cacheKey);
      if (cached) {
        return JSON.parse(cached);
      }

      const lock = LockService.getScriptLock();
      try {
        lock.waitLock(30000);

        const cachedAfterLock = cache.get(cacheKey);
        if (cachedAfterLock) {
          return JSON.parse(cachedAfterLock);
        }

        const apiKey = "YOUR_STEDI_API_KEY"; // Replace with your Stedi API key
        const encodedQuery = encodeURIComponent(query);
        const url = "https://healthcare.us.stedi.com/2024-04-01/payers/search?query=" + encodedQuery;
        const options = {
          "method": "get",
          "headers": { "Authorization": apiKey },
          "muteHttpExceptions": true
        };

        const response = UrlFetchApp.fetch(url, options);
        const status = response.getResponseCode();
        if (status === 403) {
          return [["Error: Invalid or missing API key", ""]];
        }

        const result = JSON.parse(response.getContentText());
        let output;

        if (
          result.items &&
          result.items.length > 0 &&
          result.items[0].payer &&
          result.items[0].payer.displayName &&
          result.items[0].payer.primaryPayerId
        ) {
          output = [[
            result.items[0].payer.displayName,
            result.items[0].payer.primaryPayerId
          ]];
        } else {
          output = [["No match found", ""]];
        }

        // Cache successful results for 24 hours
        if (!output[0][0].startsWith("Error:") && output[0][0] !== "No match found") {
          cache.put(cacheKey, JSON.stringify(output), 86400);
        }

        return output;
      } catch (e) {
        if (e.toString().includes("timeout")) {
          return [["Error: Request timeout - try again", ""]];
        }
        return [["Error: " + e.message, ""]];
      } finally {
        lock.releaseLock();
      }
    }
    ```

4.  Click the **Save project to Drive** icon or press **Ctrl** + **S**.

The script creates an `=STEDI_PAYER_INFO()` formula that outputs the payer name and primary payer ID from the [Search Payers API endpoint](https://www.stedi.com/docs/healthcare/api-reference/get-search-payers).

## Step 4. Use the Google Sheets formula

In your Google Sheets spreadsheet, use the `=STEDI_PAYER_INFO()` formula to get the payer name and primary payer ID for each value in column A. For example:

[Watch the video](https://www.stedi.com/blog/media/look-up-payer-ids-in-google-sheets/google-sheets-example.mp4)

The search supports fuzzy matching. The formula returns the closest match available.

Note

The payer names returned by the [Search Payers API endpoint](https://www.stedi.com/docs/healthcare/api-reference/get-search-payers) are intended for routing transactions – not for display in patient-facing UIs. If you need a patient-facing name, build your own list and map the names to [Stedi payer IDs](https://www.stedi.com/docs/healthcare/supported-payers#stedi-payer-id).

## Get started

The [Payers API](https://www.stedi.com/docs/healthcare/api-reference/get-search-payers) is available on all paid Stedi plans.

To get started with Stedi, [sign up](https://portal.stedi.com/auth/sign-up-intent) for a free sandbox account. It takes less than two minutes. No credit card is required.

When you’re ready, upgrade to production on our [pay-as-you-go plan](https://www.stedi.com/pricing). There are no monthly minimums or setup fees. You only pay for the transactions you use.
