LostChurn Docs
API Reference

Customers API

Query customer records, retrieve customer details, and list a customer's payment history via the LostChurn REST API.

The Customers API provides access to customer records that LostChurn has received through webhook events from your payment processor. Customers are created automatically when LostChurn receives their first failed payment event.

Endpoints

MethodPathDescription
GET/v1/customersList customers
GET/v1/customers/:idGet a customer
GET/v1/customers/:id/paymentsList a customer's payments
DELETE/v1/customers/:idDelete customer data (GDPR erasure)

List Customers

Retrieve a paginated list of customers, optionally filtered by status or search query.

GET /v1/customers

Query Parameters

ParameterTypeDefaultDescription
querystring--Search by name or email
statusstringallFilter: active (has pending recovery), recovered (all payments recovered), churned (subscription canceled)
pspstring--Filter by payment processor
has_failed_paymentboolean--Filter to customers with at least one currently failed payment
created_afterstring--ISO 8601 datetime
created_beforestring--ISO 8601 datetime
sortstringcreated_atSort field: created_at, name, email, total_recovered
orderstringdescSort order: asc, desc
pageinteger1Page number
per_pageinteger20Results per page (max: 100)

Example Request

curl "https://api.lostchurn.com/v1/customers?has_failed_payment=true&per_page=10" \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": [
    {
      "id": "cus_def456",
      "email": "jane.smith@example.com",
      "name": "Jane Smith",
      "psp": "stripe",
      "psp_customer_id": "cus_stripe_abc123",
      "status": "active",
      "total_payments": 3,
      "failed_payments": 1,
      "recovered_payments": 2,
      "total_recovered_amount": 9998,
      "total_recovered_currency": "usd",
      "created_at": "2024-11-15T10:00:00Z",
      "updated_at": "2025-03-08T14:30:00Z"
    },
    {
      "id": "cus_ghi789",
      "email": "john.doe@example.com",
      "name": "John Doe",
      "psp": "stripe",
      "psp_customer_id": "cus_stripe_def456",
      "status": "active",
      "total_payments": 1,
      "failed_payments": 1,
      "recovered_payments": 0,
      "total_recovered_amount": 0,
      "total_recovered_currency": "usd",
      "created_at": "2025-01-20T08:30:00Z",
      "updated_at": "2025-03-07T09:15:00Z"
    }
  ],
  "pagination": {
    "total": 234,
    "page": 1,
    "per_page": 10,
    "total_pages": 24
  }
}

Get a Customer

Retrieve full details for a single customer, including their current subscription status and recovery summary.

GET /v1/customers/:id

Example Request

curl https://api.lostchurn.com/v1/customers/cus_def456 \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": {
    "id": "cus_def456",
    "email": "jane.smith@example.com",
    "name": "Jane Smith",
    "psp": "stripe",
    "psp_customer_id": "cus_stripe_abc123",
    "status": "active",
    "subscriptions": [
      {
        "id": "sub_ghi789",
        "psp_subscription_id": "sub_stripe_xyz",
        "plan": "Pro Monthly",
        "amount": 4999,
        "currency": "usd",
        "status": "active",
        "current_period_end": "2025-04-08T00:00:00Z"
      }
    ],
    "payment_method": {
      "type": "card",
      "brand": "visa",
      "last_four": "4242",
      "exp_month": 12,
      "exp_year": 2026
    },
    "recovery_summary": {
      "total_failures": 3,
      "total_recovered": 2,
      "total_terminal": 0,
      "total_pending": 1,
      "recovery_rate": 0.67,
      "total_recovered_amount": 9998,
      "currency": "usd"
    },
    "created_at": "2024-11-15T10:00:00Z",
    "updated_at": "2025-03-08T14:30:00Z"
  }
}

List Customer Payments

Retrieve all payments (failed, recovered, and terminal) for a specific customer.

GET /v1/customers/:id/payments

Query Parameters

ParameterTypeDefaultDescription
statusstringallFilter by status: pending, retrying, recovered, terminal, communication_pending
sortstringcreated_atSort field
orderstringdescSort order
pageinteger1Page number
per_pageinteger20Results per page (max: 100)

Example Request

curl "https://api.lostchurn.com/v1/customers/cus_def456/payments?status=recovered" \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": [
    {
      "id": "pay_abc123",
      "amount": 4999,
      "currency": "usd",
      "status": "recovered",
      "decline_code": "insufficient_funds",
      "decline_category": "soft_retry",
      "retry_count": 2,
      "created_at": "2025-03-01T14:30:00Z",
      "recovered_at": "2025-03-03T06:12:00Z"
    },
    {
      "id": "pay_xyz789",
      "amount": 4999,
      "currency": "usd",
      "status": "recovered",
      "decline_code": "generic_decline",
      "decline_category": "soft_retry",
      "retry_count": 1,
      "created_at": "2025-02-01T10:00:00Z",
      "recovered_at": "2025-02-02T08:30:00Z"
    }
  ],
  "pagination": {
    "total": 2,
    "page": 1,
    "per_page": 20,
    "total_pages": 1
  }
}

Delete Customer Data

Permanently delete all personal data for a customer. This supports GDPR right-to-erasure requests. Transaction records are anonymized (customer identifiers removed) but retained for financial reporting. See GDPR & Data Privacy for details.

DELETE /v1/customers/:id

Example Request

curl -X DELETE https://api.lostchurn.com/v1/customers/cus_def456 \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": {
    "id": "cus_def456",
    "deleted": true,
    "anonymized_records": 3
  }
}

This action is irreversible. The API key must have write or admin scope.

Customer Object

FieldTypeDescription
idstringLostChurn customer ID
emailstringCustomer email address
namestringCustomer display name
pspstringPayment processor
psp_customer_idstringCustomer ID in your PSP
statusstringactive, recovered, churned
total_paymentsintegerTotal failed payments recorded
failed_paymentsintegerCurrently failed (pending) payments
recovered_paymentsintegerSuccessfully recovered payments
total_recovered_amountintegerTotal recovered in smallest currency unit
total_recovered_currencystringCurrency of recovered amount
subscriptionsarrayActive subscriptions (on detail endpoint)
payment_methodobjectCurrent payment method details (on detail endpoint)
recovery_summaryobjectRecovery statistics (on detail endpoint)
created_atstringFirst seen timestamp
updated_atstringLast update timestamp

Next Steps

On this page