Developing a Marketplace App

Phase 1: Build a custom app for your own workspace

The first step to building a Marketplace App is to build a Custom App. Please note, usage of the Copilot SDK is required for Marketplace apps.

Testing session tokens

Many Marketplace Apps require access to the session token, which includes information about:

  1. The currently logged-in internal user.
  2. The current client-user. Note, when client ID is present it doesn’t necessarily mean the client is the logged in user. It can be:
    1. A logged-in client.
    2. A client that’s being previewed by an internal user.
  3. The company ID associated with the client.
  4. The workspace ID where the app is installed and is being rendered.

For more information on session tokens, visit the session token section of the guide to Setting up the SDK.

During development you’ll likely be developing on [localhost:3000](http://localhost:3000) and by default you won’t have a session token to work with. In order to generate a session token for testing purposes you can take the token from the URL of the iFrame rendered in your Copilot workspace. For instance, if we’d like to test a token that has a client ID we can take the following steps:

  1. Once your custom app has been created, visit the installed version of your app in your client portal.
  2. Using the element inspector, find the iFrame element where your app is rendered. The simplest way to do that is to search for the following selector in the element inspector: iframe[src*=""]. If you’re using a domain supplied by Vercel, for example, that selector would be: iframe[src*=""].
  3. Take the token query parameter from the iFrame URL and paste it into your localhost URL. For instance, if the iFrame app URL is: then your localhost URL should read: http://localhost:3000?token=12345.
  4. Call the getTokenPayload function in the SDK to get the values in the token.

Phase 2: Update the code to work on any workspace

Once you’ve got a functioning app, it’s time to make sure the code is general enough to support a variety of workspaces. Let’s go through some of the considerations necessary to accomplish this.

Workspace customization

Each workspace has various customizations and metadata associated with it, like the name of the workspace, brand colors, fonts, and logo images on the customization page. You can fetch these workspace customizations by calling the retrieveWorkspace function in the SDK and using the supplied values in your app.

Some values are simply to implement, like the workspace name. Let’s get into some of the more advanced values here.

Using color values

Colors are returned as a valid CSS color value and can be injected into your app in your chosen way of authoring CSS.

colorSidebarBackgroundThe background color of the left hand sidebar of a client portal.
colorSidebarTextThe text color in the left hand sidebar of a client portal.
colorAccentThe accent color chosen by the workspace admin.

Fetching fonts

Fonts are returned as a human readable font label. In order to load the appropriate font you’ll have to do a little parsing of the font family name and fetch the font file from Google Fonts. For instance, let’s say the retrieveWorkspace endpoint returns font: "Rubik Scribble"; In order to fetch this font you’ll need to replace the space with a plus sign and inject it into the following code:

import Head from 'next/head'
import type { CopilotAPI } from 'copilot-node-sdk';

export function FontDownloader({ copilot }: { copilot: CopilotApi }) {
  const workspace = await copilot.retrieveWorkspace();
  const fontFamily = workspace.font.split(' ').join('+');
	return (
			<link rel="preconnect" href="">
			<link rel="preconnect" href="" crossorigin>
			<link href=`{fontFamily}&display=swap` rel="stylesheet">

Using images

Images are also returned from the workspace endpoint. These images can be helpful to reinforce the branding of the workspace the app is installed in. Before using these images, consider the “Client branding” option that lets a workspace owner toggle between displaying their own branding and displaying their clients’ branding.

squareIconUrlA cropped logo that is guaranteed to be a square.
fullLogoUrlThe unprocessed logo image.

Handling the “Enable companies” toggle

Each Copilot workspace has the option to enable or disable companies, this is particularly useful when a service business targets individual people rather than corporate clients. When the retrieveWorkspace endpoint returns isCompaniesEnabled: false, your app should avoid displaying companies in its UI.

Relying on custom fields

Custom fields are a powerful way to associate clients with arbitrary data. However, when developing marketplace apps you can no longer rely on custom fields that are saved on clients in your development workspace. To fetch the list of custom fields that are available in a workspace, call the List Custom Fields API endpoint.