Plans

A Plan is a comprehensive billing aggregator that brings together multiple components of the insurance premium collection process


A Plan is a comprehensive billing aggregator that brings together multiple components of the insurance premium collection process. Rather than being an invoice itself, a Plan contains and orchestrates:

  • Invoice: The billing document sent to the insured with premium details
  • Payment Link: A secure checkout URL for collecting payment
  • Flow-of-Funds: The routing configuration determining how collected funds are distributed between the agency, carrier, and producer
  • Policies: One or more insurance policies being billed
  • Payment Tracking: Status and history of payments received against the plan

This aggregated structure allows you to manage the entire billing lifecycle through a single resource, from invoice generation through payment collection and fund distribution.

Pre-Requirements for Plan Creation

Before you can create Plans, your tenant environment must have the following components configured:

Required Account Setup:

Account TypePurposeRequirement
Operational AccountYour agency's primary business operating account for receiving agency fees and operational fundsExactly one per tenant
Transitory AccountTemporary holding account used for fund transfers between accountsExactly one per tenant
Fiduciary AccountTrust account(s) for holding client premium funds before disbursement to carriersAt least one, linked to a carrier

Required Entity Setup:

EntityPurposeRequirement
CarrierInsurance company that will receive premium paymentsAt least one carrier with an associated fiduciary account
Producer (optional)Agent/broker who earns commission on the policyRequired only if tracking commissions

Why These Are Required:

The flow-of-funds engine requires these accounts to properly route collected payments. When an insured pays a premium:

  1. Funds are collected via the payment gateway
  2. Premium amounts are routed to the carrier's fiduciary account
  3. Agency fees are routed to the operational account
  4. Producer commissions are calculated and tracked for payout
  5. The transitory account facilitates transfers between accounts when needed

Verification:

Before creating your first Plan, verify your setup by calling:

  • GET /v1/carriers - Confirm at least one carrier exists
  • GET /v1/accounts - Confirm your accounts are configured

If these prerequisites are not met, Plan creation will fail with a validation error indicating the missing configuration.

Plan Statuses

StatusDescription
draftPlan created but not finalized; no payment link generated
openActive plan with payment link; awaiting payment
partially_paidSome payments received but balance remains
paidFully paid
overduePayment due date has passed
deletedSoft deleted

Create a Plan

Creates a new plan with its associated invoice, payment link, and fund flow configuration.

Endpoint: POST /v1/plans

Use Cases:

  • Create a billing plan for a new insurance policy with automatic invoice generation
  • Generate a payment link for premium collection
  • Configure flow-of-funds for agency billing vs direct billing
  • Set up automated payment reminders

Request Body:

FieldTypeRequiredDescription
insured_idstringNoID of existing insured; if not provided, use recipient fields
recipient_namestringNoName of the invoice recipient
recipient_emailstringNoEmail for sending invoice
recipient_phone_numberstringNoPhone number (max 20 chars)
sender_namestringNoName of the sender on the invoice
sender_emailstringNoEmail of the sender on the invoice
policiesarrayNoList of policies to include (see Policy Object below)
billing_typestringNodirect or agency (default: direct)
payment_duedatetimeNoPayment due date
statusstringNodraft or open (default: open)
invoice_numberstringNoCustom invoice number
invoice_headerstringNoCustom header text (default: "Invoice")
invoice_memostringNoNotes to display on invoice
agency_feesarrayNoAdditional agency fees (objects with name and amount)
allowed_payment_methodsarrayNoAccepted methods: ach, check, checkout_ach, checkout_credit_card
reminder_daysarrayNoDays relative to due date for reminders (max 4 reminders)
producer_idstringNoAssociated producer for commission
use_agency_brandingbooleanNoUse agency branding on invoice (default: false)

Policy Object:

