POST /api/admin-reservations-status
POST /api/admin-reservations-status
Update the status and/or notes of a reservation.
Request
Method
POST
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {ADMIN_API_TOKEN} |
| Content-Type | application/json |
Body
{
"id": "res_1706889600000-a1b2c3",
"productSlug": "oxi-one-mk2",
"status": "confirmed",
"notes": "電話連絡済み 2/5"
}
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Reservation ID to update |
productSlug | string | Yes | Product slug (used for blob key lookup) |
status | string | Yes | New status: pending, confirmed, fulfilled, cancelled |
notes | string | No | Admin notes (optional, preserves existing if omitted) |
Response
Success (200)
{
"success": true,
"reservation": {
"id": "res_1706889600000-a1b2c3",
"name": "山田太郎",
"email": "yamada@example.com",
"productSlug": "oxi-one-mk2",
"status": "confirmed",
"notes": "電話連絡済み 2/5",
"createdAt": "2024-02-02T10:00:00.000Z"
}
}
Status Workflow
graph LR
P[pending] --> C[confirmed]
P --> X[cancelled]
C --> F[fulfilled]
C --> X
C --> P
F --> C
X --> P
| From | Valid Transitions |
|---|---|
pending | confirmed, cancelled |
confirmed | fulfilled, cancelled, pending |
fulfilled | confirmed |
cancelled | pending |
Not Found (404)
{
"success": false,
"error": "Reservation not found"
}
Validation Error (400)
{
"success": false,
"error": "Missing required fields: id, productSlug, status"
}
Unauthorized (401)
{
"success": false,
"error": "Unauthorized"
}
Example
cURL
# Confirm a reservation
curl -X POST https://takazudomodular.com/api/admin-reservations-status \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "res_1706889600000-a1b2c3",
"productSlug": "oxi-one-mk2",
"status": "confirmed"
}'
# Update status with notes
curl -X POST https://takazudomodular.com/api/admin-reservations-status \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "res_1706889600000-a1b2c3",
"productSlug": "oxi-one-mk2",
"status": "fulfilled",
"notes": "発送完了 追跡番号: 1234567890"
}'
JavaScript (fetch)
const response = await fetch('/api/admin-reservations-status', {
method: 'POST',
headers: {
'Authorization': `Bearer ${ADMIN_API_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: 'res_1706889600000-a1b2c3',
productSlug: 'oxi-one-mk2',
status: 'confirmed',
notes: '電話連絡済み',
}),
});
const data = await response.json();
if (data.success) {
console.log('Updated reservation:', data.reservation);
}
Implementation Details
Source File
netlify/functions/admin-reservations-status.ts
Behavior
- Validates Bearer token authentication
- Validates required fields (id, productSlug, status)
- Fetches existing reservation from Netlify Blobs
- Updates status field
- Updates notes field if provided
- Saves updated reservation
- Returns the updated reservation object
Storage Key
Reservations are stored with the key format: reservations/{productSlug}/{id}
Notes Handling
- If
notesis provided in the request, it replaces the existing notes - If
notesis omitted, the existing notes are preserved - To clear notes, pass an empty string:
"notes": ""
Related
- POST /api/admin-reservations-list - List reservations
- POST /api/reservation - Public reservation endpoint