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

# Answer a space request

Approves or declines a trainer's request to book one of the business's spaces. It charges nothing; a decline returns the trainer's payment by the site's own rules.

- `POST https://api.dev.repp.co.il/v1/bookings/{id}/decision`
- Needs a key: `Authorization: Bearer repp_…`.
- **Changes something · needs a read-and-actions key** (or an app signed in with `repp.write`). Send an `Idempotency-Key`: a repeat gets the first answer. Never moves money. See [Actions](https://docs.dev.repp.co.il/actions.md).

This is the one action that moves money: a decline refunds the trainer exactly as declining it on the site does. `action_refused` with `booking_not_available` when the request is no longer waiting (answered, ran out after 24 hours, or its hour came).

Needs a key made as **read and actions** on the site; a read-only key gets `403 read_only_key`. An AI app's sign-in acts through the MCP server only, never here. Send an `Idempotency-Key` header: the same key sent again does nothing and answers the first result.

## Path parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `id` **(required)** | uuid | — | The booking's id. |

## Request body

A JSON object, sent with `Content-Type: application/json`.

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `approve` **(required)** | boolean | — | `true` to approve, `false` to decline. |

## Request

**cURL**

```bash
IDEMPOTENCY_KEY=$(uuidgen)  # send the same one again to retry this action
curl -X POST "https://api.dev.repp.co.il/v1/bookings/c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f/decision" \
  -H "Authorization: Bearer $REPP_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{
  "approve": true
}'
```

**JavaScript**

```js
// One key per action: send the same one again to retry it, and it is done once.
const idempotencyKey = crypto.randomUUID();
const response = await fetch("https://api.dev.repp.co.il/v1/bookings/c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f/decision", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.REPP_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": idempotencyKey,
  },
  body: JSON.stringify({
    "approve": true
  }),
});
if (!response.ok) throw new Error((await response.json()).error.message);
const data = await response.json();
```

**TypeScript**

```ts
/** Your answer to a space request. */
interface BookingDecision {
  booking_id: string;
  status: "confirmed" | "declined";
}

interface ApiError {
  error: { code: string; message: string; reason?: string };
}

// One key per action: send the same one again to retry it, and it is done once.
const idempotencyKey = crypto.randomUUID();
const response = await fetch("https://api.dev.repp.co.il/v1/bookings/c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f/decision", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.REPP_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": idempotencyKey,
  },
  body: JSON.stringify({
    "approve": true
  }),
});
if (!response.ok) throw new Error(((await response.json()) as ApiError).error.message);
const data = (await response.json()) as BookingDecision;
```

**Python**

```python
import os
import uuid

import requests

# One key per action: send the same one again to retry it, and it is done once.
idempotency_key = str(uuid.uuid4())

response = requests.post(
    "https://api.dev.repp.co.il/v1/bookings/c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f/decision",
    headers={
        "Authorization": f"Bearer {os.environ['REPP_API_KEY']}",
        "Idempotency-Key": idempotency_key,
    },
    json={
        "approve": True,
    },
    timeout=30,
)
if not response.ok:
    raise RuntimeError(response.json()["error"]["message"])
data = response.json()
```

**PHP**

```php
<?php
// One key per action: send the same one again to retry it, and it is done once.
$idempotencyKey = bin2hex(random_bytes(16));

$ch = curl_init("https://api.dev.repp.co.il/v1/bookings/c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f/decision");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("REPP_API_KEY"),
        "Content-Type: application/json",
        "Idempotency-Key: " . $idempotencyKey,
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "approve" => true,
    ]),
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
    throw new RuntimeException($data["error"]["message"]);
}
```

## Response (200)

```json
{
  "booking_id": "c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f",
  "status": "confirmed"
}
```

## Response fields

| Field | Type | Description |
| --- | --- | --- |
| `booking_id` | string | Identifier. |
| `status` | one of: confirmed, declined | confirmed: you approved it. declined: you declined it, and the trainer's money went back by the site's rules. |

## Errors

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `bad_body` | The request body is not a JSON object (or a field in it is missing or malformed). The message names it. |
| 401 | `missing_key` | The endpoint needs a key and no Authorization header came. |
| 401 | `bad_key` | The key is not one of ours, was revoked, or its account was closed or blocked. |
| 403 | `read_only_key` | The key only reads. Actions need a key made with "read and actions" (or an app signed in with the scope repp.write). |
| 403 | `not_a_business` | The endpoint is for businesses and the key's account has none. |
| 404 | `not_found` | No such endpoint, or no such item for this caller. |
| 409 | `idempotency_conflict` | The Idempotency-Key was already used by this key for a different action. |
| 409 | `action_refused` | The site's own rules refused the action; `reason` says which (for example class_not_available, already_offered, booking_not_available). |
| 429 | `too_many_actions` | The key ran 200 actions in the last 24 hours. Reads still work. |
| 429 | `too_many_requests` | Over the rate limit. Wait the seconds in `Retry-After` (60) and go on. |
| 500 | `server_error` | Something failed on our side. Try again shortly. |
