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

# Introduction to the Flex API

> Learn the basics of integrating with the Flex API to accept HSA/FSA payments

The Flex API allows you to integrate HSA/FSA payment capabilities directly into your application. This guide covers the basics of how to get started with the API, authentication, and core concepts.

## Authentication

All API requests must include your API key in the Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

<Note>
  Always keep your API keys secure and never expose them in client-side code. You can generate and manage API keys in the [Partner Dashboard](https://dashboard.withflex.com/apikeys).
</Note>

## Base URL

All API requests should be made to the following base URL:

```
https://api.withflex.com/v1
```

## Content type

API requests with a request body should specify the content type:

```
Content-Type: application/json
```

## Test mode

Flex provides a test mode environment that allows you to test your integration without processing real payments. Test mode API keys start with `fsk_test_`, while production API keys start with `fsk_`.

<Warning>
  Be sure to replace your test API keys with production keys when you're ready to go live.
</Warning>

## API response format

All API responses are returned in JSON format. Successful responses will include the requested resource(s), while error responses will include an error code and message.

Example successful response:

```json theme={null}
{
  "checkout_session": {
    "checkout_session_id": "fcs_01HW5KTQQAAQ66WV19MFW4DTT4",
    "status": "complete",
    "amount_total": 4999,
    "redirect_url": "https://checkout.withflex.com/pay/c/fcs_01HW5KTQQAAQ66WV19MFW4DTT4",
    "mode": "payment"
    // ...other properties
  }
}
```

Example error response:

```json theme={null}
{
  "error": {
    "code": "invalid_request",
    "message": "Missing required parameter: price"
  }
}
```

## Rate limits

The Flex API enforces rate limits to ensure stability. If you exceed the rate limit, you'll receive a `429 Too Many Requests` response. The response headers will include information about when you can retry.

## Core resources

The Flex API is organized around these core resources:

| Resource          | Description                                   |
| :---------------- | :-------------------------------------------- |
| Products          | What you're selling (goods or services)       |
| Prices            | How much and how often to charge for products |
| Checkout Sessions | A session representing a purchase attempt     |
| Customers         | The buyers of your products                   |
| Payment Intents   | The intent to make a payment                  |
| Subscriptions     | Recurring payment arrangements                |

## Next steps

Explore these guides to learn more about specific aspects of the Flex API :

<CardGroup cols={2}>
  <Card title="Products & Prices" href="/developer-guides/products-and-prices/how-products-and-prices-work" icon="tag" iconType="regular" />

  <Card title="Checkout Integration" href="/developer-guides/integration/checkout/how-checkout-works" icon="rocket" iconType="regular" />

  <Card title="Subscriptions" href="/developer-guides/subscriptions/overview" icon="repeat" iconType="regular" />

  <Card title="Webhooks" href="/developer-guides/webhooks/overview" icon="code" iconType="regular" />
</CardGroup>

For a complete reference of all API endpoints, see the API Reference section.

## AI assistants (MCP)

The Flex MCP exposes the API surface described here as typed tools for AI assistants — Claude, Cursor, Windsurf, and any other Model Context Protocol-compatible client. See the [Flex MCP overview](/developer-guides/integration/mcp/overview) to connect your assistant.
