Back

Microsoft Dynamics Business Central API Essential Guide

Aug 9, 20246 minute read

What type of API does Microsoft Dynamics Business Central provide?

Microsoft Dynamics Business Central supports multiple types of APIs, with REST being the primary and recommended option. Here are the key points:

API Types Supported

  1. REST API (recommended)
  2. OData web services
  3. SOAP web services (legacy)

REST API

  • This is the preferred and most modern API option for Business Central.
  • It is optimized for performance and is recommended for integrating Business Central with external systems.
  • Business Central comes with an extensive list of built-in REST APIs that require minimal setup.
  • Custom REST APIs can be developed using AL object types like API pages and API queries.

OData Web Services

  • Based on OData version 4 standard.
  • Allows publishing pages, codeunits, and queries as ODataV4 web service endpoints.
  • Supports both XML and JSON formats.

SOAP Web Services

  • Still supported but considered legacy.
  • Exposes a Web Services Description Language (WSDL) document.
  • Less flexible compared to REST and OData options.

Does the Microsoft Dynamics Business Central API have webhooks?

Yes, the official Microsoft Dynamics Business Central API does support webhooks. Here are the key points about webhooks in Business Central:

Webhook Support

  • Business Central supports webhooks as a way to get notified when entities change.
  • Webhooks are available for both v1.0 and v2.0 of the Business Central API.

Supported Events

You can subscribe to webhook events for the following types of entities:

  • Standard API entities like accounts, customers, sales orders, etc.
  • Custom API entities that you create
  • Document APIs (e.g. salesInvoice) - notifications are sent for changes to both headers and lines

Subscribing to Webhooks

  • You can get a list of supported webhook entities by making a GET request to the webhookSupportedResources endpoint.
  • To subscribe to webhooks, you make a POST request to create a subscription, specifying:
    • The notification URL to receive events
    • The resource/entity to subscribe to
    • Optional client state

Key Considerations

  • Webhooks are valid for 3 days by default and need to be renewed.
  • Changes made by users without job queue permissions may not trigger notifications immediately.
  • There are some limitations for Power Automate flows using webhooks.
  • For on-premises deployments, you need to enable OData, API, and job queue on the service tier.

Implementation

  • Behind the scenes, Business Central uses tables to track subscriptions and notifications.
  • You can implement webhooks without writing any AL code in Business Central - the system handles sending notifications automatically.

In summary, webhooks provide a powerful way to get real-time notifications of data changes in Business Central, enabling integrations with external systems. The API supports subscribing to both standard and custom entities.

Rate Limits and other limitations

Here are the key API rate limits for the Microsoft Dynamics Business Central API:

OData Request Limits (Per User)

  • Max concurrent requests: 5
  • Max connections: 100
  • Max request queue size: 95
  • Speed (rate): 6000 requests per 5-minute sliding window

OData Request Limits (Per Environment)

  • Max body size: 350 MB
  • Max page size: 20,000 entities
  • Max batch size: 100 operations in a $batch request
  • Operation timeout: 8 minutes

SOAP Request Limits (Per User)

  • Speed (rate): 6000 requests per 5-minute sliding window

Key Points to Consider

  • These limits are applied to all types of users, including application users (service principals).

  • Exceeding these limits will result in HTTP status codes like 429 (Too Many Requests) or 503 (Service Temporarily Unavailable).

  • To optimize throughput, it's recommended to use API or OData instead of SOAP, as they execute faster.

  • If your integration is using a single user or service principal for many operations, consider distributing the workload across multiple users or service principals to avoid hitting per-user limits.

Best Practices

  1. Implement retry logic with cool-off periods to handle rate limiting.

  2. For large-scale integrations, distribute requests across multiple users or service principals.

  3. Use OData batch requests to combine multiple operations and reduce the number of API calls.

  4. Monitor your API usage and implement strategies to stay within the limits.

  5. Consider using asynchronous operations for long-running tasks to avoid timeouts.

By understanding and working within these limits, you can ensure smooth integration with Dynamics 365 Business Central while avoiding performance issues or service disruptions.

Latest API Version

Based on the search results provided, here is the answer to your question about the most recent version of the Microsoft Dynamics Business Central API:

The most recent version of the Microsoft Dynamics Business Central API is v2.0 [1].

Key points to consider:

  1. The API v2.0 is the current version for Business Central [1].

  2. Microsoft recommends using the highest API version available when using the built-in APIs [3].

  3. There was a transition from API v1.0 to API v2.0. For information about this transition, you can refer to the "Transition from API v1.0 to API v2.0" documentation [1].

  4. The Business Central API stack is optimized for performance and is the preferred way to integrate with Business Central [3].

  5. Developers can create custom APIs using AL object types like API pages and API queries [3].