FieldTypeRequiredDescription
policy_namestringYesName/description of the policy
policy_numberstringYesPolicy number
carrier_idstringYesInsurance carrier ID
effective_datedatetimeNoPolicy effective date
expiration_datedatetimeNoPolicy expiration date
product_line_namestringNoCarrier product line name
premiumobjectNoPremium amount (name and amount fields)
taxesobjectNoTax amount (name and amount fields)
feesobjectNoFee amount (name and amount fields)
additional_policy_itemsarrayNoAdditional line items (each with name and amount)
commission_percentagenumber/stringNoCarrier commission percentage
producer_commission_percentagenumber/stringNoProducer commission percentage
producer_commission_amountnumber/stringNoProducer commission amount (takes precedence over percentage)
statusstringNoPolicy status (default: open)

Example Request - Basic Plan:

curl -X POST "https://api.advancehq.com/v1/plans" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "recipient_name": "Acme Corporation",
    "recipient_email": "[email protected]",
    "payment_due": "2025-02-15T00:00:00Z",
    "status": "open",
    "policies": [
      {
        "policy_name": "General Liability",
        "policy_number": "POL-2025-001",
        "carrier_id": "car_abc123",
        "effective_date": "2025-01-01T00:00:00Z",
        "expiration_date": "2026-01-01T00:00:00Z",
        "premium": {
          "name": "Premium",
          "amount": "5000.00"
        },
        "taxes": {
          "name": "State Tax",
          "amount": "250.00"
        }
      }
    ]
  }'

Example Request - Plan with Existing Insured and Producer:

curl -X POST "https://api.advancehq.com/v1/plans" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "insured_id": "ins_abc123",
    "producer_id": "prod_xyz789",
    "billing_type": "agency",
    "payment_due": "2025-03-01T00:00:00Z",
    "status": "open",
    "invoice_memo": "Thank you for your business!",
    "reminder_days": [-7, -3, 1, 7],
    "allowed_payment_methods": ["checkout_ach", "checkout_credit_card"],
    "policies": [
      {
        "policy_name": "Workers Compensation",
        "policy_number": "WC-2025-100",
        "carrier_id": "car_def456",
        "effective_date": "2025-01-15T00:00:00Z",
        "expiration_date": "2026-01-15T00:00:00Z",
        "premium": {
          "name": "Premium",
          "amount": "12500.00"
        },
        "producer_commission_percentage": "10"
      }
    ],
    "agency_fees": [
      {
        "name": "Processing Fee",
        "amount": "75.00"
      }
    ]
  }'

Response:

{
  "plan_id": "plan_abc123def456",
  "plan_number": "INV-2025-0001",
  "message": "Plan created successfully",
  "payment_url": "https://app.advancehq.com/checkout/abc123",
  "invoice_pdf_url": "https://storage.advancehq.com/invoices/plan_abc123.pdf"
}

List All Plans

Retrieves all plans for your tenant with optional filtering and pagination.

Endpoint: GET /v1/plans

Query Parameters:

ParameterTypeDefaultDescription
paginationbooleanfalseEnable paginated response
pageinteger1Page number (1-based)
page_sizeinteger100Items per page (max 10000)
statusstringopenFilter by status

Use Cases:

  • Sync invoices with your agency management system
  • Generate reports on outstanding balances
  • Monitor payment collection progress

Example - Get All Open Plans:

curl -X GET "https://api.advancehq.com/v1/plans?status=open" \
  -H "Authorization: Bearer your_api_key"

Example - Paginated Request:

curl -X GET "https://api.advancehq.com/v1/plans?pagination=true&page=1&page_size=50&status=partially_paid" \
  -H "Authorization: Bearer your_api_key"

Response (Non-Paginated):

[
  {
    "plan_id": "plan_abc123",
    "plan_number": "INV-2025-0001",
    "insured_id": "ins_xyz789",
    "insured_name": "Acme Corporation",
    "status": "open",
    "total_invoiced_amount": "5250.00",
    "collected_amount": "0.00",
    "payment_due": "2025-02-15T00:00:00Z",
    "payment_url": "https://app.advancehq.com/checkout/abc123",
    "invoice_pdf_url": "https://storage.advancehq.com/invoices/plan_abc123.pdf",
    "created_at": "2025-01-15T10:30:00Z"
  }
]

