Skip to main content
This is the current Data import API surface. It lets a trusted CLI or backend import job declare cost sources that Pylva should track and price. It is not a general historical customer or event upload endpoint. For the full coverage workflow, see Cost Source Discovery.

Authentication

Use a Data import key as a bearer token.
curl https://api.pylva.com/api/v1/cost-sources \
  -X POST \
  -H "Authorization: Bearer $PYLVA_CLI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "Search API",
    "slug": "search-api",
    "source_type": "non_llm_manual",
    "metric": "search_requests",
    "unit": "request",
    "price_per_unit": 0.01
  }'

Request

{
  "display_name": "Search API",
  "slug": "search-api",
  "source_type": "non_llm_manual",
  "metric": "search_requests",
  "unit": "request",
  "price_per_unit": 0.01
}
For tiered pricing, send pricing_tiers instead of price_per_unit:
{
  "display_name": "Transcription API",
  "slug": "transcription-api",
  "source_type": "non_llm_manual",
  "metric": "audio_minutes",
  "unit": "minute",
  "pricing_tiers": [
    { "from": 0, "to": 1000, "price": 0.006 },
    { "from": 1000, "to": null, "price": 0.004 }
  ]
}

Response

{
  "cost_source": {
    "id": "00000000-0000-0000-0000-000000000000",
    "builder_id": "11111111-1111-1111-1111-111111111111",
    "source_type": "non_llm_manual",
    "display_name": "Search API",
    "slug": "search-api",
    "metric": "search_requests",
    "unit": "request",
    "price_per_unit": 0.01,
    "pricing_tiers": null,
    "status": "healthy",
    "last_seen_at": null,
    "approved_at": "2026-06-11T10:00:00.000Z",
    "created_at": "2026-06-11T10:00:00.000Z"
  }
}

Notes

  • Re-running the same slug is idempotent and returns the existing cost source.
  • Use this endpoint from server-side import jobs only.
  • Use an Agent SDK key to send telemetry events.
  • Use an Admin API key to mutate custom pricing and other elevated project settings.