Best practices:

  1. Always use the latest version of the API for the most up-to-date features and improvements.

  2. Familiarize yourself with the Microsoft APIs Terms of Use before starting to use the Business Central APIs [1].

  3. When developing connect apps or integrations, use standard REST API to interchange data [1].

  4. For inspiration and examples, check the open-source ALAppExtensions repository, which contains examples of API pages written in AL [1].

  5. If you need to extend APIs with additional fields, you must create a custom API based on the existing AL code, as extending APIs directly is not currently possible in Business Central [1].

How to get a Microsoft Dynamics Business Central developer account and API Keys?

To get a developer account for Microsoft Dynamics Business Central and create an API integration, you need to follow these steps:

Sign up for a Business Central trial tenant

  1. Sign up for a free Dynamics 365 Business Central trial tenant.

  2. This will give you access to a Business Central environment where you can explore the APIs and develop your integration.

Set up authentication

  1. For production use, you should use Microsoft Entra ID (formerly Azure AD) authentication. To set this up:

    • Sign in to the Azure portal
    • Register Business Central as an app
    • Add API permissions for Business Central
    • Create a client secret
  2. For initial development and testing, you can use basic authentication, but this is deprecated for production use.

Enable API access

  1. In Business Central, search for "API Setup" and enable the APIs.

  2. For on-premises installations, you may need to enable OData and API services using PowerShell commands.

Determine the API endpoint

  1. The endpoint URL will depend on your environment:

    • For online: https://api.businesscentral.dynamics.com/v2.0/<environment name>/api/v2.0
    • For on-premises: https://<base URL>:<port>/<serverInstance>/api/v2.0/

Explore and develop

  1. You can now explore the available APIs using the OpenAPI specification.

  2. Develop your integration using any language capable of calling REST APIs.

What can you do with the Microsoft Dynamics Business Central API?

Here's the markdown text with the trailing list of URLs and citation references removed, and any URLs inside the content formatted correctly for the markdown file format:

Here's a list of data models you can interact with using the Microsoft Dynamics Business Central API, along with what is possible for each:

Financial Management

  • General Ledger Entries

    • Read and create journal entries
    • Retrieve account balances
    • Generate financial reports
  • Accounts Receivable

    • Create and manage customer invoices
    • Process payments
    • View customer balances and aging reports
  • Accounts Payable

    • Create and manage vendor bills
    • Process payments to vendors
    • View vendor balances and aging reports
  • Cash Management

    • Manage bank accounts and reconciliations
    • Process bank transfers
    • View cash flow statements

Sales and Customer Management

  • Customers

    • Create, read, update, and delete customer records
    • Manage customer contact information
    • View customer sales history
  • Sales Orders

    • Create and manage sales orders
    • Process order fulfillment and shipments
    • Generate invoices from sales orders
  • Sales Quotes

    • Create and manage sales quotes
    • Convert quotes to sales orders

Purchasing and Vendor Management

  • Vendors

    • Create, read, update, and delete vendor records
    • Manage vendor contact information
    • View purchase history
  • Purchase Orders

    • Create and manage purchase orders
    • Process receipts and returns
    • Generate vendor bills from purchase orders

Inventory Management

  • Items

    • Create, read, update, and delete item records
    • Manage item attributes and pricing
    • View inventory levels and stock movements
  • Warehouses

    • Manage warehouse locations and bins
    • Process inventory transfers between locations

Project Management

  • Projects

    • Create and manage project records
    • Track project progress and milestones
    • Manage project budgets and resources
  • Time Sheets

    • Create and submit time entries
    • Approve time sheets
    • Bill time to projects or customers

Manufacturing

  • Production Orders

    • Create and manage production orders
    • Track production progress
    • Manage bill of materials and routings
  • Capacity Planning

    • View and manage work center capacity
    • Schedule production orders

Service Management

  • Service Items

    • Create and manage service item records
    • Track service history and warranties
  • Service Orders

    • Create and manage service orders
    • Schedule service appointments
    • Generate invoices for completed service work

Human Resources

  • Employees
    • Create, read, update, and delete employee records
    • Manage employee contact information and job details

General

  • Dimensions

    • Create and manage dimension values
    • Apply dimensions to transactions for reporting purposes
  • Attachments

    • Upload and retrieve documents attached to various records

For each of these data models, the API generally allows for creating, reading, updating, and deleting records (CRUD operations), as well as performing specific actions related to the business processes they represent. The exact capabilities may vary depending on the specific API endpoint and the user's permissions within the system.

It's important to note that the Business Central API is designed to be RESTful, following OData v4 standards, which allows for efficient querying, filtering, and data manipulation. Additionally, the API supports integration with other Microsoft services and third-party applications, enabling developers to create comprehensive solutions that leverage Business Central's functionality.