Skip to main content
Track costs associated with your managed sites.
Requires the Cost Tracker Extension to be installed and active.

What You’ll Learn

  • Listing and filtering cost entries
  • Creating and updating cost records
  • Associating costs with sites

GET /costs

Returns all cost entries with pagination support. Method: GET (readonly)
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/costs"

Parameters

NameTypeRequiredDefaultDescription
pageintegerNo1Page number
per_pageintegerNo10Items per page
searchstringNoSearch in cost name
includestringNoComma-separated cost IDs to include
excludestringNoComma-separated cost IDs to exclude
statusstringNoFilter by status
categorystringNoFilter by category
typestringNoFilter by type

Response

[
  {
    "id": 1,
    "name": "Hosting - Example Site",
    "type": "subscription",
    "category": "hosting",
    "amount": 29.99,
    "currency": "USD",
    "renewal_type": "monthly",
    "next_renewal": "2024-02-01",
    "sites": [1, 2],
    "created_at": "2024-01-01T00:00:00"
  }
]

GET /costs/

Returns details about a specific cost entry. Method: GET (readonly)
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/costs/1"

Parameters

NameTypeRequiredDescription
costintegerYesCost ID

Response

{
  "id": 1,
  "name": "Hosting - Example Site",
  "type": "subscription",
  "category": "hosting",
  "amount": 29.99,
  "currency": "USD",
  "renewal_type": "monthly",
  "next_renewal": "2024-02-01",
  "notes": "Annual hosting package",
  "sites": [
    {"id": 1, "url": "https://example.com", "name": "Example Site"}
  ],
  "payment_history": [
    {
      "date": "2024-01-01",
      "amount": 29.99,
      "status": "paid"
    }
  ],
  "created_at": "2024-01-01T00:00:00"
}

PUT /costs/add

Creates a new cost entry. Method: PUT
curl -X PUT \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Hosting Fee", "amount": 29.99, "type": "subscription"}' \
  "https://your-dashboard.com/wp-json/mainwp/v2/costs/add"

Parameters

NameTypeRequiredDescription
namestringYesCost name/description
amountnumberNoCost amount
currencystringNoCurrency code (default: USD)
typestringNoone-time, subscription
categorystringNohosting, plugin, theme, service, other
renewal_typestringNomonthly, yearly, quarterly
next_renewalstringNoNext renewal date (Y-m-d)
sitesstringNoComma-separated site IDs to associate
notesstringNoInternal notes

Response

{
  "id": 5,
  "name": "Hosting Fee",
  "amount": 29.99,
  "message": "Cost created successfully"
}

PUT /costs//edit

Updates an existing cost entry. Method: PUT
curl -X PUT \
  -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/costs/1/edit?name=Updated%20Cost&amount=39.99"

Parameters

NameTypeRequiredDescription
costintegerYesCost ID
namestringNoUpdated name
amountnumberNoUpdated amount
currencystringNoUpdated currency
typestringNoUpdated type
categorystringNoUpdated category
renewal_typestringNoUpdated renewal type
next_renewalstringNoUpdated next renewal date
sitesstringNoUpdated comma-separated site IDs
notesstringNoUpdated notes

Response

{
  "id": 1,
  "name": "Updated Cost",
  "amount": 39.99,
  "message": "Cost updated successfully"
}