> Documentation index: https://docs.dev.repp.co.il/llms.txt - fetch it to find every page of these docs.

# Partner quickstart

## 1. Get your keys

You get two keys from Repp. The **publishable key** (`rpk_test_…`) goes in your page; it only says who you are. The **secret key** (`rsk_test_…`) stays on your server; it makes sessions. Test keys are all there is in early access. See [Authentication & keys](https://docs.dev.repp.co.il/partners-authentication.md).

```bash
export REPP_SECRET_KEY="rsk_test_…"
```

## 2. Make sessions on your server

Add one endpoint to your server that your page calls. It works out the business and the person from your own sign-in, builds the session's body from your own data, calls [Sessions](https://docs.dev.repp.co.il/partners-sessions.md), and answers the `client_secret` alone.

```js
// Your server (Node 18+ with Express): a session for the person signed in to your system.
const COMPONENTS = ["messenger", "connect", "substitute", "class-status"];

app.post("/repp/session", requireSignedIn, async (req, res) => {
  const { component, classId } = req.body; // what the SDK asked for
  if (!COMPONENTS.includes(component)) return res.status(400).end();
  const business = req.user.business; // never a business id sent by the browser

  const body = {
    partner_business_id: String(business.id),
    partner_business_name: business.name,
    partner_user: { id: String(req.user.id), role: roleInRepp(req.user), display_name: req.user.firstName },
    component,
    class: null,
  };
  if (component === "messenger") {
    // From your own data: the next ~14 days of classes (up to 100) and the rooms (up to 50).
    body.classes = await comingClasses(business, { days: 14, max: 100 });
    body.rooms = await roomsOf(business, { max: 50 });
  } else if (component !== "connect") {
    // One of this business's classes, or nothing.
    body.class = await classSnapshot(business, classId);
    if (!body.class) return res.status(404).end();
  }

  const response = await fetch("https://api.dev.repp.co.il/partner/v1/embed-sessions", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.REPP_SECRET_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  });
  if (!response.ok) return res.status(502).end();
  const { client_secret } = await response.json();
  res.json({ client_secret }); // the secret alone: never your key, never the whole answer
});
```

The call to Repp itself, in every language:

**cURL**

```bash
curl -X POST "https://api.dev.repp.co.il/partner/v1/embed-sessions" \
  -H "Authorization: Bearer $REPP_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "partner_business_id": "4012",
  "partner_business_name": "סטודיו מרכז",
  "partner_user": {
    "id": "51751",
    "role": "manager",
    "display_name": "מיכל"
  },
  "component": "messenger",
  "class": null,
  "classes": [
    {
      "partner_class_id": "30146899",
      "date": "2026-12-07",
      "time": "18:00",
      "duration_minutes": 60,
      "style": "pilates",
      "service_name": "פילאטיס מכשירים",
      "branch_name": "סניף ראשי"
    }
  ],
  "rooms": [
    {
      "partner_room_id": "room-2",
      "name": "סטודיו גדול",
      "branch_name": "סניף ראשי",
      "capacity": 20
    }
  ]
}'
```

**JavaScript**

```js
const response = await fetch("https://api.dev.repp.co.il/partner/v1/embed-sessions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.REPP_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "partner_business_id": "4012",
    "partner_business_name": "סטודיו מרכז",
    "partner_user": {
      "id": "51751",
      "role": "manager",
      "display_name": "מיכל"
    },
    "component": "messenger",
    "class": null,
    "classes": [
      {
        "partner_class_id": "30146899",
        "date": "2026-12-07",
        "time": "18:00",
        "duration_minutes": 60,
        "style": "pilates",
        "service_name": "פילאטיס מכשירים",
        "branch_name": "סניף ראשי"
      }
    ],
    "rooms": [
      {
        "partner_room_id": "room-2",
        "name": "סטודיו גדול",
        "branch_name": "סניף ראשי",
        "capacity": 20
      }
    ]
  }),
});
if (!response.ok) throw new Error((await response.json()).error.code);
const session = await response.json();
// Hand only session.client_secret to your page.
```

**TypeScript**

```ts
interface SessionCreated {
  id: string;
  /** Hand it to your page as it is: it works once, for 5 minutes. */
  client_secret: string;
  expires_at: string;
  component: "connect" | "substitute" | "class-status" | "messenger";
  /** Whether this business already connected its Repp account. */
  connected: boolean;
}

interface EmbedError {
  error: { code: string; message: string };
}

const response = await fetch("https://api.dev.repp.co.il/partner/v1/embed-sessions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.REPP_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "partner_business_id": "4012",
    "partner_business_name": "סטודיו מרכז",
    "partner_user": {
      "id": "51751",
      "role": "manager",
      "display_name": "מיכל"
    },
    "component": "messenger",
    "class": null,
    "classes": [
      {
        "partner_class_id": "30146899",
        "date": "2026-12-07",
        "time": "18:00",
        "duration_minutes": 60,
        "style": "pilates",
        "service_name": "פילאטיס מכשירים",
        "branch_name": "סניף ראשי"
      }
    ],
    "rooms": [
      {
        "partner_room_id": "room-2",
        "name": "סטודיו גדול",
        "branch_name": "סניף ראשי",
        "capacity": 20
      }
    ]
  }),
});
if (!response.ok) throw new Error(((await response.json()) as EmbedError).error.code);
const session = (await response.json()) as SessionCreated;
// Hand only session.client_secret to your page.
```

**Python**

```python
import os

import requests

response = requests.post(
    "https://api.dev.repp.co.il/partner/v1/embed-sessions",
    headers={"Authorization": f"Bearer {os.environ['REPP_SECRET_KEY']}"},
    json={
        "partner_business_id": "4012",
        "partner_business_name": "סטודיו מרכז",
        "partner_user": {
            "id": "51751",
            "role": "manager",
            "display_name": "מיכל",
        },
        "component": "messenger",
        "class": None,
        "classes": [
            {
                "partner_class_id": "30146899",
                "date": "2026-12-07",
                "time": "18:00",
                "duration_minutes": 60,
                "style": "pilates",
                "service_name": "פילאטיס מכשירים",
                "branch_name": "סניף ראשי",
            },
        ],
        "rooms": [
            {
                "partner_room_id": "room-2",
                "name": "סטודיו גדול",
                "branch_name": "סניף ראשי",
                "capacity": 20,
            },
        ],
    },
    timeout=30,
)
if not response.ok:
    raise RuntimeError(response.json()["error"]["code"])
session = response.json()
# Hand only session["client_secret"] to your page.
```

**PHP**

```php
<?php
$ch = curl_init("https://api.dev.repp.co.il/partner/v1/embed-sessions");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("REPP_SECRET_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "partner_business_id" => "4012",
        "partner_business_name" => "סטודיו מרכז",
        "partner_user" => [
            "id" => "51751",
            "role" => "manager",
            "display_name" => "מיכל",
        ],
        "component" => "messenger",
        "class" => null,
        "classes" => [
            [
                "partner_class_id" => "30146899",
                "date" => "2026-12-07",
                "time" => "18:00",
                "duration_minutes" => 60,
                "style" => "pilates",
                "service_name" => "פילאטיס מכשירים",
                "branch_name" => "סניף ראשי",
            ],
        ],
        "rooms" => [
            [
                "partner_room_id" => "room-2",
                "name" => "סטודיו גדול",
                "branch_name" => "סניף ראשי",
                "capacity" => 20,
            ],
        ],
    ]),
]);
$session = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
    throw new RuntimeException($session["error"]["code"]);
}
// Hand only $session["client_secret"] to your page.
```

## 3. Load the script and boot the messenger

```html
<script src="https://embed.dev.repp.co.il/v1/repp-embed.js"></script>
```

```js
const repp = await ReppEmbed.load({
  publishableKey: "rpk_test_…",
  // Called for every frame Repp loads, and again when a session runs out.
  fetchClientSecret: async ({ component, classId }) => {
    const response = await fetch("/repp/session", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ component, classId }),
    });
    if (!response.ok) throw new Error("No Repp session");
    return (await response.json()).client_secret;
  },
});

const messenger = repp.boot({ alignment: "left" });
```

The button appears in the bottom left corner, and the panel loads hidden behind it, so its count is live and it opens at once. See the [Messenger SDK](https://docs.dev.repp.co.il/partners-messenger.md) for every option.

## 4. Open it from your own buttons (optional)

Your calendar and menus can open the panel right where the business needs it: on one class, or on the rooms for rent.

```js
// "Find a substitute trainer" on a class in your own calendar:
findButton.addEventListener("click", () => messenger.showSubstitute("30146899"));

// "Rent out a room" in your own menu:
rentButton.addEventListener("click", () => messenger.showSpace("spaces"));
```

## 5. Block rooms that were booked

When a trainer books a room the business opened from the panel, your calendar should hold that room for those hours. **Do it from [Webhooks](https://docs.dev.repp.co.il/partners-webhooks.md) on your server**: `room.booking_requested`, `room.booking_confirmed` and `room.booking_cancelled` reach you whether or not anyone has your page open, signed, and retried until you answer. Set your endpoint once with your secret key.

Your page hears the same while the messenger is booted, so an open calendar can update at once: when it boots it first says each room's whole window (`room_bookings`), then each change (`room_booking_changed`).

```js
// One block per booking and day (a weekly booking holds the room on several days).
const blockId = (room, booking) => `repp:${room}:${booking.repp_booking_id}:${booking.date}`;
const block = (room, booking) =>
  calendar.blockRoom(room, blockId(room, booking), {
    date: booking.date,
    from: booking.start_hour,
    to: booking.end_hour,
    tentative: booking.state === "pending",
  });

// When the messenger boots, and each new day: the room's whole window. Replace your Repp blocks of that room
// in those days, so whatever changed while your page was closed is right too.
messenger.on("room_bookings", ({ partner_room_id, from, to, bookings }) => {
  calendar.removeBlocks(partner_room_id, { prefix: "repp:", from, to });
  for (const booking of bookings) block(partner_room_id, booking);
});

// Between reads: one booking on one day came, was confirmed or went.
messenger.on("room_booking_changed", (booking) => {
  if (booking.state === "cancelled") calendar.removeBlock(blockId(booking.partner_room_id, booking));
  else block(booking.partner_room_id, booking);
});
```

> **Note:** Browser events reach only a page where the messenger is booted. Keep your record of bookings from [Webhooks](https://docs.dev.repp.co.il/partners-webhooks.md): they are the source of truth, and the browser's events only a quicker hint.

```js
// When the person signs out of your system:
messenger.shutdown();
```
