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

# Algolia for Stripe Projects

> Provision Algolia applications and credentials from your terminal with Stripe Projects.

Add Algolia to your project with [Stripe Projects](https://projects.dev), a Stripe CLI plugin for provisioning and managing your app's infrastructure. One command creates a fully configured Algolia application, without a separate Algolia sign-up or email verification, and you manage billing through your existing Stripe account.

Because credentials land in your environment as soon as provisioning completes, this is a good fit for agent-driven workflows: your coding agent can provision Algolia and start indexing in the same session.

This integration provisions your Algolia application and credentials. It doesn't index your content. You can populate your indices with any indexing method: API clients, the Algolia CLI, connectors, or the Algolia Crawler.

## Before you begin

You need:

* A [Stripe](https://stripe.com) account
* The Stripe CLI with [Stripe Projects](https://projects.dev), authenticated with `stripe login`

If you're working with a coding agent, see [Build with AI agents](/doc/guides/get-started/build-with-ai) for the tools and skills that help it work with Algolia.

## Initialize your project

1. From your repository, initialize your project:
   ```sh Command line icon=square-terminal theme={"system"}
   stripe projects init
   ```
   This adds project-level metadata to your repository, recording which providers are provisioned and how credentials are handled. The CLI and any agents you use later read this metadata.
2. Optional: browse all available providers, including Algolia:
   ```sh Command line icon=square-terminal theme={"system"}
   stripe projects catalog
   ```

## Provision Algolia

<Steps>
  <Step title="Add Algolia to your project">
    ```sh Command line icon=square-terminal theme={"system"}
    stripe projects add algolia
    ```

    This registers Algolia in your project under the resource name `algolia`.
    To use a different resource name, add `--name`.
    The resource name prefixes your environment variables and identifies the service in the [management commands](#manage-your-algolia-application).
  </Step>

  <Step title="Name your Algolia application">
    Enter a name for your application.
    This name appears in the Algolia dashboard, and Stripe writes it to your `.env` file as `ALGOLIA_APPLICATION_NAME`.
    It's separate from the resource name in your project.
  </Step>

  <Step title="Choose a region">
    Select the region where you want to host your application:

    * EU West
    * US Central
    * US East
    * US West
    * United Kingdom

    You can't change the region after provisioning.
  </Step>

  <Step title="Choose your plan">
    Select Build, Grow, or Grow Plus, then accept the plan terms when prompted.
    Build is free, and both Grow plans include a free tier.
  </Step>
</Steps>

Stripe creates your Algolia account and application, generates API credentials, and adds them to your project's `.env` file:

* `ALGOLIA_APPLICATION_ID`
* `ALGOLIA_APPLICATION_NAME`
* `ALGOLIA_SEARCH_API_KEY`
* `ALGOLIA_WRITE_API_KEY`, for server-side use only

<Note>
  The injected variable names don't have a framework prefix, so build tools don't expose them to browser code. To use the application ID and search API key in your frontend, add them again with your framework's public prefix, such as `NEXT_PUBLIC_` for Next.js or `VITE_` for Vite. Never expose the write API key in frontend code.
</Note>

## Manage your Algolia application

Use the Stripe CLI to manage the lifecycle of your application. These commands take the resource name you set when you added the service, which is `algolia` by default.

* **Change your plan**: `stripe projects upgrade algolia` or `stripe projects downgrade algolia`
* **Rotate credentials**: `stripe projects rotate algolia`
* **Review charges**: `stripe projects spend algolia`
* **Check your project's services**: `stripe projects status`
* **Open the [Algolia dashboard](https://dashboard.algolia.com)**: `stripe projects open algolia`

Run `stripe projects --help` for all available commands.

## Next steps: add search to your app

* **[Index your data](/doc/guides/sending-and-managing-data/send-and-update-your-data)**: send the content you want to search to Algolia as records, authenticating with the injected credentials.

  <Expandable title="Prompt">
    ```text expandable theme={"system"}
    You are a software engineer working on an existing codebase. Your task is to implement Algolia indexing in a way that fits the current architecture.

    Before writing any code:

    1. Inspect the repository and understand the backend architecture, where data is created, stored, or synchronized, and any existing pipelines, jobs, or APIs responsible for data flow.
    2. Check whether this project can use an existing Algolia integration or connector. If a suitable integration exists, explain which one applies and why, and outline how it would be introduced into this codebase. If not, identify the language and framework used, then select the appropriate Algolia API client.

    Don't write code yet. First, summarize your understanding of the system, propose a clear, minimal plan for adding indexing, state your assumptions explicitly, and ask clarifying questions if anything is unclear or ambiguous.

    Then implement a minimal, idiomatic indexing setup that:

    - Sends relevant application data to an Algolia index.
    - Uses credentials already available as environment variables in `.env`.
    - Uses environment-aware index naming, such as `dev`, `staging`, and `prod`.
    - Integrates with existing data flows rather than duplicating them.

    Avoid large refactors, keep changes small, safe, and easy to review, and follow existing project conventions.

    After implementing, explain how indexing is triggered, such as on write, in a batch job, or with a script. Describe how to run and test indexing locally, and how to verify that records are correctly indexed in Algolia.
    ```
  </Expandable>

* **[Configure relevance](/doc/guides/managing-results/relevance-overview)**: tell Algolia which attributes to search, how to rank results, and which attributes to use as facets.

  <Expandable title="Prompt">
    This prompt applies settings with the [Algolia CLI](/doc/tools/cli/get-started).

    ```text expandable theme={"system"}
    You are a software engineer working on an existing codebase. Your task is to review the indexed record schema and apply a safe first pass of Algolia index settings using the Algolia CLI.

    Before making any changes:

    1. Inspect the codebase and the indexing implementation.
    2. Use the Algolia CLI to inspect sample records from the index and understand the schema.
    3. Identify which indices are written to, the shape of the indexed records, which fields are consistently present, and which fields are text, numeric, boolean, categorical, or date-like.
    4. Verify which fields exist in the indexed records before proposing any settings.

    Don't apply settings yet. First, propose values for `searchableAttributes`, `customRanking`, and `attributesForFaceting`, plus sortable attributes or replicas only if they're clearly useful.

    For searchable attributes:

    - Include fields users are likely to search directly, such as names, titles, brands, categories, tags, and short descriptions.
    - Exclude IDs, URLs, booleans, internal metadata, and purely numeric fields.
    - Order attributes by likely importance, and only group attributes together if they're genuinely equal in importance.

    For custom ranking:

    - Use fields that represent quality, popularity, freshness, or business value, and avoid weak or noisy signals.
    - Use `desc()` when higher values should rank higher, and `asc()` only where lower values are clearly better.
    - If no credible ranking fields exist, say so rather than inventing weak ones.

    For faceting:

    - Include fields users would realistically filter on, such as category, brand, type, or availability.
    - Avoid fields that are unique, long text, or clearly unsuitable for filtering.
    - Use `searchable()` only where facet value search would genuinely help, and `filterOnly()` only for programmatic filters that you don't intend to display.

    For sortable attributes and replicas, stay conservative: sorting often requires replicas, so omit it unless it's clearly useful in the product experience.

    Explain your reasoning briefly and concretely, list your assumptions, and ask clarifying questions if business intent, user experience, or the meaning of a field is ambiguous. Wait for approval before applying changes.

    Once approved, use the Algolia CLI to apply the settings to the correct index, keep changes minimal and easy to review, show the exact commands you used, and explain how to verify the settings locally and in Algolia.

    Don't invent fields that aren't present in the indexed schema, don't make large refactors, and don't assume every numeric field should affect ranking. Prefer a safe first pass over an aggressive configuration.
    ```
  </Expandable>

* **[Build your UI](/doc/guides/building-search-ui/what-is-instantsearch/js)**: create a search or chat interface with prebuilt InstantSearch components, backed by [Agent Studio](/doc/guides/algolia-ai/agent-studio) for conversational AI.

  <Expandable title="Prompt">
    ```text expandable theme={"system"}
    You are a software engineer working on an existing application. Your task is to add a search experience powered by Algolia that fits naturally into the current frontend architecture.

    Before writing any code:

    1. Inspect the frontend structure and understand the framework in use, how components are organized, and how data fetching and state are handled.
    2. Choose an appropriate search UI approach for this stack.

    Don't write code yet. First, summarize your understanding of the UI architecture, propose a minimal implementation plan for adding search, state your assumptions explicitly, and ask clarifying questions if any user experience, routing, or data flow is unclear.

    Then implement a minimal but polished search experience with a query input, a results list, basic states such as loading and empty results, and any faceting and filtering the use case and indexed schema require. Make sure the implementation:

    - Uses Algolia credentials already available as environment variables in `.env`.
    - Follows existing project conventions and patterns.
    - Integrates cleanly with the current UI and routing.
    - Avoids unnecessary complexity and new abstractions.

    Keep the implementation simple and extensible, and don't introduce large structural changes unless necessary.

    After implementing, explain how to run and test the search locally, and how to verify that queries and results work correctly.
    ```
  </Expandable>
