Skip to content

Define a field, then filter by it

Your records already carry customFields.obsolescenceScore (0–100) and customFields.province. To filter by range and sort by them, define them.

{ "tool": "list_custom_fields", "entityType": "organization" }

If the key is defined, use it as it is. Never invent a variant (provincia next to province).

{ "tool": "define_custom_field", "entityType": "organization", "key": "obsolescenceScore", "type": "number",
"label": { "es": "Obsolescencia web", "en": "Website obsolescence" },
"description": "0-100, higher means a worse website", "showInList": true,
"idempotencyKey": "define:obsolescenceScore" }
  • meta.existingValues: how many records already hold the key.
  • meta.invalidValues: how many of those are stored with another type (for example "57" as a string). They count as NULL in typed filters until rewritten.

Upsert them with the value in its proper type. Writes to a defined key are coerced ("58" → 58) or refused (VALIDATION_FAILED, reason CUSTOM_FIELD_TYPE, or NOT_AN_OPTION with allowed for a select).

{ "tool": "upsert_records", "type": "organization", "matchOn": "domain",
"items": [{ "domain": "acme.es", "customFields": { "obsolescenceScore": 57 } }] }

Send the typed value (57, not "57"). A write that sends exactly what is already stored ("57" again) is treated as untouched, so that the read-modify-writes of other tools never fail on old values: it leaves the string in place.

The worst websites in Gipuzkoa first:

{ "tool": "query_records", "type": "organization",
"filters": [{ "field": "customFields.obsolescenceScore", "op": "gte", "value": 50 },
{ "field": "customFields.province", "op": "eq", "value": "Gipuzkoa" }],
"sort": "customFields.obsolescenceScore:desc", "fields": ["name", "domain", "customFields"] }

REST:

Terminal window
curl -sg "https://api.mety.ai/api/v1/organizations?filter[customFields.obsolescenceScore][gte]=50&filter[customFields.province][eq]=Gipuzkoa&sort=customFields.obsolescenceScore:desc" \
-H "Authorization: Bearer $METY_KEY"

province here is undefined, so it takes eq/in only and compares as text. Define it as text or select to get contains or a fixed list of options.