Jump to

  • Quickstarts
  • API reference
  • Webhook events
  • Error codes
  • SDKs

API reference

Lookup

How these fit together: the Lookup guide.

Lookup phone number

get/v1/lookup/{phone}

Looks a phone number up: validity, formats, country, type and India’s do-not-call status.

Answered from the numbering metadata this deployment carries and the NCPR (India do-not-call) extract the platform operator loaded — no vendor is contacted, so a lookup is free (it counts against the key’s per-minute request budget). The carrier name is never known (carrier.available: false). The number is in the path, so it is never logged or kept: the request log records the route template, error envelopes read /v1/lookup/[redacted]. A number that parses but is not one its country assigns is 200 with valid: false.

Access: an organization key with the lookup:read scope.

Path parameters

  • phonestringRequired

    The number in E.164 (+919876543210; URL-encode + as %2B if your client rewrites it), or written nationally with ?country= (09876543210?country=IN). Spaces, dots, dashes and brackets are ignored.

Query parameters

  • countrystring

    ISO 3166 alpha-2 country to read a number written WITHOUT + and a country calling code in (09876543210 with country=IN). Ignored for a number in E.164 (+…). Case-insensitive.

Response 200PublicPhoneNumberLookup

Show the 10 fields
  • carrierPublicLookupCarrierRequired

    2 fields of carrier
    • availablebooleanRequired

      Whether this deployment can name carriers: false. Read name only when it is true.

    • namestring | nullRequired

      Always null: a carrier (operator) name needs a vendor lookup, and this deployment makes none. India’s mobile numbers are portable, so the range a number was issued from would not name its operator either.

  • countrystring | nullRequired

    ISO 3166 alpha-2 country (or territory) the number belongs to. Null for a non-geographic code (+800, +882, …) or a number that is not valid.

  • countryCallingCodestringRequired

    The country calling code, without +.

  • dndPublicLookupDndRequired

    2 fields of dnd
    • registrystring | nullRequired

      The national do-not-call registry consulted: ncpr (India’s National Customer Preference Register) for a valid +91 number; null elsewhere.

      One ofncpr

    • statusstringRequired

      registered or not_registered on the NCPR extract the platform operator loaded into this deployment (not a live scrub with a registry vendor — a number registered since the last load reads not_registered); not_applicable for a number outside India or one that is not valid; not_checked for a TEST key, whose lookups never read the registry (it is real data about real people — use a live key). A promotional call to a registered number is refused (422 NCPR_REGISTERED).

      One ofregisterednot_registerednot_applicablenot_checked

  • e164stringRequired

    The number in E.164 (+, the country calling code, the national number) — the form every other endpoint takes.

  • invalidReasonstring | nullRequired

    Why valid is false: too_short, too_long, invalid_length (a length the country never uses) or not_in_numbering_plan (the right length, in a range not allocated). Null for a valid number.

    One oftoo_shorttoo_longinvalid_lengthnot_in_numbering_plan

  • nationalFormatstring | nullRequired

    How the number is written inside its country. Null when it is not valid.

  • objectstringRequired

    One ofphone_number_lookup

  • typestringRequired

    The kind of number its range is allocated to. fixed_line_or_mobile where the plan does not tell them apart (the US and Canada); unknown for a number that is not valid. A ported number keeps the type of its range.

    One ofmobilefixed_linefixed_line_or_mobiletoll_freepremium_rateshared_costvoippersonal_numberpageruanvoicemailunknown

  • validbooleanRequired

    Whether the number is one its country’s numbering plan assigns (right length, an allocated range). Not whether it is in service.

Errors

  • 400PHONE_NUMBER_MALFORMED — the path is not a phone number this API can read (letters, no country calling code and no country, a code no country uses); the message never repeats it. VALIDATION_FAILED — country is not an ISO 3166 alpha-2 code this API knows.
  • 401API_KEY_INVALID — missing, unknown, revoked or expired key.
  • 403API_KEY_SCOPE_MISSING or API_KEY_KIND_MISMATCH — the key may not call this endpoint.
  • 404NOT_FOUND — no such resource for this key (another organization’s id is answered the same way).
  • 429RATE_LIMITED — retry after Retry-After seconds.
  • 500INTERNAL_ERROR — our fault; retry with backoff (with the same Idempotency-Key on a write).
Request
curl 'https://api.trovacast.com/v1/lookup/%2B919876543210' \
  -H "Authorization: Bearer $TROVACAST_API_KEY"
Response 200 (json)
{
  "carrier": {
    "available": false,
    "name": null
  },
  "country": "IN",
  "countryCallingCode": "91",
  "dnd": {
    "registry": "ncpr",
    "status": "not_registered"
  },
  "e164": "+919876543210",
  "invalidReason": null,
  "nationalFormat": "098765 43210",
  "object": "phone_number_lookup",
  "type": "mobile",
  "valid": true
}