Prompt

Appointment booking API with round robin routing

Technology / Scheduling & Booking Software1 observationLast seen Oct 16, 2026

Latest observation

Oct 16, 2026OpenAI APIWeb search: off

Here’s a solid design for an appointment booking API with round-robin routing for assigning bookings to providers/agents/staff.


1) Core idea

When a new appointment request arrives, the system should:

  1. Validate the request
  2. Find the eligible providers/resources
  3. Select the next provider using round robin
  4. Create the appointment
  5. Return the assigned provider and booking details

2) Typical entities

Customer

  • id
  • name
  • email
  • phone

Provider

  • id
  • name
  • status (active, inactive)
  • service_types
  • timezone

Appointment

  • id
  • customer_id
  • provider_id
  • service_type
  • start_time
  • end_time
  • status (booked, cancelled, completed)
  • created_at

RoundRobinState

Tracks where the next assignment should go.

  • id
  • queue_key (e.g. "haircut:nyc", "support", "default")
  • last_assigned_provider_id
  • updated_at

3) Example API endpoints

Create booking

POST /appointments

Request

{
  "customer_id": "cust_123",
  "service_type": "consultation",
  "start_time": "2026-10-20T10:00:00Z",
  "duration_minutes": 30
}

Response

{
  "appointment_id": "apt_456",
  "customer_id": "cust_123",
  "provider_id": "prov_789",
  "service_type": "consultation",
  "start_time": "2026-10-20T10:00:00Z",
  "end_time": "2026-10-20T10:30:00Z",
  "status": "booked"
}

Get appointment

GET /appointments/{id}

Cancel appointment

POST /appointments/{id}/cancel

List available providers

GET /providers?service_type=consultation


4) Round robin selection logic

A simple version:

  1. Fetch all active eligible providers for the requested service
  2. Sort them consistently by id or created_at
  3. Find the provider after last_assigned_provider_id
  4. If at the end, wrap around to the first provider
  5. Save the new last_assigned_provider_id

Pseudocode

def select_next_provider(queue_key, eligible_providers):
    state = get_round_robin_state(queue_key)
    providers = sort_by_id(eligible_providers)

    if not providers:
        raise Exception("No providers available")

    if state is None or state.last_assigned_provider_id is None:
        chosen = providers[0]
    else:
        ids = [p.id for p in providers]
        if state.last_assigned_provider_id in ids:
            idx = ids.index(state.last_assigned_provider_id)
            chosen = providers[(idx + 1) % len(providers)]
        else:
            chosen = providers[0]

    update_round_robin_state(queue_key, chosen.id)
    return chosen

5) Important production considerations

A. Concurrency

Two bookings can arrive at the same time and select the same provider if state is not protected.

Fix:

  • Use a DB transaction
  • Lock the round robin state row (SELECT ... FOR UPDATE)
  • Or use Redis with atomic operations

B. Availability checks

Round robin should only choose providers who are actually free.

Check:

  • working hours
  • existing appointments
  • blackout periods
  • provider status

C. Fairness

If a provider is unavailable, skip them and continue round robin to the next eligible one.


D. Multi-tenant / queue-based routing

You may want separate round robin sequences for:

  • each service type
  • each location
  • each team
  • each tenant

Use a queue_key like:

  • tenant_1:consultation:nyc
  • support:level1

6) Example workflow

  1. Client calls POST /appointments
  2. API validates input
  3. System gets eligible providers for consultation
  4. Round robin state says last provider was prov_2
  5. Next eligible provider is prov_3
  6. Appointment is created for prov_3
  7. State is updated to prov_3

7) Suggested database approach

Table: providers

id | name | status | service_type

Table: appointments

id | customer_id | provider_id | service_type | start_time | end_time | status

Table: round_robin_state

queue_key | last_assigned_provider_id | updated_at

8) If you want a more scalable design

Use:

  • PostgreSQL for booking data
  • Redis for round robin counters/state
  • message queue for async notifications
  • distributed lock for safe assignment under load

9) Edge cases to handle

  • No eligible providers
  • Provider becomes unavailable after selection but before booking commit
  • Appointment conflicts
  • Cancelled bookings shouldn’t break sequence unexpectedly
  • Provider removed from rotation
  • Rebalancing when providers are added/removed

10) Minimal implementation pattern

Booking transaction

  1. Start transaction
  2. Lock round robin state
  3. Query eligible providers
  4. Pick next provider
  5. Verify provider availability again
  6. Insert appointment
  7. Update round robin state
  8. Commit

If you want, I can also provide one of these:

  1. OpenAPI spec
  2. SQL schema
  3. Node.js/Express implementation
  4. Python/FastAPI implementation
  5. System design diagram
  6. Redis-based round robin implementation

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.