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

Overview

This endpoint allows parking spot owners to create availability windows for their spots.

Authentication

Request Body

spot_id
string
required
ID of the parking spot to make available
start_time
string
required
Availability start time (ISO 8601 format)
end_time
string
required
Availability end time (ISO 8601 format)

Response

availability
object
required
Created availability object

Example Request

curl -X POST "https://harbor-parking.vercel.app/api/availabilities" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "spot_id": "123e4567-e89b-12d3-a456-426614174000",
    "start_time": "2024-01-16T09:00:00Z",
    "end_time": "2024-01-16T17:00:00Z"
  }'

Example Response

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

Validation Rules

  • start_time must be in the future
  • end_time must be after start_time
  • You can only create availabilities for spots you own
  • Availability windows cannot overlap with existing ones for the same spot