> ## Documentation Index
> Fetch the complete documentation index at: https://docs.context.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Pre-filled Onboarding Flows

> Increase conversions and decrease user onboarding time by pre-filling company information during signup flow

export const PromptBanner = ({prompt, message = "Use this pre-built prompt to get started faster."}) => {
  const [copied, setCopied] = useState(false);
  const timeoutRef = useRef(null);
  useEffect(() => {
    return () => {
      if (timeoutRef.current) {
        clearTimeout(timeoutRef.current);
      }
    };
  }, []);
  const handleCopy = useCallback(async () => {
    try {
      await navigator.clipboard.writeText(prompt);
      setCopied(true);
      if (timeoutRef.current) {
        clearTimeout(timeoutRef.current);
      }
      timeoutRef.current = setTimeout(() => {
        setCopied(false);
        timeoutRef.current = null;
      }, 2000);
    } catch (err) {
      console.error("Failed to copy:", err);
    }
  }, [prompt]);
  const handleOpenInCursor = useCallback(() => {
    const url = new URL('cursor://anysphere.cursor-deeplink/prompt');
    url.searchParams.set('text', prompt);
    window.location.href = url.toString();
  }, [prompt]);
  return <div className="not-prose my-6 rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 overflow-hidden">
      <div className="p-4">
        <div className="mb-3">
          <div className="text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2">
            {message}
          </div>
          <div className="relative">
            <textarea readOnly value={prompt} className="w-full px-3 py-2 text-sm font-mono text-zinc-700 dark:text-zinc-300 bg-zinc-50 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-md resize-none focus:outline-none focus:ring-2 focus:ring-zinc-400 dark:focus:ring-zinc-600" rows={Math.min(prompt.split('\n').length, 6)} />
          </div>
        </div>

        <div className="flex items-center gap-2">
          <button onClick={handleOpenInCursor} className="inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-zinc-950 dark:bg-white text-sm font-medium text-white dark:text-zinc-950 hover:bg-zinc-800 dark:hover:bg-zinc-200 transition-colors" aria-label="Try in Cursor">
            <img src="/images/cursor-light.svg" alt="Cursor logo" className="size-4 block dark:hidden" loading="lazy" width="16" height="16" />
            <img src="/images/cursor-dark.svg" alt="Cursor logo" className="size-4 hidden dark:block" loading="lazy" width="16" height="16" />
            Try in Cursor
          </button>

          <button onClick={handleCopy} className="inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-zinc-100 dark:bg-zinc-800 text-sm font-medium text-zinc-950 dark:text-white hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors" aria-label={copied ? "Copied" : "Copy prompt"} aria-live="polite">
            {copied ? <>
                <svg className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
                </svg>
                Copied
              </> : <>
                <svg className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
                </svg>
                Copy prompt
              </>}
          </button>
        </div>
      </div>
    </div>;
};

<img src="https://mintcdn.com/branddev/JTvSrAMAd7UkFxMq/guides/image-3.png?fit=max&auto=format&n=JTvSrAMAd7UkFxMq&q=85&s=bcbef767ce3bea34d868b070854f5826" alt="alt text" width="966" height="710" data-path="guides/image-3.png" />

<PromptBanner
  message="Use this pre-built prompt to add pre-filled onboarding flows"
  prompt="Help me implement pre-filled onboarding flows using Context.dev API. Here's what I need to do:

1. Sign up for a Context.dev account at https://context.dev and get my API key
2. Implement the prefetch endpoint to start fetching brand data early when users enter their email
3. Call the /brand endpoint to retrieve company logos, descriptions, social links, and other brand assets
4. Pre-fill onboarding form fields with the fetched brand data while allowing users to override any information
5. Handle fallbacks gracefully when brand data is unavailable or incomplete
6. Optimize the onboarding flow to reduce friction and increase conversion rates

Use the Context.dev API documentation at https://docs.context.dev for implementation details. Show me how to integrate this into my existing onboarding flow."
/>

## Overview

Users increasingly find themselves having to upload the same information to websites: their logo, socials, backdrops, company descriptions and more. Context.dev's brand endpoint simplifies this process by enabling you to intelligently pre-fetch customer information and brand assets.

We'll walk through the system design and best practices for this implementation, along with some examples.

### Prerequisites

