I’m trying to retrieve specific records from my Airtable base by using the filterByFormula parameter in the API endpoint. However, I keep running into an “INVALID_FILTER_BY_FORMULA” error when making the request.
Here’s what I’m attempting:
api.airtable.com/v0/BASE_ID/Products?filterByFormula=(FIND("Smart home device will send alerts when motion detected",{Customer needs}) &api_key=YOUR_API_KEY
The error response I receive:
{
"error": {
"type": "INVALID_FILTER_BY_FORMULA",
"message": "The formula for filtering records is invalid: Invalid formula. Please check your formula text."
}
}
I’ve been testing this through Postman but can’t figure out what’s wrong with my formula syntax. What’s the correct way to structure this filterByFormula query to search for text within a specific field? Any help would be appreciated.
The issue is with your URL encoding and missing closing parenthesis. When you have spaces and special characters in your filterByFormula parameter, they need to be properly URL encoded. Your FIND function is also missing the closing parenthesis.
Try this approach instead:
api.airtable.com/v0/BASE_ID/Products?filterByFormula=FIND(%22Smart%20home%20device%20will%20send%20alerts%20when%20motion%20detected%22%2C%7BCustomer%20needs%7D)&api_key=YOUR_API_KEY
I ran into similar encoding problems when I first started working with Airtable’s API. The key is that spaces become %20, quotes become %22, and curly braces become %7B and %7D. Most HTTP clients like Postman should handle this automatically if you put the raw formula in the params section rather than constructing the full URL manually. That way you avoid the encoding headaches entirely.
Your formula syntax has a fundamental issue beyond just URL encoding. The FIND function in Airtable returns a number (the position where text is found) or an error if not found, but your filter needs to evaluate to true or false. You should wrap it in a comparison or use a different approach.
Try this instead:
FIND("Smart home device", {Customer needs}) > 0
This checks if the text exists and returns true when found. I learned this the hard way after getting similar errors - FIND alone doesn’t work as a boolean filter. You could also use SEARCH function which is case-insensitive, or simply use this pattern: {Customer needs} = "your exact text" for exact matches. The comparison operator is what makes it a valid filter formula that Airtable can process properly.