Skip to main content
Complete reference for all methods available in the buena/sdk package.

Installation & Setup

Core API Methods

All API methods are accessed through the DefaultApi instance.

Lead Management Functions

listLeads($limit, $offset, $sort, $order, $search, $company, $status)

  • Purpose: List all leads with optional filtering and pagination
  • Parameters:
    • $limit (int, optional): Number of leads (default: 50, max: 100)
    • $offset (int, optional): Pagination offset (default: 0)
    • $sort (string, optional): Sort field (created_at, updated_at, first_name, last_name)
    • $order (string, optional): Sort order (asc, desc, default: desc)
    • $search (string, optional): Search term for name/email
    • $company (string, optional): Filter by company name
    • $status (string, optional): Filter by status (active, inactive, contacted)
  • Returns: Array of Lead objects with pagination info
  • Throws: ApiException on error

createLead($createLeadRequest)

  • Purpose: Create a new lead in database
  • Parameters:
    • $createLeadRequest (CreateLeadRequest): Lead data object
      • first_name (string, required): Lead’s first name
      • last_name (string, required): Lead’s last name
      • email (string, required): Valid email address
      • company (string, optional): Company name
      • phone (string, optional): Phone number
      • linkedin_url (string, optional): LinkedIn profile URL
      • job_title (string, optional): Job title
      • location (string, optional): Location/city
      • notes (string, optional): Additional notes
      • tags (array, optional): Array of tags
      • custom_fields (array, optional): Custom field data
  • Returns: Lead object with generated ID and timestamps
  • Throws: ApiException on validation error, duplicate email

getLead($leadId)

  • Purpose: Retrieve specific lead by ID
  • Parameters:
    • $leadId (string, required): Unique lead identifier
  • Returns: Lead object
  • Throws: ApiException if lead not found

updateLead($leadId, $updateLeadRequest)

  • Purpose: Update existing lead information
  • Parameters:
    • $leadId (string, required): Unique lead identifier
    • $updateLeadRequest (UpdateLeadRequest): Update data object
      • All fields optional, same as CreateLeadRequest
      • status (string, optional): Update status (active, inactive, contacted)
  • Returns: Updated Lead object
  • Throws: ApiException on validation error, lead not found

deleteLead($leadId)

  • Purpose: Permanently delete lead from database
  • Parameters:
    • $leadId (string, required): Unique lead identifier
  • Returns: Success confirmation array
  • Throws: ApiException if lead not found

API Key Management Functions

listApiKeys()

  • Purpose: List all API keys for account
  • Parameters: None
  • Returns: Array of ApiKey objects
  • Throws: ApiException on insufficient permissions

createApiKey($createApiKeyRequest)

  • Purpose: Create new API key for account
  • Parameters:
    • $createApiKeyRequest (CreateApiKeyRequest): API key data
      • name (string, required): Descriptive name for key
      • permissions (array, required): Array of permission strings
      • expires_at (DateTime, optional): Expiration date
      • description (string, optional): Key description
  • Returns: ApiKey object with full key (only returned on creation)
  • Throws: ApiException on validation error

System Health Functions

healthCheck()

  • Purpose: Check API system status and connection
  • Parameters: None
  • Returns: HealthCheck200Response with system status
  • Throws: ApiException on server error

Data Models

Lead Object

ApiKey Object

Available Permissions

Error Handling

All methods throw ApiException with these properties:
  • getCode() - HTTP status code
  • getMessage() - Error message
  • getResponseBody() - Raw response body
  • getResponseHeaders() - Response headers

Common Error Codes

  • 400 - Bad Request (validation errors)
  • 401 - Unauthorized (invalid API key)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Not Found (resource doesn’t exist)
  • 409 - Conflict (duplicate email)
  • 422 - Unprocessable Entity (validation error)
  • 429 - Too Many Requests (rate limited)
  • 500 - Internal Server Error
  • 503 - Service Unavailable

Usage Examples

Basic Lead Operations

Error Handling Pattern

Pagination Helper