fastify-xhubspot
companies.search
Search HubSpot companies by matching a single property with an equality filter.
companies.search
Search HubSpot companies where a property equals a given value. Returns up to 100 results.
Signature
fastify.companies.search(
property: string,
value: string | number
): Promise<Array<{ id: string; properties: Record<string, string> }>>
Params
| Name | Type | Required | Description |
|---|---|---|---|
property | string | Yes | HubSpot property name to filter on (e.g., "industry", "lifecyclestage"). |
value | string | number | Yes | Value to match. Converted to string before sending to the API. |
Returns
Array of { id, properties }. Empty array if no matches.
Throws
[xHubspot] companies.search requires a property string[xHubspot] companies.search requires a value- Re-throws HubSpot API errors.
Examples
Basic — find all tech companies
const techCompanies = await fastify.companies.search("industry", "TECHNOLOGY");
Realistic — find customers for a campaign
fastify.get("/campaigns/eligible-companies", async () => {
const customers = await fastify.companies.search("lifecyclestage", "customer");
return customers.map(c => ({ id: c.id, name: c.properties.name }));
});
See also
- companies.list — list all companies without a filter
- companies.getByDomain — look up by domain specifically
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.companies.search(propertyName, value, options?)
use-when: Filter HubSpot companies by a single property value
returns: { results, total }
