Skip to main content

Adoption holds and concurrency

Blüdhaven Pets coordinates companion animal adoptions across three physical retail branches and an online public portal. An in-store counselor and an online applicant can reach for the same animal at once. The API enforces atomic reservation locks to prevent that double-booking.

How 30-minute holds work​

When an applicant begins an interview or starts checkout online, your client application must request a temporary hold:

[Available Animal] ──► POST /adoptions/holds ──► [30-Minute Hold Granted]
│
▼ (Second concurrent request)
[HTTP 409 Conflict]
  1. State verification. The API confirms the animal stores status: "AVAILABLE" and reads true from health_record.spay_neuter_certified.
  2. Lock creation. The API writes an AdoptionHold record and sets the animal status to RESERVED_HOLD.
  3. Expiration TTL. The server assigns an immutable expiration timestamp exactly 1,800 seconds after creation.
  4. Resolution.
    • If the applicant completes paperwork and pays the adoption fees, staff submit an application and the hold moves to CONVERTED.
    • If 30 minutes lapse without completion, an automated background reaper marks the hold EXPIRED and returns the animal to AVAILABLE.

Placing a reservation hold​

Send a POST request to /adoptions/holds with the animal and applicant identifiers.

cURL
curl -X POST https://api.bludhavenpets.com/v1/adoptions/holds \
-H "Authorization: Bearer <STAFF_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"animal_id": "pet_krypto_210",
"applicant_id": "usr_9921bc",
"notes": "In-person consultation at the Downtown adoption floor"
}'

Successful response​

201 Created

Response
{
"id": "hld_77a28f",
"animal_id": "pet_krypto_210",
"applicant_id": "usr_9921bc",
"branch_id": "loc_harbor_04",
"status": "ACTIVE",
"created_at": "2026-11-17T07:45:00Z",
"expires_at": "2026-11-17T08:15:00Z",
"seconds_remaining": 1782
}

Handling 409 Conflict collisions​

When another staff member or online applicant claims an animal first, the endpoint returns an HTTP 409 Conflict using the RFC 9457 ProblemDetails standard.

409 Conflict Response
{
"type": "https://api.bludhavenpets.com/errors/adoption-hold-conflict",
"title": "Adoption Hold Conflict",
"status": 409,
"detail": "Animal pet_krypto_210 is currently reserved under active hold hld_77a28f expiring at 2026-11-17T08:15:00Z.",
"instance": "/adoptions/holds"
}

Releasing a hold early​

A counselor releases the lock the moment an interview fails or the applicant walks out. Otherwise the animal sits invisible to other adopters for the rest of the half hour.

cURL
curl -X DELETE https://api.bludhavenpets.com/v1/adoptions/holds/hld_77a28f \
-H "Authorization: Bearer <STAFF_TOKEN>"

204 No Content confirms the release, and the animal returns to AVAILABLE immediately. A hold that already converted into an application returns 409, because a release can't undo a submitted application.

  1. Parse the detail message or inspect the target animal profile.
  2. Check expires_at on the active hold.
  3. If the customer wants to wait, prompt them to join a notification queue that alerts them if the active hold expires without conversion.
  4. Offer alternative companion animals matching the same species and temperament profile.