Skip to main content
PUT
/
api
/
availabilities
/
{id}
Update Availability
curl --request PUT \
  --url https://harbor-parking.vercel.app/api/availabilities/{id} \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "<string>",
  "end_time": "<string>"
}'
{
  "availability": {
    "id": "789e0123-e89b-12d3-a456-426614174002",
    "spot_id": "123e4567-e89b-12d3-a456-426614174000",
    "start_time": "2024-01-16T08:00:00Z",
    "end_time": "2024-01-16T18:00:00Z",
    "is_claimed": false,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-16T11:45:00Z"
  }
}

Overview

This endpoint allows parking spot owners to update their availability windows.
You cannot update an availability that has already been claimed.

Authentication

Path Parameters

id
string
required
Unique identifier of the availability to update

Request Body

start_time
string
Updated availability start time (ISO 8601 format)
end_time
string
Updated availability end time (ISO 8601 format)

Response

availability
object
required
Updated availability object

Example Request

curl -X PUT "https://harbor-parking.vercel.app/api/availabilities/789e0123-e89b-12d3-a456-426614174002" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "start_time": "2024-01-16T08:00:00Z",
    "end_time": "2024-01-16T18:00:00Z"
  }'

Example Response

{
  "availability": {
    "id": "789e0123-e89b-12d3-a456-426614174002",
    "spot_id": "123e4567-e89b-12d3-a456-426614174000",
    "start_time": "2024-01-16T08:00:00Z",
    "end_time": "2024-01-16T18:00:00Z",
    "is_claimed": false,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-16T11:45:00Z"
  }
}

Error Responses

{
  "error": "Cannot update a claimed availability"
}