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

# Pharmacy Integration Guide

> Step-by-step guide for pharmacies to integrate with RxScale

# Pharmacy Integration Guide

This guide walks you through the steps to integrate your pharmacy or pharmacy management system with RxScale, from receiving your API key to processing your first order.

## Step 1: Get Your API Key

Contact your RxScale account manager to receive your API credentials. You will get:

* An **API key** for authentication
* A **pharmacy UID** (or group-level access if you manage multiple pharmacies)
* Access to the **development environment** for testing

| Environment | Base URL                      |
| ----------- | ----------------------------- |
| Development | `https://api.rxscale-dev.com` |
| Production  | `https://api.rxscale.com`     |

Test your key with a health check:

```bash theme={null}
curl -X GET "https://api.rxscale-dev.com/v1/external_pharmacy_api/health/" \
  -H "X-API-Key: your-api-key-here"
```

## Step 2: Sync Your SKUs

Retrieve your pharmacy's SKU catalog and sync it with your internal product system.

```bash theme={null}
curl -X GET "https://api.rxscale.com/v1/external_pharmacy_api/pharmacy_skus/" \
  -H "X-API-Key: your-api-key-here"
```

For each SKU, you can:

* **Set your price** (in euro cents)
* **Update stock levels** to reflect your current inventory
* **Link an external ID** from your pharmacy management system

```bash theme={null}
curl -X PATCH "https://api.rxscale.com/v1/external_pharmacy_api/pharmacy_skus/psku-abc123" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "price": 1299,
    "stock": 100,
    "external_id": "YOUR-PMS-ID-001"
  }'
```

See [Pharmacy SKUs](/api-reference/external-pharmacy/skus) for full documentation.

## Step 3: Register Webhooks

Set up webhooks so your system receives real-time notifications when new orders come in or stock levels change.

```bash theme={null}
curl -X POST "https://api.rxscale.com/v1/external_pharmacy_api/webhooks/" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "target": "https://your-pharmacy.com/webhooks/rxscale",
    "notification_type": "pharmacy_order_created"
  }'
```

<Warning>
  Store the `signing_secret` returned in the response. You will need it to verify webhook signatures. It is only shown once.
</Warning>

We recommend subscribing to these event types:

| Event Type                   | Why                                                                    |
| ---------------------------- | ---------------------------------------------------------------------- |
| `pharmacy_order_created`     | Get notified immediately when a new order is assigned to your pharmacy |
| `pharmacy_order_updated`     | Track status changes (e.g. cancellations)                              |
| `pharmacy_sku_stock_updated` | Stay in sync if stock is adjusted externally                           |

See [Webhook Security](/webhooks/security) for how to verify webhook signatures.

## Step 4: Process Orders

When you receive a `pharmacy_order_created` webhook (or poll the orders endpoint), process the order through your pharmacy workflow:

### 4a. View Order Details

```bash theme={null}
curl -X GET "https://api.rxscale.com/v1/external_pharmacy_api/pharmacy_orders/po-abc123" \
  -H "X-API-Key: your-api-key-here"
```

This returns the full order including patient data, doctor data, prescription files, and line items.

### 4b. Update Order Status

As you process the order, update its status:

```bash theme={null}
curl -X PATCH "https://api.rxscale.com/v1/external_pharmacy_api/pharmacy_orders/po-abc123/status" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"status": "in-progress"}'
```

And when the order is packed and ready for pickup or shipping:

```bash theme={null}
curl -X PATCH "https://api.rxscale.com/v1/external_pharmacy_api/pharmacy_orders/po-abc123/status" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"status": "ready_for_pickup"}'
```

Complete the order through the dedicated completion endpoint so RxScale can reduce stock and publish shipment and order update events:

```bash theme={null}
curl -X PATCH "https://api.rxscale.com/v1/external_pharmacy_api/pharmacy_orders/po-abc123/complete_order" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "tracking_links": [
      {
        "tracking_link": "https://tracking.example.com/parcel/123",
        "carrier": "DHL"
      }
    ]
  }'
```

See [Order Lifecycle](/guides/order-lifecycle) for the full status flow.

## Integration Checklist

<AccordionGroup>
  <Accordion title="API key and connectivity">
    * Received API key from RxScale
    * Verified connectivity with health check endpoint
    * Tested on development environment before production
  </Accordion>

  <Accordion title="SKU synchronization">
    * Fetched full SKU catalog
    * Mapped external IDs to your pharmacy management system
    * Set initial prices and stock levels
    * Scheduled regular stock sync (or use webhooks)
  </Accordion>

  <Accordion title="Webhook setup">
    * Registered webhooks for `pharmacy_order_created` and `pharmacy_order_updated`
    * Stored signing secrets securely
    * Implemented signature verification
    * Endpoint responds with `2xx` within 5 seconds
  </Accordion>

  <Accordion title="Order processing">
    * Handling incoming orders (via webhook or polling)
    * Updating order status as you process and ship orders
    * Completing orders through the dedicated `complete_order` endpoint
    * Handling edge cases (cancellations, stock issues)
  </Accordion>
</AccordionGroup>
