Search across your Organizations. Returns an array of Organization objects.
Search for Organizations
Body parameters
The cursor field allows you to paginate through your results. Each result array is limited to 1000 results. If your query returns more than 1000 results, you will need to paginate the responses using the cursor. If you receive a response that includes a non-null next_cursor in the results_metadata object, repeat the search call with the next_cursor value set to the cursor field to retrieve the next page of results. Continue to make search calls until the next_cursor in the response is null.
The number of search results to return per page. The default limit is 100. A maximum of 1000 results can be returned by a single search request. If the total size of your result set is greater than one page size, you must paginate the response. See the cursor field.
The optional query object contains the operator, i.e. AND or OR, and the operands that will filter your results. Only an operator is required. If you include no operands, no filtering will be applied. If you include no query object, it will return all Organizations with no filtering applied.
The action to perform on the operands. The accepted value are:
AND – all the operand values provided must match.
OR – the operator will return any matches to at least one of the operand values you supply.
An array of operand objects that contains all of the filters and values to apply to your search query.
The type of search filter to apply. The accepted values are: organization_ids, organization_slugs, organization_slug_fuzzy, organization_name_fuzzy, member_emails, member_email_fuzzy, allowed_domains, allowed_domain_fuzzy, claimed_email_domains, has_active_sso_connection, and sso_connection_id.
The values to search for based on which filter_name is applied.
An array of organization_ids to search for by exact match, when filter_name = "organization_ids".
An array of organization_slugs to search for by exact match, when filter_name = "organization_slugs".
The organization_slug to search for by fuzzy match, when filter_name = "organization_slug_fuzzy".
The organization_name to search for by fuzzy match, when filter_name = "organization_name_fuzzy".
An array of Member email_addresss to search for by exact match, when filter_name = "member_emails".
The Member's email_address to search for by fuzzy match, when filter_name = "member_email_fuzzy".
An array of email domains to search for by exact match, when filter_name = "allowed_domains".
The email domain to search for by fuzzy match, when filter_name = "allowed_domain_fuzzy".
An array of claimed email domains to search for by exact match, when filter_name = "claimed_email_domains".
Response fields
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
The search results_metadata object contains metadata relevant to your specific query like total and next_cursor.
The next_cursor string is returned when your search result contains more than one page of results. This value is passed into your next search call in the cursor field.
The total number of results returned by your search query. If totals have been disabled for your Stytch Workspace to improve search performance, the value will always be -1.
const stytch = require('stytch');
const client = new stytch.B2BClient({
project_id: 'PROJECT_ID',
secret: 'SECRET',
env: stytch.envs.test,
});
const params = {
limit: 200,
cursor: "",
query: {
operator: "OR",
operands: [
{
filter_name: "allowed_domains",
filter_value: ["stytch.com"]
},
{
filter_name: "organization_name_fuzzy",
filter_value: "example org"
}
]
}
};
client.organizations
.search(params)
.then((resp) => {
console.log(resp);
})
.catch((err) => {
console.log(err);
});
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"results_metadata": {
"next_cursor": null,
"total": 5
},
"organizations": [
...
]
}
{
"status_code": 401,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "unauthorized_credentials",
"error_message": "Unauthorized credentials.",
"error_url": "https://stytch.com/docs/api/errors/401"
}
{
"status_code": 429,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "too_many_requests",
"error_message": "Too many requests have been made.",
"error_url": "https://stytch.com/docs/api/errors/429"
}
{
"status_code": 500,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "internal_server_error",
"error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
"error_url": "https://stytch.com/docs/api/errors/500"
}
Common Error Types
- invalid_email
- organization_search_expected_array_of_strings
- organization_search_expected_string
- organization_search_filter_name_not_recognized
- organization_search_member_email_fuzzy_too_short
- organization_search_missing_filter_name
- organization_search_missing_filter_value
- organization_search_organization_name_fuzzy_too_short
- search_timeout
- user_search_invalid_cursor
- user_search_invalid_limit
- user_search_invalid_operator