GET
/
agents
/
availability
{
  "code": "missing_parameters",
  "message": "Required parameters: location_id, service_id, date, start_time",
  "data": {
    "status": 400
  }
}
This endpoint allows you to get a list of agents with flexible filtering options. You can filter by location, service, and optionally check their availability for a specific date and time. All parameters are optional, making it very flexible for different use cases.

Parameters

location_id
integer
Filter agents by location ID. If provided, only agents working at this location will be returned
service_id
integer
Filter agents by service ID. If provided, only agents who can provide this service will be returned
date
string
Date to check availability for in Y-m-d format (e.g., “2024-01-15”). Only used if start_time is also provided
start_time
string
Start time to check availability for. Can be in HH:MM format (e.g., “14:30”) or minutes since midnight (e.g., “870”). Only used if date is also provided
duration
integer
Duration of the appointment in minutes. If not provided and service_id is given, uses the service’s default duration. Otherwise defaults to 60 minutes
limit
integer
default:"50"
Maximum number of agents to return. Useful for pagination

Response

success
boolean
Indicates if the request was successful
data
object
The main response data containing agents information

Example Requests

1. Get all agents (no filters)

curl -X GET "https://yourdomain.com/wp-json/latepoint-api/v1/agents/availability" \
  -H "Authorization: Bearer lp_your_api_key_here"

2. Get agents by location only

curl -X GET "https://yourdomain.com/wp-json/latepoint-api/v1/agents/availability?location_id=1" \
  -H "Authorization: Bearer lp_your_api_key_here"

3. Get agents by location and service

curl -X GET "https://yourdomain.com/wp-json/latepoint-api/v1/agents/availability?location_id=1&service_id=2" \
  -H "Authorization: Bearer lp_your_api_key_here"

4. Check availability for specific date and time

curl -X GET "https://yourdomain.com/wp-json/latepoint-api/v1/agents/availability?location_id=1&service_id=2&date=2024-01-15&start_time=14:30&duration=60&limit=3" \
  -H "Authorization: Bearer lp_your_api_key_here"

Example Response

{
  "success": true,
  "data": {
    "filters": {
      "location_id": 1,
      "service_id": 2,
      "date": "2024-01-15",
      "start_time": "14:30",
      "duration": 60
    },
    "total_agents": 3,
    "available_agents_count": 2,
    "agents": [
      {
        "id": 3,
        "first_name": "John",
        "last_name": "Smith",
        "display_name": "Dr. John Smith",
        "email": "john.smith@example.com",
        "phone": "+1234567890",
        "status": "active",
        "services": [
          {
            "id": 2,
            "name": "Consultation",
            "duration": 60
          }
        ],
        "locations": [
          {
            "id": 1,
            "name": "Main Office",
            "address": "123 Main St, City, State"
          }
        ],
        "is_available": true
      },
      {
        "id": 7,
        "first_name": "Sarah",
        "last_name": "Johnson",
        "display_name": "Dr. Sarah Johnson",
        "email": "sarah.johnson@example.com",
        "phone": "+1234567891",
        "status": "active",
        "services": [
          {
            "id": 2,
            "name": "Consultation",
            "duration": 60
          }
        ],
        "locations": [
          {
            "id": 1,
            "name": "Main Office",
            "address": "123 Main St, City, State"
          }
        ],
        "is_available": true
      },
      {
        "id": 9,
        "first_name": "Mike",
        "last_name": "Wilson",
        "display_name": "Dr. Mike Wilson",
        "email": "mike.wilson@example.com",
        "phone": "+1234567892",
        "status": "active",
        "services": [
          {
            "id": 2,
            "name": "Consultation",
            "duration": 60
          }
        ],
        "locations": [
          {
            "id": 1,
            "name": "Main Office",
            "address": "123 Main St, City, State"
          }
        ],
        "is_available": false
      }
    ],
    "available_agents": [
      {
        "id": 3,
        "first_name": "John",
        "last_name": "Smith",
        "display_name": "Dr. John Smith",
        "email": "john.smith@example.com",
        "phone": "+1234567890",
        "status": "active",
        "services": [...],
        "locations": [...],
        "is_available": true
      },
      {
        "id": 7,
        "first_name": "Sarah",
        "last_name": "Johnson",
        "display_name": "Dr. Sarah Johnson",
        "email": "sarah.johnson@example.com",
        "phone": "+1234567891",
        "status": "active",
        "services": [...],
        "locations": [...],
        "is_available": true
      }
    ]
  }
},
      {
        "id": 5,
        "first_name": "Mike",
        "last_name": "Johnson",
        "display_name": "Dr. Mike Johnson",
        "email": "mike.johnson@example.com",
        "status": "active"
      }
    ]
  }
}

Use Cases

  • Find Multiple Available Agents: When you need to show customers multiple agent options for the same time slot
  • Count Available Agents: Check how many agents are available without needing their full details
  • Load Balancing: Distribute bookings across available agents
  • Capacity Planning: Understand availability patterns for better scheduling
  • Group Bookings: Find multiple agents for simultaneous appointments

Error Responses

{
  "code": "missing_parameters",
  "message": "Required parameters: location_id, service_id, date, start_time",
  "data": {
    "status": 400
  }
}
{
  "code": "invalid_date",
  "message": "Date must be in Y-m-d format",
  "data": {
    "status": 400
  }
}
{
  "code": "invalid_time",
  "message": "Start time must be in HH:MM format or minutes",
  "data": {
    "status": 400
  }
}
{
  "code": "service_not_found",
  "message": "Service not found",
  "data": {
    "status": 404
  }
}

Notes

  • The endpoint checks for both existing bookings and agent working hours
  • Only active agents are considered for availability
  • The limit parameter is useful for performance when you only need a specific number of agents
  • Time can be provided in either HH:MM format or as minutes since midnight
  • If duration is not provided, the service’s default duration is used
  • The endpoint considers both approved and pending bookings as conflicts