1. A [Context.dev](https://context.dev) API key
2. An existing customer onboarding flow

### Concept

Context.dev fetches company information from many sources based on the customer domain name or email.

## Architecture

### 1. Collecting User Domain/Email

Context.dev fetches company information from many sources. Responses are returned instantly if cached, if not data may take longer than 10 seconds to retrieve. This is why passing the domain/email as early as possible is crucial.

The [`prefetch` utility endpoint](/api-reference/utility/prefetch-brand-data-by-email) tells context.dev to start fetching data early on so that the brand data can be returned to the user as fast as possible. This operation does not cost any API credits, so there is no loss if the customer doesn't create an account. You are only charged once you actually fetch the brand data.

<Note>
  The prefetch by email endpoint will also return an error if the email is
  disposable or a personal address (@gmail.com, @yahoo.com, etc.)
</Note>

If a user is signing in with email/password we recommend firing a prefetch request as soon as the email field passes input validation, before they enter their new password. If signing in with OAuth, Social Providers, or SSO send the prefetch request as soon as the user's email is visible to you.

<Warning>
  Use a backend proxy to call the Context.dev endpoint so that your API key isn't
  exposed
</Warning>

### 2. Signup Process Flow

Since it may take a few seconds for the API to respond (especially with SSO) it's important to organize your onboarding flow so that there are fallbacks if data isn't available or if data couldn't be fetched. You should also try to push fields that can be pre-filled to further steps in the onboarding.

For example if your onboarding flow requires the user organization's logo, description, company role and social media links you may want to organize your onboarding questions as follows:

1. **User's Role at Company** - This information is not available with the `/brand` endpoint. Placing this first allows more time for Context.dev to fetch the data for cold hits, while providing the user a better experience.
2. **Logo** - Is available via the brand endpoint, relatively quick for the user to actually upload themselves
3. **Description** - Is available via the brand endpoint, takes more effort for the user to write and thus is better if pre-filled by Context.dev
4. **Social Media Links** - Is available via the brand endpoint, but is an optional step in your form

### 3. Call the Brand endpoint

In the example above you should call the brand endpoint just before the brand information is required (in the example above this would be during step one). This allows the information in a multi-step form to be pre-filled in the next step, without incurring unused API charges. You should never overwrite a user's choice or existing text if the brand data becomes available while the user is on that step.

<Note>
  #### Reducing Costs You could call the brand API later on in the multi-step

  onboarding form, after some users have dropped off of the funnel. The tradeoff
  is a longer onboarding. You should still call the prefetch endpoint as soon as
  possible as that does not cost any credits.
</Note>

### 4. Image Selection

For images such as logos or backdrops, select an image based on the [`mode`](/api-reference/retrieve-brand/retrieve-brand-data-by-domain#response-brand-logos-items-mode) enum field and aspect ratio. Then provide the additional options for the user to switch to.

Understand where the images are being used. If you display the user company logo in the top left of your app for aesthetics, it's probably ok to automatically pick an image from the logos and assume it is correct. In this case if the user prefers a different logo version, they can go into your app settings and change it.

However, if the information is displayed publicly (such as on a public profile) you should select a default option and provide the other options for the user to choose from allowing them to confirm their brand's external image.

## Best Practices

### 1. Don't Secretly Select Brand Data for Users

> You shouldn't assume the Context.dev information is 100% correct. If information (logos, links, descriptions) are being displayed to the user or other users, you should always let them correct or modify it. If the data is only being used for internally for analytics or not displayed to any other users it is ok to assume the data is correct.

### 2. Always Provide Fallbacks

> Always fall back to a default logo, color, and company name when brand data is missing to ensure a consistent UX. Show loading skeletons while fetching, render the branded UI when data is available, and fall back to a generic UI if no brand is found.

### 3. Skip Free Email Providers

> Skip attempts to enrich personal/free email providers (e.g., Gmail, Yahoo, Hotmail) and show a generic UI instead to avoid edge cases and inaccurate results.

<Info>
  You can use the [prefetch-by-email](/api-reference/utility/prefetch-brand-data-by-email) endpoint to automatically detect over 10K+ free + disposable email providers.
</Info>

## Related Resources

<CardGroup cols={2}>
  <Card title="Core Concepts" icon="book" href="/guides/get-started/core-concepts">
    Understanding brand data structure
  </Card>

  <Card title="Prefetch by Email" icon="bolt" href="/api-reference/utility/prefetch-brand-data-by-email">
    Optimize performance with prefetching
  </Card>

  <Card title="Lead Enrichment" icon="user-plus" href="/guides/use-cases/lead-enrichment">
    Enrich CRM data automatically
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference">
    Browse all endpoints
  </Card>
</CardGroup>
