{"title":"API query type","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-api-querytype/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-api-querytype, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-api-querytype","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Description of the API query type used for exposing and viewing web service endpoints.","date":"2026-09-21","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"API query type","slug":"api-query-type","at":0,"chars":3639},{"level":2,"title":"Describe the API for MCP tools","slug":"describe-the-api-for-mcp-tools","at":806,"chars":815},{"level":2,"title":"Example of the API query type","slug":"example-of-the-api-query-type","at":1621,"chars":1585},{"level":2,"title":"Related information","slug":"related-information","at":3206,"chars":433}],"text":"# API query type\nQueries of the type API are used to generate web service endpoints and this type of query can't be used to display data in the user interface. A query of the API type can be used to join data from different data sources. The data can only be viewed. When creating this query type, you must specify properties that provide information for the web service endpoint. Use the snippet `tquery - Query of type API` to get the right template and the list of these properties automatically filled in.\n> TIP\n> Use Ctrl+Space to trigger IntelliSense and get assistance on code completion, parameter info, quick info, and member lists. For more information about snippets, see Syntax and snippets<devenv-syntax>.\n> NOTE\n> Extending API pages and queries isn't currently possible in Business Central.\n## Describe the API for MCP tools\nWhen an API page or API query is exposed as a tool through the Business Central MCP server, the server uses metadata from the API object to generate the tool description.\nThe MCP server determines the tool description in the following order:\n1. The properties/devenv-abouttext-property property.\n1. If AboutText isn't specified, the server uses the properties/devenv-entitysetcaption-property property.\n1. If EntitySetCaption isn't available, the server uses a camel-cased version of the properties/devenv-entityname-property property.\nProvide meaningful values for these properties to help MCP clients and agents understand and select the appropriate tools. Learn more about the Business Central MCP server in Model Context Protocol (MCP) in Business Central<../ai/mcp-overview>.\n## Example of the API query type\nThe following query example publishes an API available at:\n`../contoso/app1/v1.0/companies({id})/customerSales`. The APIVersion can be specified as one version, or a list of versions, if the API is supported through multiple versions.\n```al\nquery 20000 \"APIV1 - Customer Sales\"\n{\n    QueryType = API;\n    APIPublisher = 'contoso';\n    APIGroup = 'app1';\n    APIVersion = 'v1.0';\n    Caption = 'customerSales', Locked = true;\n    EntityName = 'customerSale';\n    EntitySetName = 'customerSales';\n\n    elements\n    {\n        dataitem(QueryElement1; Customer)\n        {\n            column(customerId; Id)\n            {\n                Caption = 'Id', Locked = true;\n            }\n            column(customerNumber; \"No.\")\n            {\n                Caption = 'No', Locked = true;\n            }\n            column(name; Name)\n            {\n                Caption = 'Name', Locked = true;\n            }\n            dataitem(QueryElement10; \"Cust. Ledger Entry\")\n            {\n                DataItemLink = \"Customer No.\" = QueryElement1.\"No.\";\n                SqlJoinType = LeftOuterJoin;\n                DataItemTableFilter = \"Document Type\" = FILTER (Invoice | \"Credit Memo\");\n                column(totalSalesAmount; \"Sales (LCY)\")\n                {\n                    Caption = 'TotalSalesAmount', Locked = true;\n                    Method = Sum;\n                }\n                filter(dateFilter; \"Posting Date\")\n                {\n                    Caption = 'DateFilter', Locked = true;\n                }\n            }\n        }\n    }\n}\n```\n## Related information\nDevelop APIs with pages and queries<devenv-api>\nAL development environment<devenv-reference-overview>\nAPI page type<devenv-api-pagetype>\nproperties/devenv-apipublisher-query-property\nproperties/devenv-apigroup-query-property\nproperties/devenv-apiversion-query-property\nproperties/devenv-entityname-property\nproperties/devenv-entitysetname-property\ndevenv-query-object\nDeveloping extensions<devenv-dev-overview>"}