{"command":{"effect":"write","timeoutSeconds":30,"inputSchema":{"type":"object","description":"You can search for companies by the value of their attributes in order to fetch exactly the companies you want.\n\nTo search for companies, send a `POST` request to `https://api.intercom.io/companies/search`, with a query object in the body defining your filters.\n\nNote that the API does not include companies who have no associated users in search results.\n\n{% admonition type=\"warning\" name=\"Optimizing search queries\" %}\n  Search queries can be complex, so optimizing them can help the performance of your search.\n  Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize\n  pagination to limit the number of results returned. The default is `15` results per page.\n  See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param.\n{% /admonition %}\n\n### Nesting & Limitations\n\nYou can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).\nThere are some limitations to the amount of multiple's there can be:\n* There's a limit of max 2 nested filters\n* There's a limit of max 15 filters for each AND or OR group\n\n### Accepted Fields\n\nMost keys listed as part of the Companies Model are searchable. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `\"foobar\"`).\n\n| Field                              | Type                           |\n| ---------------------------------- | ------------------------------ |\n| company_id                         | String                         |\n| name                               | String                         |\n| created_at                         | Date (UNIX Timestamp)          |\n| updated_at                         | Date (UNIX Timestamp)          |\n| remote_created_at                  | Date (UNIX Timestamp)          |\n| last_request_at                    | Date (UNIX Timestamp)          |\n| monthly_spend                      | Integer                        |\n| session_count                      | Integer                        |\n| user_count                         | Integer                        |\n| tag_id                             | String                         |\n| custom_attributes.{attribute_name} | String                         |\n\nThe `plan.id` and `plan.name` fields are not searchable and return a `400` error with code `invalid_field`.\n\n### Accepted Operators\n\nThe table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`\"=\"`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). Searching by `tag_id` supports only the `=` and `!=` operators. The `IN` and `NIN` operators are not supported for Date fields.\n\n| Operator | Valid Types                      | Description                                                      |\n| :------- | :------------------------------- | :--------------------------------------------------------------- |\n| =        | All                              | Equals                                                           |\n| !=       | All                              | Doesn't Equal                                                    |\n| IN       | All except Date and tag_id       | In<br>Shortcut for `OR` queries<br>Values must be in Array       |\n| NIN      | All except Date and tag_id       | Not In<br>Shortcut for `OR !` queries<br>Values must be in Array |\n| >        | Integer<br>Date (UNIX Timestamp) | Greater than                                                     |\n| <       | Integer<br>Date (UNIX Timestamp) | Lower than                                                       |\n| ~        | String                           | Contains                                                         |\n| !~       | String                           | Doesn't Contain                                                  |\n| ^        | String                           | Starts With                                                      |\n| $        | String                           | Ends With                                                        |\n\n### Sorting\n\nPass an optional `sort` object with a `field` and an `order` (`ascending` or `descending`; defaults to `descending`) to order the results. An invalid `order` returns a `400` error with code `invalid_sort_order`. `tag_id` can be used as a filter but not as a sort field.\n\n### Pagination\n\nPass an optional `pagination` object with `per_page` and `starting_after`. `per_page` defaults to 15 and must be between 1 and 150; anything else returns a `400` error with code `invalid_per_page`. Take `starting_after` from `pages.next` in the previous response, and send it with the same `sort` you used for that response. A cursor from a sort on a text field such as `name`, sent with a sort on a number or date field (or the other way round), returns a `400` error with code `client_error`. Leaving out `sort` sorts by `last_request_at`, a date. A cursor sent with a different sort of the same kind is accepted, but the page it returns doesn't follow on from the previous one.\n\nRequires the `read_users_companies` OAuth scope.\n","properties":{"headers":{"type":"object","properties":{"Intercom-Version":{"$ref":"#/definitions/intercom_version","enum":["2.17"]}},"required":[],"additionalProperties":false},"body":{"$ref":"#/definitions/company_search_request","examples":[{"query":{"operator":"AND","value":[{"field":"name","operator":"=","value":"my-company"}]},"sort":{"field":"name","order":"ascending"},"pagination":{"per_page":5}}]}},"required":[],"additionalProperties":false,"definitions":{"intercom_version":{"description":"Intercom API version.</br>If you omit the header, the API uses the version set in your app package, and 1.0 if none is set.","type":"string","enum":["1.0","1.1","1.2","1.3","1.4","2.0","2.1","2.2","2.3","2.4","2.5","2.6","2.7","2.8","2.9","2.10","2.11","2.12","2.13","2.14","2.15","2.16","2.17"],"examples":["2.17"]},"company_search_request":{"description":"Search for companies using Intercom's Search API.","type":"object","title":"Company search request","properties":{"query":{"oneOf":[{"$ref":"#/definitions/single_filter_search_request"},{"$ref":"#/definitions/multiple_filter_search_request"}]},"pagination":{"$ref":"#/definitions/starting_after_paging"},"sort":{"type":"object","description":"An optional object to sort the results by.","properties":{"field":{"type":"string","description":"The field to sort the results on.","examples":["created_at"]},"order":{"type":"string","description":"The order to sort the results in. Defaults to `descending` when omitted. Values other than `ascending` or `descending` return a `400` error with code `invalid_sort_order`.","enum":["ascending","descending"],"default":"descending","examples":["descending"]}}}},"required":["query"]},"single_filter_search_request":{"title":"Single Filter Search Request","description":"Search using Intercoms Search APIs with a single filter.","type":"object","properties":{"field":{"type":"string","description":"The accepted field that you want to search on.","examples":["created_at"]},"operator":{"type":"string","enum":["=","!=","IN","NIN","<","<=",">",">=","~","!~","^","$"],"description":"The accepted operators you can use to define how you want to search for the value. Operator support depends on the field's data type. The breakdown below is for Contacts search; the other search endpoints that share this schema accept a different set per field:\n- `string` fields: `=`, `!=`, `IN`, `NIN`, `~`, `!~`, `^`, `$`\n- `tag_id`: `=` and `!=` only. Every other operator returns an error.\n- `boolean` fields: `=`, `!=`, `IN`, `NIN`\n- `integer` fields: `=`, `!=`, `IN`, `NIN`, `<`, `>`, `<=`, `>=`\n- `datetime` fields (standard contact timestamps such as `created_at` and `last_seen_at`): `=`, `!=`, `<`, `>`, `<=`, `>=`. Filtering is on the exact second, in UTC.\n- `date` fields (Date custom attributes): `=`, `<`, `>` only. `!=`, `<=`, and `>=` are not supported and return an error. Values are truncated to a whole UTC day.","examples":[">"]},"value":{"oneOf":[{"type":"string"},{"type":"integer"},{"type":"boolean"},{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"integer"}]}}],"description":"The value that you want to search on.","examples":["73732934"]}}},"multiple_filter_search_request":{"title":"Multiple Filter Search Request","description":"Search using Intercoms Search APIs with more than one filter.","type":"object","properties":{"operator":{"type":"string","enum":["AND","OR"],"description":"An operator to allow boolean inspection between multiple fields.","examples":["AND"]},"value":{"oneOf":[{"type":"array","description":"Add mutiple filters.","title":"multiple filter search request","items":{"$ref":"#/definitions/multiple_filter_search_request"}},{"type":"array","description":"Add a single filter field.","title":"single filter search request","items":{"$ref":"#/definitions/single_filter_search_request"}}]}}},"starting_after_paging":{"title":"Pagination: Starting After","type":["object","null"],"properties":{"per_page":{"type":"integer","description":"The number of results to fetch per page.","examples":[2]},"starting_after":{"type":["string","null"],"description":"The cursor to use in the next request to get the next page of results.","examples":["your-cursor-from-response"]}}}}},"name":"Search companies","id":"intercom.searchcompanies","example":{},"maxRequests":1,"summary":false}}