> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.withpersona.com/2025-10-27/api-reference/accounts/search-accounts/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withpersona.com/_mcp/server. # Search Accounts POST https://api.withpersona.com/api/v1/accounts/search Content-Type: application/json Search for accounts using a flexible query language. ## Search vs. List Endpoints The Search and List endpoints serve different purposes and have distinct performance characteristics. Use the **Search** endpoint (`POST /accounts/search`) when you need to perform complex queries with boolean logic (AND/OR/NOT), filter by custom fields or identifiers, or apply multiple conditions simultaneously. Search is optimized for flexible querying and is faster than paginating through all resources when looking for specific records. Use the **List** endpoint (`GET /accounts`) for simple listing with basic filters like reference ID. ## Data Freshness Do not use search for read-after-write flows because the data will not be immediately available to search. Under normal operating conditions, data is searchable within approximately 1 minute of creation or modification. Propagation of new or updated data could be delayed during an outage. For workflows that require immediate data availability after creating or updating an account, use the List Accounts endpoint instead. ### Searchable Attributes The following attributes can be used in query predicates: | Attribute | Description | |-----------|-------------| | `type` | Account type (e.g., `acttp_ABC123`) | | `status` | Account status (e.g., `actst_ABC123`) | | `created_at` | Account creation timestamp | | `updated_at` | Account last updated timestamp | | `identifiers.*` | Custom identifier (e.g., `identifiers.user_id`) | | `fields.*` | Custom account field (e.g., `fields.age`) | **Note:** Custom fields (`fields.*`) must be configured as searchable on the Account Type to be queryable. Reference: https://docs.withpersona.com/api-reference/accounts/search-accounts ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Query parameters - `fields` (map from string to string, optional) — Comma-separated list(s) of attributes to include in the response. This can be used to customize which attributes will be serialized in the response. See [Serialization](https://docs.withpersona.com/serialization#sparse-fieldsets) for more details. - `page` (AccountsSearchPostParametersPage, optional) ### Headers - `Key-Inflection` (enum, optional) — Determines casing for the API response. - Allowed values: `camel`, `kebab`, `snake` - `Idempotency-Key` (string, optional) — Ensures the request is idempotent. - `Persona-Version` (enum, optional) — Server API version. More info on versioning can be found [here](https://docs.withpersona.com/versioning). - Allowed values: `2025-12-08`, `2025-10-27`, `2023-01-05`, `2022-09-01`, `2021-08-18`, `2021-07-05`, `2021-02-21`, `2020-05-18` ### Body (application/json) This endpoint expects an Accounts_search-accounts_Request. - `query` (AccountsSearchPostRequestBodyContentApplicationJsonSchemaQuery, optional) — Search query using boolean logic (AND/OR/NOT) and comparison operators. Supports predicates with operators: eq (equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal). - `sort` (AccountsSearchPostRequestBodyContentApplicationJsonSchemaSort, optional) — Sort configuration for results - `page` (AccountsSearchPostRequestBodyContentApplicationJsonSchemaPage, optional) — Pagination parameters ## Response ### 200 This endpoint returns a collection of Account objects matching the search criteria. - `data` (list of account, required) — An array of Accounts matching the search criteria - `links` (AccountsSearchPostResponsesContentApplicationJsonSchemaLinks, required) ## Errors ### 400 Bad Request Error The request was unacceptable, often due to invalid parameters. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 401 Unauthorized Error An invalid API key was provided. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 403 Forbidden Error The given API key doesn’t have permissions to perform the request or a quota has been exceeded. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 404 Not Found Error The requested resource doesn’t exist. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 409 Conflict Error The request conflicts with another request, often due to attempting to create a duplicate resource. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 422 Unprocessable Entity Error The request modifies the resource in an unacceptable way, often due to an invalid action or parameter. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 429 Too Many Requests Error Your organization’s rate limit has been exceeded. We recommend an exponential backoff on requests. - `errors` (list of AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ## Types ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaQuery Search query using boolean logic (AND/OR/NOT) and comparison operators. Supports predicates with operators: eq (equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal). ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaSort Sort configuration for results - `attribute` (string, required) — The attribute name to sort by - `direction` (string, required, default: desc) — Sort direction. Possible values: asc (ascending), desc (descending). ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaPage Pagination parameters - `after` (string, optional) — Cursor for forward pagination - `before` (string, optional) — Cursor for backward pagination - `size` (integer, optional, default: 10) — Number of results to return per page ### AccountsSearchPostParametersPage - `after` (string, optional) — Cursor for forward pagination. Use the value from `links.next` in the previous response. - `before` (string, optional) — Cursor for backward pagination. Use the value from `links.prev` in the previous response. - `size` (integer, optional, default: 10) — Number of results to return per page. ### account An Account object. Note that `fields` is **not** key inflected. - `id` (string, optional) - `attributes` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributes, optional) - `relationships` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountRelationships, optional) ### AccountsSearchPostResponsesContentApplicationJsonSchemaLinks - `prev` (string, required, nullable) — URL pointing to the previous page of data, or null if on the first page. Must be used with POST request and original request body. - `next` (string, required, nullable) — URL pointing to the next page of data, or null if on the last page. Must be used with POST request and original request body. ### AccountsSearchPostResponsesContentApplicationJsonSchemaErrorsItems - `title` (string, optional) - `details` (string, optional) ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaQuery0 Boolean AND clause - combines multiple conditions where ALL must be true. This clause is recursive: each item in the `and` array can be another AND, OR, NOT clause, or a leaf predicate, enabling complex nested queries. Maximum nesting depth: 2 levels, Maximum clauses per AND: 20 - `and` (list of map from string to any, required) ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaQuery1 Boolean OR clause - combines multiple conditions where AT LEAST ONE must be true. This clause is recursive: each item in the `or` array can be another AND, OR, NOT clause, or a leaf predicate, enabling complex nested queries. Maximum nesting depth: 2 levels, Maximum clauses per OR: 20 - `or` (list of map from string to any, required) ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaQuery2 Boolean NOT clause - negates a single condition. This clause is recursive: the `not` value can be another AND, OR, NOT clause, or a leaf predicate, enabling complex nested queries. Maximum nesting depth: 2 levels - `not` (map from string to any, required) ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaQuery3 Attribute predicate - `attribute` (string, required) — The attribute name to filter on (e.g., 'created_at', 'type', 'status', 'fields.age') - `operator` (string, required) — Comparison operator. Possible values: eq (equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal). - `value` (AccountsSearchPostRequestBodyContentApplicationJsonSchemaQueryOneOf3Value, required) — Value to compare against ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributes - `reference-id` (string, optional, nullable) - `account-type-name` (string, optional) - `created-at` (datetime, optional) - `updated-at` (datetime, optional) - `redacted-at` (datetime, optional, nullable) - `fields` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFields, optional) — JSON key-value pairs of field name to field value. Exact schema depends on the configuration of the Account Type for this Account. Keys in `fields` are **not** key inflected. - `tags` (list of string, optional) - `account-status` (string, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountRelationships - `account-type` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountRelationshipsAccountType, optional) ### AccountsSearchPostRequestBodyContentApplicationJsonSchemaQueryOneOf3Value Value to compare against ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFields JSON key-value pairs of field name to field value. Exact schema depends on the configuration of the Account Type for this Account. Keys in `fields` are **not** key inflected. - `name` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsName, optional) - `address` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddress, optional) - `identification_numbers` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbers, optional) - `birthdate` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsBirthdate, optional) - `phone_number` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsPhoneNumber, optional) - `email_address` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsEmailAddress, optional) - `selfie_photo` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsSelfiePhoto, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountRelationshipsAccountType - `data` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountRelationshipsAccountTypeData, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsName - `type` (string, optional) - `value` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValue, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddress - `type` (string, optional) - `value` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValue, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbers - `type` (string, optional) - `value` (list of VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItems, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsBirthdate - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsPhoneNumber - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsEmailAddress - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsSelfiePhoto - `type` ("file", optional) - `value` (File, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountRelationshipsAccountTypeData - `id` (string, optional) - `type` ("account-type", optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValue - `first` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValueFirst, optional) - `middle` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValueMiddle, optional) - `last` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValueLast, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValue - `street_1` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueStreet1, optional) - `street_2` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueStreet2, optional) - `subdivision` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueSubdivision, optional) - `city` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueCity, optional) - `postal_code` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValuePostalCode, optional) - `country_code` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueCountryCode, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItems - `type` (string, optional) - `value` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValue, optional) ### File - `filename` (string, optional) - `url` (string, optional) - `byte-size` (integer, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValueFirst - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValueMiddle - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsNameValueLast - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueStreet1 - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueStreet2 - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueSubdivision - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueCity - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValuePostalCode - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsAddressValueCountryCode - `type` (string, optional) - `value` (string, optional, nullable) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValue - `identification_class` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueIdentificationClass, optional) - `identification_number` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueIdentificationNumber, optional) - `issuing_country` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueIssuingCountry, optional) - `hashed_identification_number` (VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueHashedIdentificationNumber, optional) — A SHA-256 hash of the identification number, keyed on organization, country code, identification class, and issuing subdivision. Stable across re-verifications of the same document for the same organization. Null when the identification number has not been hashed. ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueIdentificationClass - `type` (string, optional) - `value` (string, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueIdentificationNumber - `type` (string, optional) - `value` (string, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueIssuingCountry - `type` (string, optional) - `value` (string, optional) ### VerificationIncludedObjectsItemsDiscriminatorMappingAccountAttributesFieldsIdentificationNumbersValueItemsValueHashedIdentificationNumber A SHA-256 hash of the identification number, keyed on organization, country code, identification class, and issuing subdivision. Stable across re-verifications of the same document for the same organization. Null when the identification number has not been hashed. - `type` (string, optional) - `value` (string, optional, nullable) ## Examples ### Success **Response** ```json { "data": [ { "id": "act_ABC123", "attributes": { "reference-id": "abc-123", "account-type-name": "User", "created-at": "2023-09-22T17:13:49.000Z", "updated-at": "2023-09-23T00:22:19.000Z", "redacted-at": null, "fields": { "name": { "type": "hash", "value": { "first": { "type": "string", "value": "Jane" }, "middle": { "type": "string", "value": "Marie" }, "last": { "type": "string", "value": "Doe" } } }, "address": { "type": "hash", "value": { "street_1": { "type": "string", "value": "123 Main St" }, "street_2": { "type": "string", "value": null }, "subdivision": { "type": "string", "value": "California" }, "city": { "type": "string", "value": "San Francisco" }, "postal_code": { "type": "string", "value": "94111" }, "country_code": { "type": "string", "value": "US" } } }, "identification_numbers": { "type": "array", "value": [ { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "12345678" }, "issuing_country": { "type": "string", "value": "US" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "87654321" }, "issuing_country": { "type": "string", "value": "UK" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "cct" }, "identification_number": { "type": "string", "value": "A12345678" }, "issuing_country": { "type": "string", "value": "AF" } } } ] }, "birthdate": { "type": "date", "value": "1994-12-30" }, "phone_number": { "type": "string", "value": "111-222-3333" }, "email_address": { "type": "string", "value": "jane@doe.com" }, "selfie_photo": { "type": "file" } }, "tags": [ "tag1", "tag2" ] }, "relationships": { "account-type": { "data": { "id": "acttp_7X5W5w9GMtQntE6oPtKnj44c", "type": "account-type" } } }, "type": "account" } ], "links": { "prev": null, "next": "/api/v1/accounts/search?page%5Bafter%5D=act_ABC123&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Success import requests url = "https://api.withpersona.com/api/v1/accounts/search" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Success const url = 'https://api.withpersona.com/api/v1/accounts/search'; const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Success package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/accounts/search" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Success require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/accounts/search") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java Success import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/accounts/search") .header("Authorization", "Bearer ") .asString(); ``` ```php Success request('POST', 'https://api.withpersona.com/api/v1/accounts/search', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp Success using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/accounts/search"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift Success import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/accounts/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Simple query **Request** ```json { "query": { "not": { "attribute": "status", "operator": "eq", "value": "actst_ABC123" } }, "sort": { "attribute": "created_at", "direction": "asc" }, "page": { "size": 15 } } ``` **Response** ```json { "data": [ { "id": "act_ABC123", "attributes": { "reference-id": "abc-123", "account-type-name": "User", "created-at": "2023-09-22T17:13:49.000Z", "updated-at": "2023-09-23T00:22:19.000Z", "redacted-at": null, "fields": { "name": { "type": "hash", "value": { "first": { "type": "string", "value": "Jane" }, "middle": { "type": "string", "value": "Marie" }, "last": { "type": "string", "value": "Doe" } } }, "address": { "type": "hash", "value": { "street_1": { "type": "string", "value": "123 Main St" }, "street_2": { "type": "string", "value": null }, "subdivision": { "type": "string", "value": "California" }, "city": { "type": "string", "value": "San Francisco" }, "postal_code": { "type": "string", "value": "94111" }, "country_code": { "type": "string", "value": "US" } } }, "identification_numbers": { "type": "array", "value": [ { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "12345678" }, "issuing_country": { "type": "string", "value": "US" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "87654321" }, "issuing_country": { "type": "string", "value": "UK" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "cct" }, "identification_number": { "type": "string", "value": "A12345678" }, "issuing_country": { "type": "string", "value": "AF" } } } ] }, "birthdate": { "type": "date", "value": "1994-12-30" }, "phone_number": { "type": "string", "value": "111-222-3333" }, "email_address": { "type": "string", "value": "jane@doe.com" }, "selfie_photo": { "type": "file" } }, "tags": [ "tag1", "tag2" ] }, "relationships": { "account-type": { "data": { "id": "acttp_7X5W5w9GMtQntE6oPtKnj44c", "type": "account-type" } } }, "type": "account" } ], "links": { "prev": null, "next": "/api/v1/accounts/search?page%5Bafter%5D=act_ABC123&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Simple query import requests url = "https://api.withpersona.com/api/v1/accounts/search" payload = { "query": { "not": { "attribute": "status", "operator": "eq", "value": "actst_ABC123" } }, "sort": { "attribute": "created_at", "direction": "asc" }, "page": { "size": 15 } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Simple query const url = 'https://api.withpersona.com/api/v1/accounts/search'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"query":{"not":{"attribute":"status","operator":"eq","value":"actst_ABC123"}},"sort":{"attribute":"created_at","direction":"asc"},"page":{"size":15}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Simple query package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/accounts/search" payload := strings.NewReader("{\n \"query\": {\n \"not\": {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n }\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"asc\"\n },\n \"page\": {\n \"size\": 15\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Simple query require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/accounts/search") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"query\": {\n \"not\": {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n }\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"asc\"\n },\n \"page\": {\n \"size\": 15\n }\n}" response = http.request(request) puts response.read_body ``` ```java Simple query import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/accounts/search") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"query\": {\n \"not\": {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n }\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"asc\"\n },\n \"page\": {\n \"size\": 15\n }\n}") .asString(); ``` ```php Simple query request('POST', 'https://api.withpersona.com/api/v1/accounts/search', [ 'body' => '{ "query": { "not": { "attribute": "status", "operator": "eq", "value": "actst_ABC123" } }, "sort": { "attribute": "created_at", "direction": "asc" }, "page": { "size": 15 } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Simple query using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/accounts/search"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"query\": {\n \"not\": {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n }\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"asc\"\n },\n \"page\": {\n \"size\": 15\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Simple query import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "query": ["not": [ "attribute": "status", "operator": "eq", "value": "actst_ABC123" ]], "sort": [ "attribute": "created_at", "direction": "asc" ], "page": ["size": 15] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/accounts/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Complex boolean query **Request** ```json { "query": { "and": [ { "attribute": "type", "operator": "eq", "value": "acttp_ABC123" }, { "or": [ { "attribute": "status", "operator": "eq", "value": "actst_ABC123" }, { "attribute": "status", "operator": "eq", "value": "actst_ABC456" } ] } ] }, "sort": { "attribute": "created_at", "direction": "desc" }, "page": { "size": 15 } } ``` **Response** ```json { "data": [ { "id": "act_ABC123", "attributes": { "reference-id": "abc-123", "account-type-name": "User", "created-at": "2023-09-22T17:13:49.000Z", "updated-at": "2023-09-23T00:22:19.000Z", "redacted-at": null, "fields": { "name": { "type": "hash", "value": { "first": { "type": "string", "value": "Jane" }, "middle": { "type": "string", "value": "Marie" }, "last": { "type": "string", "value": "Doe" } } }, "address": { "type": "hash", "value": { "street_1": { "type": "string", "value": "123 Main St" }, "street_2": { "type": "string", "value": null }, "subdivision": { "type": "string", "value": "California" }, "city": { "type": "string", "value": "San Francisco" }, "postal_code": { "type": "string", "value": "94111" }, "country_code": { "type": "string", "value": "US" } } }, "identification_numbers": { "type": "array", "value": [ { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "12345678" }, "issuing_country": { "type": "string", "value": "US" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "87654321" }, "issuing_country": { "type": "string", "value": "UK" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "cct" }, "identification_number": { "type": "string", "value": "A12345678" }, "issuing_country": { "type": "string", "value": "AF" } } } ] }, "birthdate": { "type": "date", "value": "1994-12-30" }, "phone_number": { "type": "string", "value": "111-222-3333" }, "email_address": { "type": "string", "value": "jane@doe.com" }, "selfie_photo": { "type": "file" } }, "tags": [ "tag1", "tag2" ] }, "relationships": { "account-type": { "data": { "id": "acttp_7X5W5w9GMtQntE6oPtKnj44c", "type": "account-type" } } }, "type": "account" } ], "links": { "prev": null, "next": "/api/v1/accounts/search?page%5Bafter%5D=act_ABC123&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Complex boolean query import requests url = "https://api.withpersona.com/api/v1/accounts/search" payload = { "query": { "and": [{ "attribute": "type", "operator": "eq", "value": "acttp_ABC123" }, { "or": [ { "attribute": "status", "operator": "eq", "value": "actst_ABC123" }, { "attribute": "status", "operator": "eq", "value": "actst_ABC456" } ] }] }, "sort": { "attribute": "created_at", "direction": "desc" }, "page": { "size": 15 } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Complex boolean query const url = 'https://api.withpersona.com/api/v1/accounts/search'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"query":{"and":[{"attribute":"type","operator":"eq","value":"acttp_ABC123"},{"or":[{"attribute":"status","operator":"eq","value":"actst_ABC123"},{"attribute":"status","operator":"eq","value":"actst_ABC456"}]}]},"sort":{"attribute":"created_at","direction":"desc"},"page":{"size":15}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Complex boolean query package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/accounts/search" payload := strings.NewReader("{\n \"query\": {\n \"and\": [\n {\n \"attribute\": \"type\",\n \"operator\": \"eq\",\n \"value\": \"acttp_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC456\"\n }\n ]\n }\n ]\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"desc\"\n },\n \"page\": {\n \"size\": 15\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Complex boolean query require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/accounts/search") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"query\": {\n \"and\": [\n {\n \"attribute\": \"type\",\n \"operator\": \"eq\",\n \"value\": \"acttp_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC456\"\n }\n ]\n }\n ]\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"desc\"\n },\n \"page\": {\n \"size\": 15\n }\n}" response = http.request(request) puts response.read_body ``` ```java Complex boolean query import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/accounts/search") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"query\": {\n \"and\": [\n {\n \"attribute\": \"type\",\n \"operator\": \"eq\",\n \"value\": \"acttp_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC456\"\n }\n ]\n }\n ]\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"desc\"\n },\n \"page\": {\n \"size\": 15\n }\n}") .asString(); ``` ```php Complex boolean query request('POST', 'https://api.withpersona.com/api/v1/accounts/search', [ 'body' => '{ "query": { "and": [ { "attribute": "type", "operator": "eq", "value": "acttp_ABC123" }, { "or": [ { "attribute": "status", "operator": "eq", "value": "actst_ABC123" }, { "attribute": "status", "operator": "eq", "value": "actst_ABC456" } ] } ] }, "sort": { "attribute": "created_at", "direction": "desc" }, "page": { "size": 15 } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Complex boolean query using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/accounts/search"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"query\": {\n \"and\": [\n {\n \"attribute\": \"type\",\n \"operator\": \"eq\",\n \"value\": \"acttp_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC123\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"actst_ABC456\"\n }\n ]\n }\n ]\n },\n \"sort\": {\n \"attribute\": \"created_at\",\n \"direction\": \"desc\"\n },\n \"page\": {\n \"size\": 15\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Complex boolean query import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "query": ["and": [[ "attribute": "type", "operator": "eq", "value": "acttp_ABC123" ], ["or": [ [ "attribute": "status", "operator": "eq", "value": "actst_ABC123" ], [ "attribute": "status", "operator": "eq", "value": "actst_ABC456" ] ]]]], "sort": [ "attribute": "created_at", "direction": "desc" ], "page": ["size": 15] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/accounts/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Empty query (all accounts) **Request** ```json { "page": { "size": 15 } } ``` **Response** ```json { "data": [ { "id": "act_ABC123", "attributes": { "reference-id": "abc-123", "account-type-name": "User", "created-at": "2023-09-22T17:13:49.000Z", "updated-at": "2023-09-23T00:22:19.000Z", "redacted-at": null, "fields": { "name": { "type": "hash", "value": { "first": { "type": "string", "value": "Jane" }, "middle": { "type": "string", "value": "Marie" }, "last": { "type": "string", "value": "Doe" } } }, "address": { "type": "hash", "value": { "street_1": { "type": "string", "value": "123 Main St" }, "street_2": { "type": "string", "value": null }, "subdivision": { "type": "string", "value": "California" }, "city": { "type": "string", "value": "San Francisco" }, "postal_code": { "type": "string", "value": "94111" }, "country_code": { "type": "string", "value": "US" } } }, "identification_numbers": { "type": "array", "value": [ { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "12345678" }, "issuing_country": { "type": "string", "value": "US" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "visa" }, "identification_number": { "type": "string", "value": "87654321" }, "issuing_country": { "type": "string", "value": "UK" } } }, { "type": "hash", "value": { "identification_class": { "type": "string", "value": "cct" }, "identification_number": { "type": "string", "value": "A12345678" }, "issuing_country": { "type": "string", "value": "AF" } } } ] }, "birthdate": { "type": "date", "value": "1994-12-30" }, "phone_number": { "type": "string", "value": "111-222-3333" }, "email_address": { "type": "string", "value": "jane@doe.com" }, "selfie_photo": { "type": "file" } }, "tags": [ "tag1", "tag2" ] }, "relationships": { "account-type": { "data": { "id": "acttp_7X5W5w9GMtQntE6oPtKnj44c", "type": "account-type" } } }, "type": "account" } ], "links": { "prev": null, "next": "/api/v1/accounts/search?page%5Bafter%5D=act_ABC123&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Empty query (all accounts) import requests url = "https://api.withpersona.com/api/v1/accounts/search" payload = { "page": { "size": 15 } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Empty query (all accounts) const url = 'https://api.withpersona.com/api/v1/accounts/search'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"page":{"size":15}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Empty query (all accounts) package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/accounts/search" payload := strings.NewReader("{\n \"page\": {\n \"size\": 15\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Empty query (all accounts) require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/accounts/search") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"page\": {\n \"size\": 15\n }\n}" response = http.request(request) puts response.read_body ``` ```java Empty query (all accounts) import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/accounts/search") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"page\": {\n \"size\": 15\n }\n}") .asString(); ``` ```php Empty query (all accounts) request('POST', 'https://api.withpersona.com/api/v1/accounts/search', [ 'body' => '{ "page": { "size": 15 } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Empty query (all accounts) using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/accounts/search"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"page\": {\n \"size\": 15\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Empty query (all accounts) import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["page": ["size": 15]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/accounts/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```