Look up payer IDs in Google Sheets

You can turn payer names into payer IDs (or the reverse) in Google Sheets using the Search Payers API endpoint. 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 or use the List Payers CSV endpoint.

Requirements

To use the Search Payers API endpoint, you need a paid Stedi plan. If you don’t have one, upgrade to our pay-as-you-go plan.

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:

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.

    /**
     * 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.

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:

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

Note

The payer names returned by the Search Payers API endpoint 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.

Get started

The Payers API is available on all paid Stedi plans.

To get started with Stedi, sign up 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. There are no monthly minimums or setup fees. You only pay for the transactions you use.

PreviousSpotlight: Federico Ruiz @ Puppeteer AI

Get started with Stedi

Start free with a sandbox account. Upgrade to production when you’re ready. There are no monthly minimums or setup fees. You only pay for the transactions you use. See our pricing.

Sign up free