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

# Getting Started

> Get up and running with Gale's API in minutes

# Getting Started

This guide walks you through creating your first checkout session using Gale's API. By the end, you'll understand the full payment flow.

## Base URL

```
https://api.withgale.com/api/v2
```

Use test API keys (prefix `glm_test_`) during development. All test transactions are processed in sandbox mode with no real charges.

## Authentication

Include your API key in the `Authorization` header:

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

Get your API keys from [Gale Dashboard](https://dashboard.withgale.com) under **Settings** > **API Keys**.

## Quick Start

### 1. Sync a Product

Before creating a checkout, sync your product catalog so Gale can determine HSA/FSA eligibility.

```bash theme={null}
curl -X POST https://api.withgale.com/api/v2/products \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Digital Blood Pressure Monitor",
    "merchant_product_id": "BP-MONITOR-001",
    "upc_code_or_gtin": "14567890123456",
    "price": 4995,
    "currency": "USD"
  }'
```

The response includes eligibility status:

```json theme={null}
{
  "success": true,
  "data": {
    "id": 12345,
    "name": "Digital Blood Pressure Monitor",
    "merchant_product_id": "BP-MONITOR-001",
    "price": 4995,
    "eligibility": {
      "hsa_fsa_eligible": true,
      "message": "SIGIS verified - Medical device"
    }
  }
}
```

### 2. Create a Checkout Session

Create a checkout session and get a URL to redirect your customer to:

```bash theme={null}
curl -X POST https://api.withgale.com/api/v2/checkout \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reference_id": "your-order-123",
    "customer": {
      "email": "jane@example.com",
      "first_name": "Jane",
      "last_name": "Doe"
    },
    "line_items": [
      {
        "product_id": "BP-MONITOR-001",
        "name": "Digital Blood Pressure Monitor",
        "price": 4995,
        "quantity": 1
      }
    ],
    "shipping_info": {
      "address_line_1": "123 Main St",
      "city": "New York",
      "state": "NY",
      "postal_code": "10001",
      "country": "US"
    },
    "shipping": 500,
    "tax": 410,
    "success_url": "https://yoursite.com/order/success",
    "failure_url": "https://yoursite.com/order/failed"
  }'
```

Response:

```json theme={null}
{
  "success": true,
  "checkout_id": "01HXYZ...",
  "checkout_url": "https://checkout.withgale.com/checkout/01HXYZ...",
  "status": "open",
  "expires_at": "2026-02-26T14:30:00Z"
}
```

### 3. Redirect Customer

Send your customer to the `checkout_url`. Gale's hosted checkout page handles:

* HSA/FSA card collection
* Eligibility verification
* Letter of Medical Necessity (LMN) flow for dual-purpose items
* Payment processing

After payment, the customer is redirected to your `success_url` or `failure_url`.

### 4. Confirm Payment

**Option A: Webhooks (recommended)**

Register a webhook endpoint in your [Dashboard](https://dashboard.withgale.com) under **Settings** > **Webhooks**. Gale sends an `order.created` event when payment succeeds:

```json theme={null}
{
  "type": "order.created",
  "data": {
    "id": "ord_abc123",
    "status": "completed",
    "checkout_id": "01HXYZ...",
    "reference_id": "your-order-123",
    "customer": {
      "email": "jane@example.com"
    }
  }
}
```

**Option B: Poll for status**

Check the checkout status by querying the order:

```bash theme={null}
curl https://api.withgale.com/api/v2/orders/{order_id} \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY"
```

## Three Key IDs

| ID             | What it is                                  | When you get it                           |
| -------------- | ------------------------------------------- | ----------------------------------------- |
| `checkout_id`  | The checkout session you created            | Returned when you create a checkout       |
| `order_id`     | The payment record after successful payment | Returned in webhooks and order queries    |
| `reference_id` | Your own order/cart ID for correlation      | You provide this when creating a checkout |

## Testing

Use test API keys (`glm_test_*`) during development. Test card numbers:

| Card Number           | Result             |
| --------------------- | ------------------ |
| `4111 1111 1111 1111` | Successful payment |
| `4000 0000 0000 0002` | Card declined      |

See [Test Cards](/resources/test-cards) for the full list.

## Next Steps

<CardGroup cols={2}>
  <Card title="Integration Flow" icon="diagram-project" href="/developer-manual/integration-flow">
    Full end-to-end integration walkthrough
  </Card>

  <Card title="Checkout Guide" icon="credit-card" href="/integration/checkout">
    Detailed checkout integration guide
  </Card>

  <Card title="API Reference" icon="terminal" href="/api-reference/introduction">
    Complete API endpoint documentation
  </Card>

  <Card title="Webhooks" icon="bell" href="/developer-manual/webhooks">
    Set up real-time event notifications
  </Card>
</CardGroup>
