Skip to main content
Documentation

Leads

leads.sources

Break the shop's leads down by where they came from
Read-onlyRead budget

REST

Shipping
POST /api/v1/leads/sources

MCP tool

Live
leads.sources

Exposed on: REST API · Shop MCP server · Claude connector · Dash (in-app copilot) · Zapier. Part of the Leads domain.

Operating contract

Every source that produced a lead in the window, biggest first, with how many arrived and how many of those are won. This is the honest answer to 'where is our work coming from' and to 'is that channel worth what we pay for it'.

key is the normalised source and it is what leads.list's source filter takes; label is the same thing in a shop's own words ('Google', 'Walk-in', 'AI voice agent').

A source of unknown means the arrival recorded no attribution. It is a real answer and usually the most useful one on this list — it is the share of the pipeline nobody can credit, and it is what makes a spend-per-lead figure a guess.

Only sources this shop has actually seen are returned, so a channel missing from the list produced nothing in the window rather than not existing.

This read is a rollup, not a page: it counts every matching lead in the window and returns one row per source, so nothing is truncated.

Who may call it

Permission
leads.accessThe caller must hold Leads at the ACT level. A read-only dashboard grant on the same section is refused.
Plan
Every planNo plan gate. Available on every Service VIN plan.
Retries
naturalNaturally idempotent — running it twice leaves the same world as running it once. A retrying integration needs no key.
Rate class
readCounted against the read budget — the widest of the four.

Input

FieldTypeDescription
daysinteger1–730

How many days back to count. 1-730, defaults to 90.

Default: 90

Output

FieldTypeDescription
window_daysnumber

totalnumber

itemsobject[]

items[].keystring

items[].labelstring

items[].countnumber

items[].wonnumber

Examples

Built from this capability's own schema — required fields and the ones carrying a default, and nothing invented. Paste one and it validates.

curl
export SERVICEVIN_API_KEY=svk_live_…

curl -X POST https://www.servicevin.com/api/v1/leads/sources \
  -H "Authorization: Bearer $SERVICEVIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"days":90}'

TypeScript (fetch)
const res = await fetch("https://www.servicevin.com/api/v1/leads/sources", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SERVICEVIN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "days": 90
  }),
});

// Success and failure are both envelopes. Switch on error.code, never
// on error.message — the codes are stable, the messages are for people.
const payload = await res.json();
if (!res.ok) throw new Error(payload.error.code);
const data = payload.data;

Python (requests)
import os, requests

res = requests.post(
    "https://www.servicevin.com/api/v1/leads/sources",
    headers={"Authorization": f"Bearer {os.environ['SERVICEVIN_API_KEY']}"},
    json={
    "days": 90
},
    timeout=30,
)
payload = res.json()
if not res.ok:
    raise RuntimeError(payload["error"]["code"])
data = payload["data"]

MCP tools/call — https://www.servicevin.com/api/mcp
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "leads.sources",
    "arguments": {
      "days": 90
    }
  }
}

Refusals

The four gates run in this order on every surface, and the order is not arbitrary — see Authentication.

StatusCodeWhen
404not_foundThe id is unknown, or the feature is not enabled for this account. Deliberately the same answer for both.
403forbiddenThis login does not hold leads.access.
422validation_errorAn argument was wrong. The message names the field.
429rate_limitedToo many read calls. Back off and retry.
500internal_errorSomething failed on our side. Nothing was changed.