Response (Paginated):

{
  "data": [
    {
      "plan_id": "plan_abc123",
      "plan_number": "INV-2025-0001",
      "insured_name": "Acme Corporation",
      "status": "open",
      "total_invoiced_amount": "5250.00",
      "collected_amount": "0.00"
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 50,
    "total_items": 150,
    "total_pages": 3,
    "has_next": true,
    "has_previous": false
  }
}

Get Plan by ID

Retrieves detailed information about a specific plan.

Endpoint: GET /v1/plans/{plan_id}

Use Cases:

  • Check payment status of a specific invoice
  • Retrieve invoice PDF URL for customer
  • Verify plan details before processing

Example:

curl -X GET "https://api.advancehq.com/v1/plans/plan_abc123" \
  -H "Authorization: Bearer your_api_key"

Response:

{
  "plan_id": "plan_abc123",
  "plan_number": "INV-2025-0001",
  "invoice_number": "INV-2025-0001",
  "insured_id": "ins_xyz789",
  "insured_name": "Acme Corporation",
  "producer_id": "prod_def456",
  "status": "partially_paid",
  "billing_type": "agency",
  "premiums": "12500.00",
  "taxes_and_fees": "75.00",
  "additional_policy_items_amount": "0.00",
  "total_invoiced_amount": "12575.00",
  "collected_amount": "5000.00",
  "commission_amount": "1257.50",
  "processing_fees_ach": "0.00",
  "processing_fees_credit_card": "375.00",
  "payment_due": "2025-03-01T00:00:00Z",
  "payment_url": "https://app.advancehq.com/checkout/abc123",
  "invoice_pdf_url": "https://storage.advancehq.com/invoices/plan_abc123.pdf",
  "invoice_header": "Invoice",
  "invoice_memo": "Thank you for your business!",
  "policies": [
    {
      "policy_id": "pol_123",
      "policy_name": "Workers Compensation",
      "policy_number": "WC-2025-100",
      "carrier_id": "car_def456",
      "carrier_name": "National Insurance Co",
      "effective_date": "2025-01-15T00:00:00Z",
      "expiration_date": "2026-01-15T00:00:00Z",
      "premium": {
        "name": "Premium",
        "amount": "12500.00"
      },
      "taxes": {
        "name": "State Tax",
        "amount": "50.00"
      },
      "fees": {
        "name": "Policy Fee",
        "amount": "25.00"
      },
      "additional_policy_items": [],
      "status": "open"
    }
  ],
  "agency_fees": [
    {
      "name": "Processing Fee",
      "amount": "75.00"
    }
  ],
  "created_at": "2025-01-10T14:20:00Z",
  "last_updated": "2025-01-20T09:15:00Z"
}

Get Plans Count

Returns the count of plans grouped by status.

Endpoint: GET /v1/plans/count

Use Cases:

  • Dashboard statistics
  • Monitoring invoice volume by status

Example:

curl -X GET "https://api.advancehq.com/v1/plans/count" \
  -H "Authorization: Bearer your_api_key"

Response:

{
  "total": 1250,
  "open": 450,
  "paid": 680,
  "partially_paid": 85,
  "draft": 20,
  "overdue": 15
}

Update Plan Status

Updates the status of an existing plan.

Endpoint: PUT /v1/plans/{plan_id}/status

Use Cases:

  • Mark a plan as deleted
  • Reopen a draft plan
  • Manually update payment status

Request Body:

FieldTypeRequiredDescription
statusstringYesNew status: draft, open, deleted, paid, partially_paid

Example:

curl -X PUT "https://api.advancehq.com/v1/plans/plan_abc123/status" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "deleted"
  }'