GoliathDevelopersGet an API key
Reference/Contactsgenerated from the gateway manifest

countRecords

Count records grouped by any field in ONE call.

POST/api/v1/callREADreadruns as the key's owner
View as Markdown

Count records grouped by any field in ONE call: tasks per contact or per teammate, mine vs others, contacts by source, deals by stage. Use it instead of paging a list op or a code task to tally. spec = {from, groupBy (up to 6), measures, where (equality; an array = any of; null = unset), orderBy [{by, dir}], limit (default 500), since/until (ISO, "now", "-30d")}. Values match exactly: statuses are UPPERCASE (tasks: UPCOMING, OVERDUE = past due now, earlier today included, COMPLETED; open tasks = completed false). Counts only what the caller may see. Contacts per TAG are contactTagUsage, one call; contacts.owners groups by the whole owner set, not per owner. Answers {ok, result: {rows, truncated}} or {ok: false, error}. Models: contacts (group: owners, source, doNotContact, lastActivityType, archived, stage, buyer, buyerStatus; measures: count, replied; time createdAt) · tasks (group: contactId, contactName, assigneeId, assignee, mine, completed, status; measures: count, rows; time dueAt) · deals (group: pipelineId, pipeline, stageId, stage, outcome, archived, workflowId, employeeId, teammateId, origin, assignees; measures: count, valueCents; time createdAt) · pipeline (group: pipelineId, pipeline, stageId, stage, stageOrder, outcome; measures: deals, valueCents, openDeals, openValueCents) · appointments (group: completed, cancelled, workflowId, employeeId, teammateId; measures: count; time startAt) · leads (group: source; measures: count; time at) · properties (group: contactId, contactName, relation, zipCode, state, propertyType, bedrooms, ownerOccupied, countyFips, county, ownedSince, ownerPropertyCount, wrongLink, archived; measures: count, properties, contacts, avgEstimatedValue, medianEstimatedValue)

curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operationId": "countRecords",
    "variables": {
      "spec": "<JSON>"
    }
  }'
import { GoliathClient } from '@goliath-data/sdk'

const goliath = new GoliathClient({
  apiKey: process.env.GOLIATH_API_KEY!,
  baseUrl: 'https://server.goliathdata.com',
})

const result = await goliath.contacts.countRecords({
  spec: '<JSON>'
})
const res = await fetch('https://server.goliathdata.com/api/v1/call', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.GOLIATH_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    operationId: 'countRecords',
    variables: {
      spec: '<JSON>'
    }
  }),
})
const { data, errors } = await res.json()

Variables

The example sends only what the schema requires. Some operations also need one of several optional variables (one filter or another, say); the description above says which.

specJSON!required

Response

What comes back under data: a list shows as one entry, and a value as its type.

response shape
{
  "data": {
    "pagesQuery": {
      "count": "…"
    }
  }
}

Errors

Behaviour

A read. It rejects an Idempotency-Key header with 400 bad_request.