Rezervace
Sprava rezervaci - vytvareni, cteni, aktualizace a ruseni.
GET /:slug/reservations
Ziskani seznamu rezervaci. Vyzaduje opravneni Cteni.
Pozadavek
curl -X GET \
-H "X-API-Key: vas_api_klic" \
"https://api.zarezervujto.cz/api/v1/vas-projekt/reservations?date=2024-12-15"
Query parametry
| Parametr | Typ | Popis |
|---|---|---|
date | string | Filtr podle data (YYYY-MM-DD) |
from | string | Od data (YYYY-MM-DD) |
to | string | Do data (YYYY-MM-DD) |
status | string | Filtr podle statusu |
branchId | string | Filtr podle pobocky |
limit | number | Max pocet vysledku (vychozi 50, max 100) |
offset | number | Pocet preskocit (pro strankovani) |
Statusy rezervaci
| Status | Popis |
|---|---|
PENDING | Cekajici na potvrzeni |
CONFIRMED | Potvrzena |
CANCELLED | Zrusena |
COMPLETED | Dokoncena |
NO_SHOW | Zakaznik se nedostavil |
Odpoved
{
"success": true,
"count": 2,
"total": 15,
"reservations": [
{
"id": "res-123",
"date": "2024-12-15",
"from": "10:00",
"to": "11:00",
"status": "CONFIRMED",
"guests": 2,
"note": "Prosim stolek u okna",
"customer": {
"id": "cust-1",
"firstName": "Jan",
"lastName": "Novak",
"email": "jan@example.com",
"phone": "+420 123 456 789"
},
"services": [
{
"id": "service-1",
"name": "Strihani vlasu",
"duration": 30,
"price": 350
}
],
"table": {
"id": "table-1",
"name": "Stolek 1",
"capacity": 4
},
"createdAt": "2024-12-10T14:30:00Z"
}
]
}
GET /:slug/reservations/:id
Ziskani detailu rezervace. Vyzaduje opravneni Cteni.
Pozadavek
curl -X GET \
-H "X-API-Key: vas_api_klic" \
https://api.zarezervujto.cz/api/v1/vas-projekt/reservations/res-123
Odpoved
{
"success": true,
"reservation": {
"id": "res-123",
"date": "2024-12-15",
"from": "10:00",
"to": "11:00",
"status": "CONFIRMED",
"guests": 2,
"note": "Prosim stolek u okna",
"customer": {
"id": "cust-1",
"firstName": "Jan",
"lastName": "Novak",
"email": "jan@example.com",
"phone": "+420 123 456 789"
},
"services": [...],
"table": {...},
"statusHistory": [
{
"status": "PENDING",
"changedBy": "system",
"action": "created",
"changedAt": "2024-12-10T14:30:00Z"
},
{
"status": "CONFIRMED",
"changedBy": "admin@example.com",
"action": "confirmed",
"changedAt": "2024-12-10T15:00:00Z"
}
],
"createdAt": "2024-12-10T14:30:00Z"
}
}
POST /:slug/reservations
Vytvoreni nove rezervace. Vyzaduje opravneni Zapis.
Pozadavek
curl -X POST \
-H "X-API-Key: vas_api_klic" \
-H "Content-Type: application/json" \
-d '{
"email": "jan@example.com",
"firstName": "Jan",
"lastName": "Novak",
"phone": "+420123456789",
"date": "2024-12-15",
"from": "10:00",
"to": "11:00",
"guests": 2,
"branchId": "branch-1",
"tableId": "table-1",
"serviceIds": ["service-1"],
"note": "Prosim stolek u okna"
}' \
https://api.zarezervujto.cz/api/v1/vas-projekt/reservations
Body parametry
| Parametr | Typ | Povinny | Popis |
|---|---|---|---|
email | string | Ano | Email zakaznika |
firstName | string | Ne | Jmeno |
lastName | string | Ne | Prijmeni |
phone | string | Ne* | Telefon (*muze byt povinny dle nastaveni) |
date | string | Ano | Datum (YYYY-MM-DD) |
from | string | Ano | Cas zacatku (HH:MM) |
to | string | Ano | Cas konce (HH:MM) |
guests | number | Ne | Pocet hostu |
branchId | string | Ne | ID pobocky |
tableId | string | Ne | ID stolu |
serviceIds | array | Ne | Pole ID sluzeb |
note | string | Ne | Poznamka |
Uspesna odpoved (201)
{
"success": true,
"message": "Reservation created successfully",
"reservation": {
"id": "res-456",
"status": "PENDING",
"date": "2024-12-15",
"from": "10:00",
"to": "11:00"
}
}
Chybove odpovedi
400 Bad Request - Chybejici pole
{
"error": "Bad Request",
"message": "Required fields: email, date, from, to"
}
403 Forbidden - Zakaznik na blacklistu
{
"error": "Forbidden",
"message": "Customer is blacklisted",
"code": "CUSTOMER_BLACKLISTED"
}
409 Conflict - Kolize terminu
{
"error": "Conflict",
"message": "Table is already reserved for this time slot",
"code": "DOUBLE_BOOKING"
}
PATCH /:slug/reservations/:id/status
Zmena statusu rezervace. Vyzaduje opravneni Zapis.
Pozadavek
curl -X PATCH \
-H "X-API-Key: vas_api_klic" \
-H "Content-Type: application/json" \
-d '{
"status": "CONFIRMED",
"note": "Potvrzeno telefonicky"
}' \
https://api.zarezervujto.cz/api/v1/vas-projekt/reservations/res-123/status
Body parametry
| Parametr | Typ | Povinny | Popis |
|---|---|---|---|
status | string | Ano | Novy status |
note | string | Ne | Poznamka ke zmene |
reason | string | Ne | Duvod (pro CANCELLED) |
Povolene prechody statusu
| Z | Na |
|---|---|
| PENDING | CONFIRMED, CANCELLED |
| CONFIRMED | COMPLETED, CANCELLED, NO_SHOW |
| COMPLETED | - |
| CANCELLED | - |
| NO_SHOW | - |
Odpoved
{
"success": true,
"message": "Reservation status updated",
"reservation": {
"id": "res-123",
"status": "CONFIRMED"
}
}
DELETE /:slug/reservations/:id
Zruseni rezervace. Vyzaduje opravneni Mazani.
Pozadavek
curl -X DELETE \
-H "X-API-Key: vas_api_klic" \
-H "Content-Type: application/json" \
-d '{"reason": "Zakaznik zrusil"}' \
https://api.zarezervujto.cz/api/v1/vas-projekt/reservations/res-123
Body parametry
| Parametr | Typ | Povinny | Popis |
|---|---|---|---|
reason | string | Ne | Duvod zruseni |
Odpoved
{
"success": true,
"message": "Reservation cancelled"
}
Priklad: Kompletni workflow
const API_KEY = 'zrt_live_...';
const BASE_URL = 'https://api.zarezervujto.cz/api/v1/vas-projekt';
// 1. Zjistit dostupnost
const availability = await fetch(
`${BASE_URL}/availability?date=2024-12-15`,
{ headers: { 'X-API-Key': API_KEY } }
).then(r => r.json());
// 2. Vybrat volny slot
const freeSlot = availability.slots.find(s => s.available);
// 3. Vytvorit rezervaci
const reservation = await fetch(`${BASE_URL}/reservations`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'zakaznik@example.com',
firstName: 'Jan',
lastName: 'Novak',
date: '2024-12-15',
from: freeSlot.from,
to: freeSlot.to,
guests: 2
})
}).then(r => r.json());
console.log(`Vytvorena rezervace: ${reservation.reservation.id}`);
// 4. Potvrdit rezervaci
await fetch(`${BASE_URL}/reservations/${reservation.reservation.id}/status`, {
method: 'PATCH',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ status: 'CONFIRMED' })
});