> ## Documentation Index
> Fetch the complete documentation index at: https://lapscher.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Claim

> Update claim status or details

## Overview

This endpoint allows users to update their claim details, primarily the status.

## Authentication

<Snippet file="auth-required.mdx" />

## Path Parameters

<ParamField path="id" type="string" required>
  Unique identifier of the claim to update
</ParamField>

## Request Body

<ParamField body="status" type="string" optional>
  Updated claim status (active, completed, cancelled)
</ParamField>

<ParamField body="start_time" type="string" optional>
  Updated claim start time (ISO 8601 format)
</ParamField>

<ParamField body="end_time" type="string" optional>
  Updated claim end time (ISO 8601 format)
</ParamField>

## Response

<ResponseField name="claim" type="object" required>
  Updated claim object

  <Expandable title="Claim Object">
    <ResponseField name="id" type="string" required>
      Unique claim identifier (UUID)
    </ResponseField>

    <ResponseField name="availability_id" type="string" required>
      ID of the claimed availability
    </ResponseField>

    <ResponseField name="claimer_id" type="string" required>
      ID of the user who made the claim
    </ResponseField>

    <ResponseField name="start_time" type="string" required>
      Claim start time (ISO 8601)
    </ResponseField>

    <ResponseField name="end_time" type="string" required>
      Claim end time (ISO 8601)
    </ResponseField>

    <ResponseField name="status" type="string" required>
      Claim status (active, completed, cancelled)
    </ResponseField>

    <ResponseField name="created_at" type="string" required>
      Claim creation timestamp (ISO 8601)
    </ResponseField>

    <ResponseField name="updated_at" type="string" required>
      Claim last update timestamp (ISO 8601)
    </ResponseField>
  </Expandable>
</ResponseField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://harbor-parking.vercel.app/api/claims/abc123de-e89b-12d3-a456-426614174003" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "status": "completed"
    }'
  ```

  ```javascript JavaScript theme={null}
  const claimId = "abc123de-e89b-12d3-a456-426614174003";
  const response = await fetch(`https://harbor-parking.vercel.app/api/claims/${claimId}`, {
    method: 'PUT',
    headers: {
      'Authorization': `Bearer ${yourJwtToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      status: "completed"
    })
  });

  const result = await response.json();
  ```
</CodeGroup>

## Example Response

<ResponseExample>
  ```json Success Response theme={null}
  {
    "claim": {
      "id": "abc123de-e89b-12d3-a456-426614174003",
      "availability_id": "789e0123-e89b-12d3-a456-426614174002",
      "claimer_id": "456e7890-e89b-12d3-a456-426614174001",
      "start_time": "2024-01-16T09:00:00Z",
      "end_time": "2024-01-16T17:00:00Z",
      "status": "completed",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-16T18:00:00Z"
    }
  }
  ```
</ResponseExample>

## Status Transitions

* **active → completed**: Mark the parking session as finished
* **active → cancelled**: Cancel the claim (frees up the availability)
* **completed/cancelled**: No further changes allowed

## Error Responses

<ResponseExample>
  ```json 400 Bad Request - Invalid Status theme={null}
  {
    "error": "Cannot change status from completed/cancelled"
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "error": "You can only update your own claims"
  }
  ```
</ResponseExample>
