> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.withpersona.com/2020-05-18/api-reference/cases/search-cases/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withpersona.com/_mcp/server. # Search Cases POST https://api.withpersona.com/api/v1/cases/search Content-Type: application/json Search for cases 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 /cases/search`) when you need to perform complex queries with boolean logic (AND/OR/NOT), filter by custom fields, assignee, case queue, or SLA expiration, 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 /cases`) for simple listing with basic filters like status, case template, account, inquiry, or report. ## 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 a case, use the List Cases endpoint instead. ### Searchable Attributes The following attributes can be used in query predicates: | Attribute | Description | |-----------|-------------| | `template` | Case template (e.g., `ctmpl_ABC123`) | | `case_template_id` | Case template (e.g., `ctmpl_ABC123`) | | `status` | Case status (e.g., `open`, `pending`, `resolved`) | | `state` | Case state | | `resolution` | Case resolution | | `created_at` | Case creation timestamp | | `updated_at` | Case last updated timestamp | | `resolved_at` | Case resolution timestamp | | `sla_expires_at` | SLA expiration timestamp | | `assignee` | Assigned user (e.g., `user_ABC123`) | | `case_queue` | Case queue (e.g., `cqueue_ABC123`) | | `case_queue_id` | Case queue (e.g., `cqueue_ABC123`) | | `resolver` | Resolver user | | `account_id` | Related account (e.g., `act_ABC123`) | | `inquiry_id` | Related inquiry (e.g., `inq_ABC123`) | | `tag_id` | Related tag (e.g., `tag_ABC123`) | | `fields.*` | Custom case field (e.g., `fields.priority`) | **Note:** Custom fields (`fields.*`) must be configured as searchable on the Case Template to be queryable. **Note:** `account_id`, `inquiry_id`, `tag_id`, `case_template_id`, `case_queue_id`, and `resolution` cannot be used in `sort`. **Note:** `account_id`, `inquiry_id`, and `tag_id` match against the 50 most recently added accounts, inquiries, and tags on a case. A case related to more than 50 of one of these will not match on the older ones. Reference: https://docs.withpersona.com/api-reference/cases/search-cases ## 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` (CasesSearchPostParametersPage, 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 a Cases_search-cases_Request. - `query` (CasesSearchPostRequestBodyContentApplicationJsonSchemaQuery, 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` (CasesSearchPostRequestBodyContentApplicationJsonSchemaSort, optional) — Sort configuration for results - `page` (CasesSearchPostRequestBodyContentApplicationJsonSchemaPage, optional) — Pagination parameters ## Response ### 200 This endpoint returns a collection of Case objects matching the search criteria. - `data` (list of case, required) — An array of Cases matching the search criteria - `links` (CasesSearchPostResponsesContentApplicationJsonSchemaLinks, required) ## Errors ### 400 Bad Request Error The request was unacceptable, often due to invalid parameters. - `errors` (list of CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 401 Unauthorized Error An invalid API key was provided. - `errors` (list of CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, 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 CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 404 Not Found Error The requested resource doesn’t exist. - `errors` (list of CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 409 Conflict Error The request conflicts with another request, often due to attempting to create a duplicate resource. - `errors` (list of CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, 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 CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 429 Too Many Requests Error Your organization’s rate limit has been exceeded. We recommend an exponential backoff on requests. - `errors` (list of CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ## Types ### CasesSearchPostRequestBodyContentApplicationJsonSchemaQuery 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). ### CasesSearchPostRequestBodyContentApplicationJsonSchemaSort 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). ### CasesSearchPostRequestBodyContentApplicationJsonSchemaPage 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 ### CasesSearchPostParametersPage - `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. ### case A Case object - `type` ("case", optional) - `id` (string, optional) - `attributes` (CaseAttributes, optional) - `relationships` (CaseRelationships, optional) ### CasesSearchPostResponsesContentApplicationJsonSchemaLinks - `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. ### CasesSearchPostResponsesContentApplicationJsonSchemaErrorsItems - `title` (string, optional) - `details` (string, optional) ### CasesSearchPostRequestBodyContentApplicationJsonSchemaQuery0 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) ### CasesSearchPostRequestBodyContentApplicationJsonSchemaQuery1 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) ### CasesSearchPostRequestBodyContentApplicationJsonSchemaQuery2 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) ### CasesSearchPostRequestBodyContentApplicationJsonSchemaQuery3 Attribute predicate - `attribute` (string, required) — The attribute name to filter on (e.g., 'created_at', 'template', 'status', 'fields.priority') - `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` (CasesSearchPostRequestBodyContentApplicationJsonSchemaQueryOneOf3Value, required) — Value to compare against ### CaseAttributes - `status` (string, optional) - `name` (string, optional) - `resolution` (string, optional, nullable) - `created-at` (string, optional) - `updated-at` (string, optional, nullable) - `assigned-at` (string, optional, nullable) - `resolved-at` (string, optional, nullable) - `redacted-at` (string, optional, nullable) - `sla-expires-at` (string, optional, nullable) - `creator-id` (string, optional, nullable) - `creator-type` (string, optional, nullable) — Possible values: - user - workflow-run Do not assume this is a static enumeration; Persona may add new values in the future without a versioned update. - `assignee-id` (string, optional, nullable) - `assigner-id` (string, optional, nullable) - `assigner-type` (string, optional, nullable) — Possible values: - case-assignment-policy - user - workflow-run Do not assume this is a static enumeration; Persona may add new values in the future without a versioned update. - `resolver-id` (string, optional, nullable) - `resolver-type` (string, optional, nullable) — Possible values: - api-key - user - workflow-run Do not assume this is a static enumeration; Persona may add new values in the future without a versioned update. - `updater-id` (string, optional, nullable) - `updater-type` (string, optional, nullable) — Possible values: - api-key - case-assignment-policy - user - workflow-run Do not assume this is a static enumeration; Persona may add new values in the future without a versioned update. - `tags` (list of any, optional) - `fields` (map from string to any, optional) — JSON key-value pairs of field name to field value. Exact schema depends on the configuration of the Case template for this Case. - `attachments` (list of CaseAttributesAttachmentsItems, optional) ### CaseRelationships - `accounts` (CaseRelationshipsAccounts, optional) - `case-comments` (CaseRelationshipsCaseComments, optional) - `case-template` (CaseRelationshipsCaseTemplate, optional) - `case-queue` (CaseRelationshipsCaseQueue, optional) - `inquiries` (CaseRelationshipsInquiries, optional) - `reports` (CaseRelationshipsReports, optional) - `verifications` (CaseRelationshipsVerifications, optional) - `txns` (CaseRelationshipsTxns, optional) ### CasesSearchPostRequestBodyContentApplicationJsonSchemaQueryOneOf3Value Value to compare against ### CaseAttributesAttachmentsItems - `filename` (string, optional) - `url` (string, optional) - `byte-size` (integer, optional) ### CaseRelationshipsAccounts - `data` (list of CaseRelationshipsAccountsDataItems, optional) ### CaseRelationshipsCaseComments - `data` (list of CaseRelationshipsCaseCommentsDataItems, optional) ### CaseRelationshipsCaseTemplate - `data` (CaseRelationshipsCaseTemplateData, optional) ### CaseRelationshipsCaseQueue - `data` (CaseRelationshipsCaseQueueData, optional, nullable) ### CaseRelationshipsInquiries - `data` (list of CaseRelationshipsInquiriesDataItems, optional) ### CaseRelationshipsReports - `data` (list of CaseRelationshipsReportsDataItems, optional) ### CaseRelationshipsVerifications - `data` (list of CaseRelationshipsVerificationsDataItems, optional) ### CaseRelationshipsTxns - `data` (list of CaseRelationshipsTxnsDataItems, optional) ### CaseRelationshipsAccountsDataItems - `id` (string, optional) - `type` ("account", optional) ### CaseRelationshipsCaseCommentsDataItems - `id` (string, optional) - `type` ("case-comment", optional) ### CaseRelationshipsCaseTemplateData - `id` (string, optional) - `type` ("case-template", optional) ### CaseRelationshipsCaseQueueData - `id` (string, optional) - `type` ("case-queue", optional) ### CaseRelationshipsInquiriesDataItems - `id` (string, optional) - `type` ("inquiry", optional) ### CaseRelationshipsReportsDataItems - `id` (string, optional) - `type` (string, optional) ### CaseRelationshipsVerificationsDataItems - `id` (string, optional) - `type` (string, optional) ### CaseRelationshipsTxnsDataItems - `id` (string, optional) - `type` ("transaction", optional) ## Examples ### Success **Response** ```json { "data": [ { "type": "case", "id": "case_ABC123", "attributes": { "status": "open", "name": "KCAS-1", "resolution": null, "created-at": "2025-01-15T10:30:00.000Z", "updated-at": "2025-01-15T14:22:00.000Z", "assigned-at": "2025-01-15T10:35:00.000Z", "resolved-at": null, "redacted-at": null, "sla-expires-at": "2025-01-20T10:30:00.000Z", "creator-id": "case_creator@withpersona.com", "creator-type": "user", "assignee-id": "case_assignee@withpersona.com", "assigner-id": "manager@withpersona.com", "assigner-type": "user", "resolver-id": null, "resolver-type": null, "updater-id": "case_updater@withpersona.com", "updater-type": "user", "tags": [ "urgent", "review-needed" ], "fields": { "amount": { "type": "number", "value": 1000 }, "priority": { "type": "string", "value": "high" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": { "id": "cqueue_XYZ789", "type": "case-queue" } }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } }, { "type": "case", "id": "case_DEF456", "attributes": { "status": "pending", "name": "KCAS-2", "resolution": null, "created-at": "2025-01-14T15:20:00.000Z", "updated-at": "2025-01-14T16:10:00.000Z", "assigned-at": null, "resolved-at": null, "redacted-at": null, "sla-expires-at": null, "creator-id": "api_key_123", "creator-type": "api-key", "assignee-id": null, "assigner-id": null, "assigner-type": null, "resolver-id": null, "resolver-type": null, "updater-id": "api_key_123", "updater-type": "api-key", "tags": [], "fields": { "priority": { "type": "string", "value": "medium" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": null }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } } ], "links": { "prev": null, "next": "/api/v1/cases/search?page%5Bafter%5D=case_DEF456&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Success import requests url = "https://api.withpersona.com/api/v1/cases/search" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Success const url = 'https://api.withpersona.com/api/v1/cases/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/cases/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/cases/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/cases/search") .header("Authorization", "Bearer ") .asString(); ``` ```php Success request('POST', 'https://api.withpersona.com/api/v1/cases/search', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp Success using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/cases/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/cases/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": "resolved" } }, "sort": { "attribute": "created_at", "direction": "asc" }, "page": { "size": 15 } } ``` **Response** ```json { "data": [ { "type": "case", "id": "case_ABC123", "attributes": { "status": "open", "name": "KCAS-1", "resolution": null, "created-at": "2025-01-15T10:30:00.000Z", "updated-at": "2025-01-15T14:22:00.000Z", "assigned-at": "2025-01-15T10:35:00.000Z", "resolved-at": null, "redacted-at": null, "sla-expires-at": "2025-01-20T10:30:00.000Z", "creator-id": "case_creator@withpersona.com", "creator-type": "user", "assignee-id": "case_assignee@withpersona.com", "assigner-id": "manager@withpersona.com", "assigner-type": "user", "resolver-id": null, "resolver-type": null, "updater-id": "case_updater@withpersona.com", "updater-type": "user", "tags": [ "urgent", "review-needed" ], "fields": { "amount": { "type": "number", "value": 1000 }, "priority": { "type": "string", "value": "high" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": { "id": "cqueue_XYZ789", "type": "case-queue" } }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } }, { "type": "case", "id": "case_DEF456", "attributes": { "status": "pending", "name": "KCAS-2", "resolution": null, "created-at": "2025-01-14T15:20:00.000Z", "updated-at": "2025-01-14T16:10:00.000Z", "assigned-at": null, "resolved-at": null, "redacted-at": null, "sla-expires-at": null, "creator-id": "api_key_123", "creator-type": "api-key", "assignee-id": null, "assigner-id": null, "assigner-type": null, "resolver-id": null, "resolver-type": null, "updater-id": "api_key_123", "updater-type": "api-key", "tags": [], "fields": { "priority": { "type": "string", "value": "medium" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": null }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } } ], "links": { "prev": null, "next": "/api/v1/cases/search?page%5Bafter%5D=case_DEF456&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Simple query import requests url = "https://api.withpersona.com/api/v1/cases/search" payload = { "query": { "not": { "attribute": "status", "operator": "eq", "value": "resolved" } }, "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/cases/search'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"query":{"not":{"attribute":"status","operator":"eq","value":"resolved"}},"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/cases/search" payload := strings.NewReader("{\n \"query\": {\n \"not\": {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"resolved\"\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/cases/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\": \"resolved\"\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/cases/search") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"query\": {\n \"not\": {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"resolved\"\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/cases/search', [ 'body' => '{ "query": { "not": { "attribute": "status", "operator": "eq", "value": "resolved" } }, "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/cases/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\": \"resolved\"\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": "resolved" ]], "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/cases/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": "template", "operator": "eq", "value": "ctmpl_ABC123" }, { "or": [ { "attribute": "status", "operator": "eq", "value": "open" }, { "attribute": "status", "operator": "eq", "value": "pending" } ] } ] }, "sort": { "attribute": "created_at", "direction": "desc" }, "page": { "size": 15 } } ``` **Response** ```json { "data": [ { "type": "case", "id": "case_ABC123", "attributes": { "status": "open", "name": "KCAS-1", "resolution": null, "created-at": "2025-01-15T10:30:00.000Z", "updated-at": "2025-01-15T14:22:00.000Z", "assigned-at": "2025-01-15T10:35:00.000Z", "resolved-at": null, "redacted-at": null, "sla-expires-at": "2025-01-20T10:30:00.000Z", "creator-id": "case_creator@withpersona.com", "creator-type": "user", "assignee-id": "case_assignee@withpersona.com", "assigner-id": "manager@withpersona.com", "assigner-type": "user", "resolver-id": null, "resolver-type": null, "updater-id": "case_updater@withpersona.com", "updater-type": "user", "tags": [ "urgent", "review-needed" ], "fields": { "amount": { "type": "number", "value": 1000 }, "priority": { "type": "string", "value": "high" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": { "id": "cqueue_XYZ789", "type": "case-queue" } }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } }, { "type": "case", "id": "case_DEF456", "attributes": { "status": "pending", "name": "KCAS-2", "resolution": null, "created-at": "2025-01-14T15:20:00.000Z", "updated-at": "2025-01-14T16:10:00.000Z", "assigned-at": null, "resolved-at": null, "redacted-at": null, "sla-expires-at": null, "creator-id": "api_key_123", "creator-type": "api-key", "assignee-id": null, "assigner-id": null, "assigner-type": null, "resolver-id": null, "resolver-type": null, "updater-id": "api_key_123", "updater-type": "api-key", "tags": [], "fields": { "priority": { "type": "string", "value": "medium" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": null }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } } ], "links": { "prev": null, "next": "/api/v1/cases/search?page%5Bafter%5D=case_DEF456&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Complex boolean query import requests url = "https://api.withpersona.com/api/v1/cases/search" payload = { "query": { "and": [{ "attribute": "template", "operator": "eq", "value": "ctmpl_ABC123" }, { "or": [ { "attribute": "status", "operator": "eq", "value": "open" }, { "attribute": "status", "operator": "eq", "value": "pending" } ] }] }, "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/cases/search'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"query":{"and":[{"attribute":"template","operator":"eq","value":"ctmpl_ABC123"},{"or":[{"attribute":"status","operator":"eq","value":"open"},{"attribute":"status","operator":"eq","value":"pending"}]}]},"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/cases/search" payload := strings.NewReader("{\n \"query\": {\n \"and\": [\n {\n \"attribute\": \"template\",\n \"operator\": \"eq\",\n \"value\": \"ctmpl_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"open\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"pending\"\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/cases/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\": \"template\",\n \"operator\": \"eq\",\n \"value\": \"ctmpl_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"open\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"pending\"\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/cases/search") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"query\": {\n \"and\": [\n {\n \"attribute\": \"template\",\n \"operator\": \"eq\",\n \"value\": \"ctmpl_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"open\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"pending\"\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/cases/search', [ 'body' => '{ "query": { "and": [ { "attribute": "template", "operator": "eq", "value": "ctmpl_ABC123" }, { "or": [ { "attribute": "status", "operator": "eq", "value": "open" }, { "attribute": "status", "operator": "eq", "value": "pending" } ] } ] }, "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/cases/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\": \"template\",\n \"operator\": \"eq\",\n \"value\": \"ctmpl_ABC123\"\n },\n {\n \"or\": [\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"open\"\n },\n {\n \"attribute\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"pending\"\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": "template", "operator": "eq", "value": "ctmpl_ABC123" ], ["or": [ [ "attribute": "status", "operator": "eq", "value": "open" ], [ "attribute": "status", "operator": "eq", "value": "pending" ] ]]]], "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/cases/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 cases) **Request** ```json { "page": { "size": 15 } } ``` **Response** ```json { "data": [ { "type": "case", "id": "case_ABC123", "attributes": { "status": "open", "name": "KCAS-1", "resolution": null, "created-at": "2025-01-15T10:30:00.000Z", "updated-at": "2025-01-15T14:22:00.000Z", "assigned-at": "2025-01-15T10:35:00.000Z", "resolved-at": null, "redacted-at": null, "sla-expires-at": "2025-01-20T10:30:00.000Z", "creator-id": "case_creator@withpersona.com", "creator-type": "user", "assignee-id": "case_assignee@withpersona.com", "assigner-id": "manager@withpersona.com", "assigner-type": "user", "resolver-id": null, "resolver-type": null, "updater-id": "case_updater@withpersona.com", "updater-type": "user", "tags": [ "urgent", "review-needed" ], "fields": { "amount": { "type": "number", "value": 1000 }, "priority": { "type": "string", "value": "high" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": { "id": "cqueue_XYZ789", "type": "case-queue" } }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } }, { "type": "case", "id": "case_DEF456", "attributes": { "status": "pending", "name": "KCAS-2", "resolution": null, "created-at": "2025-01-14T15:20:00.000Z", "updated-at": "2025-01-14T16:10:00.000Z", "assigned-at": null, "resolved-at": null, "redacted-at": null, "sla-expires-at": null, "creator-id": "api_key_123", "creator-type": "api-key", "assignee-id": null, "assigner-id": null, "assigner-type": null, "resolver-id": null, "resolver-type": null, "updater-id": "api_key_123", "updater-type": "api-key", "tags": [], "fields": { "priority": { "type": "string", "value": "medium" } }, "attachments": [] }, "relationships": { "accounts": { "data": [] }, "case-comments": { "data": [] }, "case-template": { "data": { "id": "ctmpl_ABC123", "type": "case-template" } }, "case-queue": { "data": null }, "inquiries": { "data": [] }, "reports": { "data": [] }, "verifications": { "data": [] }, "txns": { "data": [] } } } ], "links": { "prev": null, "next": "/api/v1/cases/search?page%5Bafter%5D=case_DEF456&page%5Bsize%5D=10" } } ``` **SDK Code** ```python Empty query (all cases) import requests url = "https://api.withpersona.com/api/v1/cases/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 cases) const url = 'https://api.withpersona.com/api/v1/cases/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 cases) package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/cases/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 cases) require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/cases/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 cases) import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/cases/search") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"page\": {\n \"size\": 15\n }\n}") .asString(); ``` ```php Empty query (all cases) request('POST', 'https://api.withpersona.com/api/v1/cases/search', [ 'body' => '{ "page": { "size": 15 } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Empty query (all cases) using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/cases/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 cases) 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/cases/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() ```