# Quickstart

Get a key, fetch the clinic's site, render a page with the SDK and send a test lead.

This page takes you from nothing to a working request in four steps: the clinic's key, the site as JSON, a page rendered with the SDK, and a lead that lands in the clinic's panel.

## 1. Get the clinic's key

Every request carries the clinic's secret key. The clinic (or you, with access to its panel) creates it in **Ustawienia → Integracje → Klucz API** with **Wygeneruj klucz**. The key starts with `pp_live_` and is shown once: store it as an environment variable of your server.

```bash Shell
export PP_API_KEY="pp_live_..."
```

The key identifies the clinic, so no URL carries a clinic id. Keep it on the server: never put it in code that runs in a browser. More in [API keys](https://pozyskajpacjenta.pl/docs/concepts/api-keys).

## 2. Fetch the site

The base URL of every endpoint is `https://app.pozyskajpacjenta.pl/api/v1`.

```bash cURL
curl "https://app.pozyskajpacjenta.pl/api/v1/site" \
  -H "Authorization: Bearer $PP_API_KEY"
```

You get the clinic's name, domain, menu, theme tokens and profile (contact, address, opening hours). This excerpt is from a recorded response:

```json Response (excerpt)
{
  "site": {
    "name": "Klinika Wzorcowa",
    "primaryDomain": "wzorcowa.pozyskajpacjenta.pl",
    "menu": [
      {
        "label": "Strona główna",
        "path": "/"
      },
      {
        "label": "Zabiegi",
        "path": "/zabiegi"
      }
    ],
    "profile": {
      "phone": "+48 22 100 20 30",
      "address": {
        "street": "ul. Przykładowa 12",
        "postalCode": "00-950",
        "city": "Warszawa",
        "district": "Mokotów",
        "accessNote": "Wejście od podwórza, parter, winda."
      },
      "openingHours": {
        "mon": [
          {
            "opens": "08:00",
            "closes": "20:00"
          }
        ]
      }
    },
    "noindex": false
  }
}
```

## 3. Render a page with the SDK

The [TypeScript SDK](https://pozyskajpacjenta.pl/docs/sdk) wraps every endpoint and types every response. `getContent(path)` returns the page at a path together with its site; `page.kind` tells you how to render it.

```ts TypeScript
import { PozyskajPacjentaClient } from "@pozyskajpacjenta/sdk";

const client = new PozyskajPacjentaClient({
  apiKey: process.env.PP_API_KEY ?? "",
  baseUrl: "https://app.pozyskajpacjenta.pl",
});

const { site, page } = await client.getContent("/");

if (page.kind === "page") {
  for (const block of page.blocks) {
    // render the block types you support by block.type; skip the rest
  }
}
```

A page built in the clinic's editor is a list of blocks; treatments, the team, case studies and posts come as their own page kinds. See [Content model](https://pozyskajpacjenta.pl/docs/concepts/content-model).

## 4. Send a test lead

Send an enquiry the way your contact form will:

```bash cURL
curl -X POST "https://app.pozyskajpacjenta.pl/api/v1/leads" \
  -H "Authorization: Bearer $PP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Test z nowej strony", "phone": "+48 600 100 200", "message": "Test formularza, prosimy nie oddzwaniać." }'
```

```json Response
{
  "ok": true,
  "leadId": "rS2bIhedVSStSQLc7DL_T"
}
```

The lead appears in the clinic's panel under **Zapytania**. It is a real lead: reception gets the usual e-mail, so tell the clinic before you test, and say it is a test in the message.

## Next

- [Content model](https://pozyskajpacjenta.pl/docs/concepts/content-model): how pages, blocks and entities fit together.
- [Booking modes](https://pozyskajpacjenta.pl/docs/concepts/booking-modes): online booking, a request for a time, or the phone.
- [API reference](https://pozyskajpacjenta.pl/docs/reference): every endpoint with samples and recorded responses.
