# API query type
Queries 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.
> TIP
> 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>.
> NOTE
> Extending API pages and queries isn't currently possible in Business Central.
## Describe the API for MCP tools
When 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.
The MCP server determines the tool description in the following order:
1. The properties/devenv-abouttext-property property.
1. If AboutText isn't specified, the server uses the properties/devenv-entitysetcaption-property property.
1. If EntitySetCaption isn't available, the server uses a camel-cased version of the properties/devenv-entityname-property property.
Provide 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>.
## Example of the API query type
The following query example publishes an API available at:
`../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.
```al
query 20000 "APIV1 - Customer Sales"
{
    QueryType = API;
    APIPublisher = 'contoso';
    APIGroup = 'app1';
    APIVersion = 'v1.0';
    Caption = 'customerSales', Locked = true;
    EntityName = 'customerSale';
    EntitySetName = 'customerSales';

    elements
    {
        dataitem(QueryElement1; Customer)
        {
            column(customerId; Id)
            {
                Caption = 'Id', Locked = true;
            }
            column(customerNumber; "No.")
            {
                Caption = 'No', Locked = true;
            }
            column(name; Name)
            {
                Caption = 'Name', Locked = true;
            }
            dataitem(QueryElement10; "Cust. Ledger Entry")
            {
                DataItemLink = "Customer No." = QueryElement1."No.";
                SqlJoinType = LeftOuterJoin;
                DataItemTableFilter = "Document Type" = FILTER (Invoice | "Credit Memo");
                column(totalSalesAmount; "Sales (LCY)")
                {
                    Caption = 'TotalSalesAmount', Locked = true;
                    Method = Sum;
                }
                filter(dateFilter; "Posting Date")
                {
                    Caption = 'DateFilter', Locked = true;
                }
            }
        }
    }
}
```
## Related information
Develop APIs with pages and queries<devenv-api>
AL development environment<devenv-reference-overview>
API page type<devenv-api-pagetype>
properties/devenv-apipublisher-query-property
properties/devenv-apigroup-query-property
properties/devenv-apiversion-query-property
properties/devenv-entityname-property
properties/devenv-entitysetname-property
devenv-query-object
Developing extensions<devenv-dev-overview>

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. https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-api-querytype/
