> For the complete documentation index, see [llms.txt](https://docs.concurrence.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.concurrence.com/api-reference/readme/platform/workspace-data-queries.md).

# Workspace Data Queries

## List workspace data queries

> List every registered query for a workspace. Sort via repeated \`sort\_by\` query params; each entry is \`+field\` or \`-field\` (allowed field: deployed\_at). Default: \`-deployed\_at\`. Cursor opaque — round-trip \`continuation\_token\` unchanged with the same \`sort\_by\`. Requires \`Workspace.view\` permission.

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Workspace Data Queries"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_data_queries__list_workspace_data_queries__Response":{"properties":{"items":{"items":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__list_workspace_data_queries__Response__Item"},"type":"array","title":"Items"},"has_more":{"type":"boolean","title":"Has More"},"continuation_token":{"title":"Continuation Token"}},"type":"object","required":["items","has_more"],"title":"Response"},"src__routes__workspace_data_queries__list_workspace_data_queries__Response__Item":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"description":{"type":"string","title":"Description"},"sql_template":{"type":"string","title":"Sql Template"},"parameter_count":{"type":"integer","title":"Parameter Count"},"timeout_ms":{"type":"integer","title":"Timeout Ms"},"declarations":{"$ref":"#/components/schemas/DataQueryDeclarations","description":"What the query's author declares about its calls. A declaration it never made is null."},"last_invoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Invoked At"},"deployed_at":{"type":"string","format":"date-time","title":"Deployed At"},"deployed_by":{"type":"string","format":"uuid","title":"Deployed By"}},"type":"object","required":["id","name","description","sql_template","parameter_count","timeout_ms","declarations","deployed_at","deployed_by"],"title":"Item"},"DataQueryDeclarations":{"properties":{"reads":{"anyOf":[{"$ref":"#/components/schemas/EndpointReads"},{"type":"null"}],"description":"Whose patient record a call returns, and how the call names that patient: the one its\nparameters name (``params``, each one of the query's ``parameters``), the ones its rows hold\n(``response``, where ``records`` points into the rows the query returns, a list of objects keyed\nby column, so the empty pointer is every row), or none (``none``: practice data, such as\narticles, locations or opening hours). Null when undeclared: the voice agent then counts a\ncall's result as one that may hold a patient's record."},"freshness":{"anyOf":[{"$ref":"#/components/schemas/DataFreshness"},{"type":"null"}],"description":"None: rows are returned as they are, with no staleness."}},"type":"object","title":"DataQueryDeclarations","description":"What a data query's author declares about its calls. Each declaration is optional, and one\nleft out is unknown, never a default the platform guesses. A reader ignores a key it doesn't\nknow, so a later declaration never breaks an older reader."},"EndpointReads":{"oneOf":[{"$ref":"#/components/schemas/PatientInParams"},{"$ref":"#/components/schemas/PatientsInResponse"},{"$ref":"#/components/schemas/NoPatient"}],"discriminator":{"propertyName":"patient_in","mapping":{"none":"#/components/schemas/NoPatient","params":"#/components/schemas/PatientInParams","response":"#/components/schemas/PatientsInResponse"}}},"PatientInParams":{"properties":{"patient_in":{"type":"string","const":"params","title":"Patient In"},"params":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","maxItems":8,"minItems":1,"title":"Params","description":"The input parameters that name the patient, by an identifier their record on file carries:\nits entity_id, MRN, FHIR id or source system id. Each one is a property of the endpoint's\n``input_schema``. On a service that verifies its callers through its own integration, they name\nthe patient by the identifier its verifier returns."}},"type":"object","required":["patient_in","params"],"title":"PatientInParams","description":"A call returns the record of the patient its request names."},"PatientsInResponse":{"properties":{"patient_in":{"type":"string","const":"response","title":"Patient In"},"records":{"type":"string","maxLength":512,"title":"Records","description":"RFC 6901 JSON Pointer into the parsed response body, before any template, to the records:\na list of records, or one record. ``/patients`` is the list under ``patients``, and the empty\npointer is the whole body. A held call keeps only the records a caller may hear, and nothing\nbeside them, and the template renders those."},"patient":{"type":"string","maxLength":512,"minLength":1,"title":"Patient","description":"RFC 6901 JSON Pointer into each record to the identifier of the patient it belongs to, one\ntheir record on file carries, such as ``/patient_id``. On a service that verifies its callers\nthrough its own integration, the identifier its verifier returns."}},"type":"object","required":["patient_in","records","patient"],"title":"PatientsInResponse","description":"A call's response holds the patient records it found: a search, or a read by some other key."},"NoPatient":{"properties":{"patient_in":{"type":"string","const":"none","title":"Patient In"}},"type":"object","required":["patient_in"],"title":"NoPatient","description":"A call returns no patient's record: practice data, such as open slots, providers or articles."},"DataFreshness":{"properties":{"as_of_column":{"type":"string","maxLength":63,"pattern":"^[a-z][a-z0-9_]*$","title":"As Of Column","description":"The result column holding when the row was last verified (a timestamp or ISO date). A lowercase\nidentifier, so the SQL names it without quoting."},"max_age_days":{"type":"integer","maximum":365,"minimum":1,"title":"Max Age Days","description":"A row older than this, or with no value, is stale."}},"type":"object","required":["as_of_column","max_age_days"],"title":"DataFreshness","description":"How fresh a query's rows must be to be stated as current."}}},"paths":{"/v1/{workspace_id}/data_queries":{"get":{"tags":["Workspace Data Queries"],"summary":"List workspace data queries","description":"List every registered query for a workspace. Sort via repeated `sort_by` query params; each entry is `+field` or `-field` (allowed field: deployed_at). Default: `-deployed_at`. Cursor opaque — round-trip `continuation_token` unchanged with the same `sort_by`. Requires `Workspace.view` permission.","operationId":"list-workspace-data-queries","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"sort_by","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"},"description":"Sort axes, applied left-to-right. ``+field`` ascending, ``-field``\ndescending. Defaults to ``[(\"deployed_at\", -1)]`` (newest first).","default":[],"title":"Sort By"},"description":"Sort axes, applied left-to-right. ``+field`` ascending, ``-field``\ndescending. Defaults to ``[(\"deployed_at\", -1)]`` (newest first)."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"exclusiveMinimum":0,"description":"Maximum number of queries to return per page.","default":50,"title":"Limit"},"description":"Maximum number of queries to return per page."},{"name":"continuation_token","in":"query","required":false,"schema":{"description":"Opaque continuation token from a prior response. Treat as a\nblack box — the server decodes it.","title":"Continuation Token"},"description":"Opaque continuation token from a prior response. Treat as a\nblack box — the server decodes it."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__list_workspace_data_queries__Response"}}}},"401":{"description":"Missing or invalid API key."},"403":{"description":"Insufficient permissions."},"422":{"description":"Query parameter failed validation or continuation_token is unparseable."}}}}}}
```

## POST /v1/{workspace\_id}/data\_queries

> Create Workspace Data Query

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Workspace Data Queries"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_data_queries__create_workspace_data_query__Request":{"properties":{"name":{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Name"},"description":{"type":"string","maxLength":2048,"minLength":1,"title":"Description"},"sql_template":{"type":"string","maxLength":8192,"minLength":1,"title":"Sql Template"},"parameters":{"items":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__create_workspace_data_query__Request__Parameter"},"type":"array","maxItems":32,"title":"Parameters"},"timeout_ms":{"type":"integer","maximum":30000,"minimum":100,"title":"Timeout Ms","default":5000},"declarations":{"$ref":"#/components/schemas/DataQueryDeclarationsBody","description":"What the query's author declares about its calls. A declaration left out is undeclared. A query\nover practice data, such as FAQ articles, locations or hours, declares `reads` of\n`{\"patient_in\": \"none\"}`, so the voice agent never counts its result as a patient's record."}},"additionalProperties":false,"type":"object","required":["name","description","sql_template"],"title":"Request","description":"A new workspace data query: a SQL template and the parameters it declares.\n\nThe SQL template must be one SELECT, INSERT, UPDATE, DELETE or TRUNCATE statement that calls only built-in\nfunctions which run no SQL text and change no session state. Its `:name` placeholders and the declared\nparameters must be the same set of names: each placeholder is declared, and each declared parameter appears\nin the template. A parameter's `default`, when set, must be of its declared `type`. A body that breaks any\nof these rules returns 422."},"src__routes__workspace_data_queries__create_workspace_data_query__Request__Parameter":{"properties":{"name":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Name"},"type":{"type":"string","enum":["string","integer","number","boolean"],"title":"Type"},"description":{"type":"string","maxLength":512,"minLength":1,"title":"Description"},"default":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"title":"Default"},"authorization_binding":{"anyOf":[{"$ref":"#/components/schemas/RoleGrantKeysBinding"},{"type":"null"}]},"authorization_binding_test_value":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Authorization Binding Test Value","description":"Canonical CSV resource keys used only by trusted playground execution when no live authorization block exists."}},"additionalProperties":false,"type":"object","required":["name","type","description"],"title":"Parameter","description":"One parameter the query declares."},"RoleGrantKeysBinding":{"properties":{"source":{"type":"string","const":"role_grant_resource_keys","title":"Source"},"resource_type":{"type":"string","const":"kb_scope","title":"Resource Type"},"access":{"type":"string","const":"read","title":"Access","default":"read"},"encoding":{"type":"string","const":"csv","title":"Encoding","default":"csv"}},"additionalProperties":false,"type":"object","required":["source","resource_type"],"title":"RoleGrantKeysBinding","description":"Binds a SQL parameter to the authorization of the turn, so the platform fills it in and the caller does not.\n\nAt execution the platform discards any caller value, takes the resource keys the turn's authorization\nholds for `resource_type` and `access`, encodes them as `encoding`, and binds the result to the parameter's\n`:name` placeholder. Neither the model nor the caller sees or supplies it. In a trusted test run with no live\nauthorization, the parameter's `authorization_binding_test_value` is bound instead. A bound parameter has no\n`default`. Only the values shown in the schema are accepted."},"DataQueryDeclarationsBody":{"properties":{"reads":{"anyOf":[{"$ref":"#/components/schemas/EndpointReads"},{"type":"null"}],"description":"Whose patient record a call returns, and how the call names that patient: the one its\nparameters name (``params``, each one of the query's ``parameters``), the ones its rows hold\n(``response``, where ``records`` points into the rows the query returns, a list of objects keyed\nby column, so the empty pointer is every row), or none (``none``: practice data, such as\narticles, locations or opening hours). Null when undeclared: the voice agent then counts a\ncall's result as one that may hold a patient's record."},"freshness":{"anyOf":[{"$ref":"#/components/schemas/DataFreshnessBody"},{"type":"null"}],"description":"None: rows are returned as they are, with no staleness."}},"additionalProperties":false,"type":"object","title":"DataQueryDeclarationsBody","description":"The declarations a create or PATCH names. One a data query can't make, such as an endpoint's\n``writes`` or a misspelled ``reads``, is a 422, never a key dropped with a 200. Only the write\nboundary refuses one: a reader ignores a key it doesn't know (``DataQueryDeclarations``)."},"EndpointReads":{"oneOf":[{"$ref":"#/components/schemas/PatientInParams"},{"$ref":"#/components/schemas/PatientsInResponse"},{"$ref":"#/components/schemas/NoPatient"}],"discriminator":{"propertyName":"patient_in","mapping":{"none":"#/components/schemas/NoPatient","params":"#/components/schemas/PatientInParams","response":"#/components/schemas/PatientsInResponse"}}},"PatientInParams":{"properties":{"patient_in":{"type":"string","const":"params","title":"Patient In"},"params":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","maxItems":8,"minItems":1,"title":"Params","description":"The input parameters that name the patient, by an identifier their record on file carries:\nits entity_id, MRN, FHIR id or source system id. Each one is a property of the endpoint's\n``input_schema``. On a service that verifies its callers through its own integration, they name\nthe patient by the identifier its verifier returns."}},"type":"object","required":["patient_in","params"],"title":"PatientInParams","description":"A call returns the record of the patient its request names."},"PatientsInResponse":{"properties":{"patient_in":{"type":"string","const":"response","title":"Patient In"},"records":{"type":"string","maxLength":512,"title":"Records","description":"RFC 6901 JSON Pointer into the parsed response body, before any template, to the records:\na list of records, or one record. ``/patients`` is the list under ``patients``, and the empty\npointer is the whole body. A held call keeps only the records a caller may hear, and nothing\nbeside them, and the template renders those."},"patient":{"type":"string","maxLength":512,"minLength":1,"title":"Patient","description":"RFC 6901 JSON Pointer into each record to the identifier of the patient it belongs to, one\ntheir record on file carries, such as ``/patient_id``. On a service that verifies its callers\nthrough its own integration, the identifier its verifier returns."}},"type":"object","required":["patient_in","records","patient"],"title":"PatientsInResponse","description":"A call's response holds the patient records it found: a search, or a read by some other key."},"NoPatient":{"properties":{"patient_in":{"type":"string","const":"none","title":"Patient In"}},"type":"object","required":["patient_in"],"title":"NoPatient","description":"A call returns no patient's record: practice data, such as open slots, providers or articles."},"DataFreshnessBody":{"properties":{"as_of_column":{"type":"string","maxLength":63,"pattern":"^[a-z][a-z0-9_]*$","title":"As Of Column","description":"The result column holding when the row was last verified (a timestamp or ISO date). A lowercase\nidentifier, so the SQL names it without quoting."},"max_age_days":{"type":"integer","maximum":365,"minimum":1,"title":"Max Age Days","description":"A row older than this, or with no value, is stale."}},"additionalProperties":false,"type":"object","required":["as_of_column","max_age_days"],"title":"DataFreshnessBody","description":"The freshness a create or PATCH names. A key it doesn't have, such as a unit, is a 422."},"WorkspaceDataQueryItem":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"description":{"type":"string","title":"Description"},"sql_template":{"type":"string","title":"Sql Template"},"parameters":{"items":{"$ref":"#/components/schemas/StoredParameter"},"type":"array","title":"Parameters"},"timeout_ms":{"type":"integer","title":"Timeout Ms"},"declarations":{"$ref":"#/components/schemas/DataQueryDeclarations","description":"What the query's author declares about its calls. A declaration it never made is null."},"last_invoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Invoked At"},"deployed_at":{"type":"string","format":"date-time","title":"Deployed At"},"deployed_by":{"type":"string","format":"uuid","title":"Deployed By"}},"type":"object","required":["id","name","description","sql_template","parameters","timeout_ms","declarations","deployed_at","deployed_by"],"title":"WorkspaceDataQueryItem","description":"Wire shape for the response of every read + create/update handler.\n\n``id`` (UUID) is the stable handle — every URL except list takes it.\n``name`` is the workspace-visible label (UNIQUE per workspace) and is\nstill what the LLM tool registry keys on (``wsq_<name>``), but it is\nnot the route identifier.\n\n``input_schema`` is deliberately NOT exposed — it is fully derivable\nfrom ``parameters[]``. UI consumers can build the JSON Schema view\nlocally if they need it."},"StoredParameter":{"properties":{"name":{"type":"string","title":"Name"},"type":{"type":"string","enum":["string","integer","number","boolean"],"title":"Type"},"description":{"type":"string","title":"Description"},"default":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"title":"Default"},"authorization_binding":{"anyOf":[{"$ref":"#/components/schemas/RoleGrantKeysBinding"},{"type":"null"}]},"authorization_binding_test_value":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Authorization Binding Test Value","description":"Canonical CSV resource keys used only by trusted playground execution when no live authorization block exists."}},"additionalProperties":false,"type":"object","required":["name","type","description"],"title":"StoredParameter","description":"One typed input parameter of a workspace data query.\n\nA null `default` marks the parameter as required: a call that omits it is refused, unless the parameter is\nbound by `authorization_binding`. Otherwise an omitted argument takes the default."},"DataQueryDeclarations":{"properties":{"reads":{"anyOf":[{"$ref":"#/components/schemas/EndpointReads"},{"type":"null"}],"description":"Whose patient record a call returns, and how the call names that patient: the one its\nparameters name (``params``, each one of the query's ``parameters``), the ones its rows hold\n(``response``, where ``records`` points into the rows the query returns, a list of objects keyed\nby column, so the empty pointer is every row), or none (``none``: practice data, such as\narticles, locations or opening hours). Null when undeclared: the voice agent then counts a\ncall's result as one that may hold a patient's record."},"freshness":{"anyOf":[{"$ref":"#/components/schemas/DataFreshness"},{"type":"null"}],"description":"None: rows are returned as they are, with no staleness."}},"type":"object","title":"DataQueryDeclarations","description":"What a data query's author declares about its calls. Each declaration is optional, and one\nleft out is unknown, never a default the platform guesses. A reader ignores a key it doesn't\nknow, so a later declaration never breaks an older reader."},"DataFreshness":{"properties":{"as_of_column":{"type":"string","maxLength":63,"pattern":"^[a-z][a-z0-9_]*$","title":"As Of Column","description":"The result column holding when the row was last verified (a timestamp or ISO date). A lowercase\nidentifier, so the SQL names it without quoting."},"max_age_days":{"type":"integer","maximum":365,"minimum":1,"title":"Max Age Days","description":"A row older than this, or with no value, is stale."}},"type":"object","required":["as_of_column","max_age_days"],"title":"DataFreshness","description":"How fresh a query's rows must be to be stated as current."}}},"paths":{"/v1/{workspace_id}/data_queries":{"post":{"tags":["Workspace Data Queries"],"summary":"Create Workspace Data Query","operationId":"create-workspace-data-query","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__create_workspace_data_query__Request"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceDataQueryItem"}}}},"409":{"description":"A workspace data query with the given name already exists"},"422":{"description":"Validation or precondition failure"}},"parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}}]}}}}
```

## GET /v1/{workspace\_id}/data\_queries/{query\_id}

> Get Workspace Data Query

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Workspace Data Queries"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"WorkspaceDataQueryItem":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"description":{"type":"string","title":"Description"},"sql_template":{"type":"string","title":"Sql Template"},"parameters":{"items":{"$ref":"#/components/schemas/StoredParameter"},"type":"array","title":"Parameters"},"timeout_ms":{"type":"integer","title":"Timeout Ms"},"declarations":{"$ref":"#/components/schemas/DataQueryDeclarations","description":"What the query's author declares about its calls. A declaration it never made is null."},"last_invoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Invoked At"},"deployed_at":{"type":"string","format":"date-time","title":"Deployed At"},"deployed_by":{"type":"string","format":"uuid","title":"Deployed By"}},"type":"object","required":["id","name","description","sql_template","parameters","timeout_ms","declarations","deployed_at","deployed_by"],"title":"WorkspaceDataQueryItem","description":"Wire shape for the response of every read + create/update handler.\n\n``id`` (UUID) is the stable handle — every URL except list takes it.\n``name`` is the workspace-visible label (UNIQUE per workspace) and is\nstill what the LLM tool registry keys on (``wsq_<name>``), but it is\nnot the route identifier.\n\n``input_schema`` is deliberately NOT exposed — it is fully derivable\nfrom ``parameters[]``. UI consumers can build the JSON Schema view\nlocally if they need it."},"StoredParameter":{"properties":{"name":{"type":"string","title":"Name"},"type":{"type":"string","enum":["string","integer","number","boolean"],"title":"Type"},"description":{"type":"string","title":"Description"},"default":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"title":"Default"},"authorization_binding":{"anyOf":[{"$ref":"#/components/schemas/RoleGrantKeysBinding"},{"type":"null"}]},"authorization_binding_test_value":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Authorization Binding Test Value","description":"Canonical CSV resource keys used only by trusted playground execution when no live authorization block exists."}},"additionalProperties":false,"type":"object","required":["name","type","description"],"title":"StoredParameter","description":"One typed input parameter of a workspace data query.\n\nA null `default` marks the parameter as required: a call that omits it is refused, unless the parameter is\nbound by `authorization_binding`. Otherwise an omitted argument takes the default."},"RoleGrantKeysBinding":{"properties":{"source":{"type":"string","const":"role_grant_resource_keys","title":"Source"},"resource_type":{"type":"string","const":"kb_scope","title":"Resource Type"},"access":{"type":"string","const":"read","title":"Access","default":"read"},"encoding":{"type":"string","const":"csv","title":"Encoding","default":"csv"}},"additionalProperties":false,"type":"object","required":["source","resource_type"],"title":"RoleGrantKeysBinding","description":"Binds a SQL parameter to the authorization of the turn, so the platform fills it in and the caller does not.\n\nAt execution the platform discards any caller value, takes the resource keys the turn's authorization\nholds for `resource_type` and `access`, encodes them as `encoding`, and binds the result to the parameter's\n`:name` placeholder. Neither the model nor the caller sees or supplies it. In a trusted test run with no live\nauthorization, the parameter's `authorization_binding_test_value` is bound instead. A bound parameter has no\n`default`. Only the values shown in the schema are accepted."},"DataQueryDeclarations":{"properties":{"reads":{"anyOf":[{"$ref":"#/components/schemas/EndpointReads"},{"type":"null"}],"description":"Whose patient record a call returns, and how the call names that patient: the one its\nparameters name (``params``, each one of the query's ``parameters``), the ones its rows hold\n(``response``, where ``records`` points into the rows the query returns, a list of objects keyed\nby column, so the empty pointer is every row), or none (``none``: practice data, such as\narticles, locations or opening hours). Null when undeclared: the voice agent then counts a\ncall's result as one that may hold a patient's record."},"freshness":{"anyOf":[{"$ref":"#/components/schemas/DataFreshness"},{"type":"null"}],"description":"None: rows are returned as they are, with no staleness."}},"type":"object","title":"DataQueryDeclarations","description":"What a data query's author declares about its calls. Each declaration is optional, and one\nleft out is unknown, never a default the platform guesses. A reader ignores a key it doesn't\nknow, so a later declaration never breaks an older reader."},"EndpointReads":{"oneOf":[{"$ref":"#/components/schemas/PatientInParams"},{"$ref":"#/components/schemas/PatientsInResponse"},{"$ref":"#/components/schemas/NoPatient"}],"discriminator":{"propertyName":"patient_in","mapping":{"none":"#/components/schemas/NoPatient","params":"#/components/schemas/PatientInParams","response":"#/components/schemas/PatientsInResponse"}}},"PatientInParams":{"properties":{"patient_in":{"type":"string","const":"params","title":"Patient In"},"params":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","maxItems":8,"minItems":1,"title":"Params","description":"The input parameters that name the patient, by an identifier their record on file carries:\nits entity_id, MRN, FHIR id or source system id. Each one is a property of the endpoint's\n``input_schema``. On a service that verifies its callers through its own integration, they name\nthe patient by the identifier its verifier returns."}},"type":"object","required":["patient_in","params"],"title":"PatientInParams","description":"A call returns the record of the patient its request names."},"PatientsInResponse":{"properties":{"patient_in":{"type":"string","const":"response","title":"Patient In"},"records":{"type":"string","maxLength":512,"title":"Records","description":"RFC 6901 JSON Pointer into the parsed response body, before any template, to the records:\na list of records, or one record. ``/patients`` is the list under ``patients``, and the empty\npointer is the whole body. A held call keeps only the records a caller may hear, and nothing\nbeside them, and the template renders those."},"patient":{"type":"string","maxLength":512,"minLength":1,"title":"Patient","description":"RFC 6901 JSON Pointer into each record to the identifier of the patient it belongs to, one\ntheir record on file carries, such as ``/patient_id``. On a service that verifies its callers\nthrough its own integration, the identifier its verifier returns."}},"type":"object","required":["patient_in","records","patient"],"title":"PatientsInResponse","description":"A call's response holds the patient records it found: a search, or a read by some other key."},"NoPatient":{"properties":{"patient_in":{"type":"string","const":"none","title":"Patient In"}},"type":"object","required":["patient_in"],"title":"NoPatient","description":"A call returns no patient's record: practice data, such as open slots, providers or articles."},"DataFreshness":{"properties":{"as_of_column":{"type":"string","maxLength":63,"pattern":"^[a-z][a-z0-9_]*$","title":"As Of Column","description":"The result column holding when the row was last verified (a timestamp or ISO date). A lowercase\nidentifier, so the SQL names it without quoting."},"max_age_days":{"type":"integer","maximum":365,"minimum":1,"title":"Max Age Days","description":"A row older than this, or with no value, is stale."}},"type":"object","required":["as_of_column","max_age_days"],"title":"DataFreshness","description":"How fresh a query's rows must be to be stated as current."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/data_queries/{query_id}":{"get":{"tags":["Workspace Data Queries"],"summary":"Get Workspace Data Query","operationId":"get-workspace-data-query","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"query_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Query Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceDataQueryItem"}}}},"404":{"description":"Workspace data query not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## DELETE /v1/{workspace\_id}/data\_queries/{query\_id}

> Delete Workspace Data Query

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Workspace Data Queries"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/data_queries/{query_id}":{"delete":{"tags":["Workspace Data Queries"],"summary":"Delete Workspace Data Query","operationId":"delete-workspace-data-query","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"query_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Query Id"}}],"responses":{"204":{"description":"Successful Response"},"404":{"description":"Workspace data query not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## PATCH /v1/{workspace\_id}/data\_queries/{query\_id}

> Update Workspace Data Query

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Workspace Data Queries"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_data_queries__update_workspace_data_query__Request":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$"},{"type":"null"}],"title":"Name"},"description":{"anyOf":[{"type":"string","maxLength":2048,"minLength":1},{"type":"null"}],"title":"Description"},"sql_template":{"anyOf":[{"type":"string","maxLength":8192,"minLength":1},{"type":"null"}],"title":"Sql Template"},"parameters":{"anyOf":[{"items":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__update_workspace_data_query__Request__Parameter"},"type":"array","maxItems":32},{"type":"null"}],"title":"Parameters"},"timeout_ms":{"anyOf":[{"type":"integer","maximum":30000,"minimum":100},{"type":"null"}],"title":"Timeout Ms"},"declarations":{"anyOf":[{"$ref":"#/components/schemas/DataQueryDeclarationsBody"},{"type":"null"}],"description":"The declarations to change. Each one named replaces the stored one (`null` undeclares it), and\none left out keeps what is stored."}},"additionalProperties":false,"type":"object","title":"Request","description":"A change to a workspace data query. A field left out, or sent as null, keeps its stored value; inside\n`declarations`, a key sent as null removes that declaration. `parameters`, when sent, replaces the whole list,\nand `[]` clears it.\n\nThe SQL template and parameters are checked as they will stand after the change, by the same rules as a new\nquery: the template must be one SELECT, INSERT, UPDATE, DELETE or TRUNCATE statement that calls only built-in\nfunctions which run no SQL text and change no session state, its `:name` placeholders must be the same set of\nnames as the declared parameters, and a parameter's `default`, when set, must be of its declared `type`. A body\nthat breaks any of these rules returns 422."},"src__routes__workspace_data_queries__update_workspace_data_query__Request__Parameter":{"properties":{"name":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Name"},"type":{"type":"string","enum":["string","integer","number","boolean"],"title":"Type"},"description":{"type":"string","maxLength":512,"minLength":1,"title":"Description"},"default":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"title":"Default"},"authorization_binding":{"anyOf":[{"$ref":"#/components/schemas/RoleGrantKeysBinding"},{"type":"null"}]},"authorization_binding_test_value":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Authorization Binding Test Value","description":"Canonical CSV resource keys used only by trusted playground execution when no live authorization block exists."}},"additionalProperties":false,"type":"object","required":["name","type","description"],"title":"Parameter","description":"One parameter the query declares."},"RoleGrantKeysBinding":{"properties":{"source":{"type":"string","const":"role_grant_resource_keys","title":"Source"},"resource_type":{"type":"string","const":"kb_scope","title":"Resource Type"},"access":{"type":"string","const":"read","title":"Access","default":"read"},"encoding":{"type":"string","const":"csv","title":"Encoding","default":"csv"}},"additionalProperties":false,"type":"object","required":["source","resource_type"],"title":"RoleGrantKeysBinding","description":"Binds a SQL parameter to the authorization of the turn, so the platform fills it in and the caller does not.\n\nAt execution the platform discards any caller value, takes the resource keys the turn's authorization\nholds for `resource_type` and `access`, encodes them as `encoding`, and binds the result to the parameter's\n`:name` placeholder. Neither the model nor the caller sees or supplies it. In a trusted test run with no live\nauthorization, the parameter's `authorization_binding_test_value` is bound instead. A bound parameter has no\n`default`. Only the values shown in the schema are accepted."},"DataQueryDeclarationsBody":{"properties":{"reads":{"anyOf":[{"$ref":"#/components/schemas/EndpointReads"},{"type":"null"}],"description":"Whose patient record a call returns, and how the call names that patient: the one its\nparameters name (``params``, each one of the query's ``parameters``), the ones its rows hold\n(``response``, where ``records`` points into the rows the query returns, a list of objects keyed\nby column, so the empty pointer is every row), or none (``none``: practice data, such as\narticles, locations or opening hours). Null when undeclared: the voice agent then counts a\ncall's result as one that may hold a patient's record."},"freshness":{"anyOf":[{"$ref":"#/components/schemas/DataFreshnessBody"},{"type":"null"}],"description":"None: rows are returned as they are, with no staleness."}},"additionalProperties":false,"type":"object","title":"DataQueryDeclarationsBody","description":"The declarations a create or PATCH names. One a data query can't make, such as an endpoint's\n``writes`` or a misspelled ``reads``, is a 422, never a key dropped with a 200. Only the write\nboundary refuses one: a reader ignores a key it doesn't know (``DataQueryDeclarations``)."},"EndpointReads":{"oneOf":[{"$ref":"#/components/schemas/PatientInParams"},{"$ref":"#/components/schemas/PatientsInResponse"},{"$ref":"#/components/schemas/NoPatient"}],"discriminator":{"propertyName":"patient_in","mapping":{"none":"#/components/schemas/NoPatient","params":"#/components/schemas/PatientInParams","response":"#/components/schemas/PatientsInResponse"}}},"PatientInParams":{"properties":{"patient_in":{"type":"string","const":"params","title":"Patient In"},"params":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","maxItems":8,"minItems":1,"title":"Params","description":"The input parameters that name the patient, by an identifier their record on file carries:\nits entity_id, MRN, FHIR id or source system id. Each one is a property of the endpoint's\n``input_schema``. On a service that verifies its callers through its own integration, they name\nthe patient by the identifier its verifier returns."}},"type":"object","required":["patient_in","params"],"title":"PatientInParams","description":"A call returns the record of the patient its request names."},"PatientsInResponse":{"properties":{"patient_in":{"type":"string","const":"response","title":"Patient In"},"records":{"type":"string","maxLength":512,"title":"Records","description":"RFC 6901 JSON Pointer into the parsed response body, before any template, to the records:\na list of records, or one record. ``/patients`` is the list under ``patients``, and the empty\npointer is the whole body. A held call keeps only the records a caller may hear, and nothing\nbeside them, and the template renders those."},"patient":{"type":"string","maxLength":512,"minLength":1,"title":"Patient","description":"RFC 6901 JSON Pointer into each record to the identifier of the patient it belongs to, one\ntheir record on file carries, such as ``/patient_id``. On a service that verifies its callers\nthrough its own integration, the identifier its verifier returns."}},"type":"object","required":["patient_in","records","patient"],"title":"PatientsInResponse","description":"A call's response holds the patient records it found: a search, or a read by some other key."},"NoPatient":{"properties":{"patient_in":{"type":"string","const":"none","title":"Patient In"}},"type":"object","required":["patient_in"],"title":"NoPatient","description":"A call returns no patient's record: practice data, such as open slots, providers or articles."},"DataFreshnessBody":{"properties":{"as_of_column":{"type":"string","maxLength":63,"pattern":"^[a-z][a-z0-9_]*$","title":"As Of Column","description":"The result column holding when the row was last verified (a timestamp or ISO date). A lowercase\nidentifier, so the SQL names it without quoting."},"max_age_days":{"type":"integer","maximum":365,"minimum":1,"title":"Max Age Days","description":"A row older than this, or with no value, is stale."}},"additionalProperties":false,"type":"object","required":["as_of_column","max_age_days"],"title":"DataFreshnessBody","description":"The freshness a create or PATCH names. A key it doesn't have, such as a unit, is a 422."},"WorkspaceDataQueryItem":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"description":{"type":"string","title":"Description"},"sql_template":{"type":"string","title":"Sql Template"},"parameters":{"items":{"$ref":"#/components/schemas/StoredParameter"},"type":"array","title":"Parameters"},"timeout_ms":{"type":"integer","title":"Timeout Ms"},"declarations":{"$ref":"#/components/schemas/DataQueryDeclarations","description":"What the query's author declares about its calls. A declaration it never made is null."},"last_invoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Invoked At"},"deployed_at":{"type":"string","format":"date-time","title":"Deployed At"},"deployed_by":{"type":"string","format":"uuid","title":"Deployed By"}},"type":"object","required":["id","name","description","sql_template","parameters","timeout_ms","declarations","deployed_at","deployed_by"],"title":"WorkspaceDataQueryItem","description":"Wire shape for the response of every read + create/update handler.\n\n``id`` (UUID) is the stable handle — every URL except list takes it.\n``name`` is the workspace-visible label (UNIQUE per workspace) and is\nstill what the LLM tool registry keys on (``wsq_<name>``), but it is\nnot the route identifier.\n\n``input_schema`` is deliberately NOT exposed — it is fully derivable\nfrom ``parameters[]``. UI consumers can build the JSON Schema view\nlocally if they need it."},"StoredParameter":{"properties":{"name":{"type":"string","title":"Name"},"type":{"type":"string","enum":["string","integer","number","boolean"],"title":"Type"},"description":{"type":"string","title":"Description"},"default":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"title":"Default"},"authorization_binding":{"anyOf":[{"$ref":"#/components/schemas/RoleGrantKeysBinding"},{"type":"null"}]},"authorization_binding_test_value":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Authorization Binding Test Value","description":"Canonical CSV resource keys used only by trusted playground execution when no live authorization block exists."}},"additionalProperties":false,"type":"object","required":["name","type","description"],"title":"StoredParameter","description":"One typed input parameter of a workspace data query.\n\nA null `default` marks the parameter as required: a call that omits it is refused, unless the parameter is\nbound by `authorization_binding`. Otherwise an omitted argument takes the default."},"DataQueryDeclarations":{"properties":{"reads":{"anyOf":[{"$ref":"#/components/schemas/EndpointReads"},{"type":"null"}],"description":"Whose patient record a call returns, and how the call names that patient: the one its\nparameters name (``params``, each one of the query's ``parameters``), the ones its rows hold\n(``response``, where ``records`` points into the rows the query returns, a list of objects keyed\nby column, so the empty pointer is every row), or none (``none``: practice data, such as\narticles, locations or opening hours). Null when undeclared: the voice agent then counts a\ncall's result as one that may hold a patient's record."},"freshness":{"anyOf":[{"$ref":"#/components/schemas/DataFreshness"},{"type":"null"}],"description":"None: rows are returned as they are, with no staleness."}},"type":"object","title":"DataQueryDeclarations","description":"What a data query's author declares about its calls. Each declaration is optional, and one\nleft out is unknown, never a default the platform guesses. A reader ignores a key it doesn't\nknow, so a later declaration never breaks an older reader."},"DataFreshness":{"properties":{"as_of_column":{"type":"string","maxLength":63,"pattern":"^[a-z][a-z0-9_]*$","title":"As Of Column","description":"The result column holding when the row was last verified (a timestamp or ISO date). A lowercase\nidentifier, so the SQL names it without quoting."},"max_age_days":{"type":"integer","maximum":365,"minimum":1,"title":"Max Age Days","description":"A row older than this, or with no value, is stale."}},"type":"object","required":["as_of_column","max_age_days"],"title":"DataFreshness","description":"How fresh a query's rows must be to be stated as current."}}},"paths":{"/v1/{workspace_id}/data_queries/{query_id}":{"patch":{"tags":["Workspace Data Queries"],"summary":"Update Workspace Data Query","operationId":"update-workspace-data-query","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"query_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Query Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__update_workspace_data_query__Request"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceDataQueryItem"}}}},"404":{"description":"Workspace data query not found"},"409":{"description":"A workspace data query with the given name already exists"},"422":{"description":"Validation failure"}}}}}}
```

## POST /v1/{workspace\_id}/data\_queries/{query\_id}/invoke

> Invoke Workspace Data Query

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Workspace Data Queries"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_data_queries__invoke_workspace_data_query__Request":{"properties":{"input":{"additionalProperties":true,"type":"object","title":"Input","description":"Caller arguments matching the declared parameters."}},"type":"object","title":"Request"},"src__routes__workspace_data_queries__invoke_workspace_data_query__Response":{"properties":{"result":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Result"},"duration_ms":{"type":"number","title":"Duration Ms","default":0},"row_count":{"type":"integer","title":"Row Count","default":0}},"type":"object","title":"Response"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/data_queries/{query_id}/invoke":{"post":{"tags":["Workspace Data Queries"],"summary":"Invoke Workspace Data Query","operationId":"invoke-workspace-data-query","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"query_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Query Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__invoke_workspace_data_query__Request"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_data_queries__invoke_workspace_data_query__Response"}}}},"404":{"description":"Workspace data query not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"503":{"description":"Execution failed"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.concurrence.com/api-reference/readme/platform/workspace-data-queries.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
