Table of Contents

Publication API

All data in Publication is available also through API.

Webhooks

Use the Publication Line Updated external business event when a third-party system, such as a webshop, must react after Pimics publication reorganization updates a publication line. For example, after a product manager changes item data, reorganization compares Data Changed On with Updated On. If the data-change date is newer, reorganization updates the audit timestamp and raises the event. The webhook lets the webshop refresh that item after the Business Central transaction commits, instead of polling for changes.

Subscribe to the Publication Line Updated event

  1. Implement a publicly reachable HTTPS endpoint that accepts POST requests and can process the event payload. Generate a secret value for clientState so your service can check that incoming notifications belong to the subscription.
  2. Authenticate to the Business Central environment with a user that has the Ext. Events – Subscr permission set and read access to the external business-event definitions. The user must also have any access required by the event's RequiredPermissions attribute.
  3. Query the external business-event catalog and locate the event whose name is publicationLineUpdated. Record its appId and inspect payload to confirm the event parameters. See Microsoft's guidance on querying the business-event catalog for the returned definition fields:
    GET https://api.businesscentral.dynamics.com/v2.0/{tenantId}/{environment}/api/microsoft/runtime/v1.0/externalbusinesseventdefinitions
    Authorization: Bearer {accessToken}
    
  4. Subscribe your callback URL to the event by sending a POST request to the external event subscriptions endpoint. Use the company name and ID for the company to monitor:
    POST https://api.businesscentral.dynamics.com/v2.0/{tenantId}/{environment}/api/microsoft/runtime/v1.0/externaleventsubscriptions
    Authorization: Bearer {accessToken}
    Content-Type: application/json
    
    {
      "companyName": "CRONUS USA, Inc.",
      "companyId": "{companyId}",
      "eventName": "publicationLineUpdated",
      "appId": "{appIdFromEventDefinition}",
      "notificationUrl": "https://your-service.example.com/business-central/publication-line-updated",
      "clientState": "{your-secret-value}"
    }
    
    A successful request returns 201 Created. For request fields and subscription permissions, see Microsoft's guidance on submitting business-event subscriptions.
  5. After creating the subscription, use the process in Process a received notification to handle incoming events. See Microsoft's description of receiving business-event notifications for the notification envelope and delivery timing.

Process a received notification

When a third-party system receives the webhook, use the event to identify which publication line needs attention, then retrieve the current data from the Pimics API. For example, a webshop can refresh the relevant product information after a product manager's changes have been processed by publication reorganization.

  1. Receive the POST request at your callback and validate its clientState against the secret supplied when creating the subscription. Confirm that eventName is publicationLineUpdated. A notification for an item line can look like this:
    {
      "initiatingUserAADObjectId": "{userId}",
      "timestamp": "2026-11-09T08:15:00Z",
      "companyName": "CRONUS USA, Inc.",
      "companyId": "{companyId}",
      "eventName": "publicationLineUpdated",
      "payload": {
        "Code": "WEB",
        "Line Type": "Item",
        "Number": "1000",
        "LineId": "{publicationLineGuid}"
      },
      "appId": "{extensionAppId}",
      "clientState": "{your-secret-value}"
    }
    
  2. Read Code, Line Type, Number, and LineId from payload. Use Code to identify the publication and Line Type to select the data to retrieve. Confirm payload property spelling and types against the event definition's payload field.
  3. Retrieve the current data through the corresponding Publication API resource. The notification identifies the changed line; it does not contain the complete item, feature, or picture data. For an Item line, send a GET request using LineId as the item API key:
    GET https://api.businesscentral.dynamics.com/v2.0/{tenantId}/{environment}/api/pimics/publication/v2.0/companies({companyId})/items({publicationLineGuid})
    Authorization: Bearer {accessToken}
    
    The response contains the current item data, for example:
    {
      "id": "{publicationLineGuid}",
      "number": "1000",
      "description": "Example product",
      "publicationCode": "WEB"
    }
    
    For other line types, use the corresponding resource with the same LineId key: features({publicationLineGuid}) for a Feature line or documents({publicationLineGuid}) for a Picture line. The publication line GUID is the key for these API resources. The URLs show v2.0 for illustration; use the Publication API version available in your environment.
  4. Apply the retrieved data to your system. Make processing safe to repeat, and use the Changed Lines synchronization process to reconcile changes if your integration needs recovery from missed notifications.
  5. Acknowledge the notification with a successful HTTP response after accepting it for processing. If processing takes longer, queue the work and acknowledge promptly.
Note

Business Central sends the event notification only after the transaction commits. If the transaction rolls back, the notification is not sent. In this code, the event is raised during publication reorganization only when Data Changed On is later than Updated On; it is not raised immediately for every source-data edit. Use the Changed Lines synchronization process to reconcile changes if your integration needs recovery from missed notifications.

For an example of subscribing through Power Automate rather than a custom third-party callback, see the When a business event occurs trigger.

Changed Lines

Use the changed lines endpoint to find publication lines that have changed since your last synchronization. For each returned line, check its type and state to decide what to update or remove. Use the line's URL fields to retrieve the relevant data; a parent URL can lead you to the related item when the changed line is a feature or picture.

Before you begin

Make sure that the following conditions are met:

  • You have API access to the company that contains the publication.
  • You know the publicationCode of the publication channel that you synchronize, for example WEB.
  • You have a place to store the date and time of your last synchronization. On the first run, use an early date to receive all lines.

Synchronize changed items, features, and pictures

In this example, three different items change during the same synchronization time slot: one item line, one feature line, and one picture line. Read the item from lineEntityUrl, the feature's related item from parentLineUrl, and the picture from lineEntityUrl.

  1. Read the date and time of your last synchronization from your storage. On the first run, use an early date so the endpoint returns the existing lines.
  2. Send a GET request to the changed lines endpoint. Filter by publicationCode and dateModified greater than the stored date, sort by dateModified, and set the page size with $top. For example:
    GET https://api.businesscentral.dynamics.com/v2.0/{environment}/api/pimics/publication/v2.0/companies({companyId})/changedLines?$filter=publicationCode eq 'WEB' and dateModified gt 2026-11-08T00:00:00Z&$orderby=dateModified&$top=100
    
    Preview of the response is below the process
  3. Process each line in the value array. Check state first. If it is Deleted, remove the line from your system. If it is Draft or Published, choose the URL according to lineTypeEnum:
    • For Item, send a GET request to lineEntityUrl to read the item.
    • For Feature, send a GET request to parentLineUrl to read its parent item.
    • For Picture, send a GET request to lineEntityUrl to read the picture. Form the full address by adding the selected relative URL to the API base address, for example https://api.businesscentral.dynamics.com/v2.0/{environment}. Update your system with the data returned by that request. If the required URL is empty, skip the request for that line.
  4. If the response contains @odata.nextLink, send a GET request to that URL and process the returned lines as in step 3. Continue until no next link is returned.
  5. Store the greatest dateModified value you have processed. Use it as the starting date for the next synchronization run.

For this example, the response is:

{
  "value": [
    {
      "id": "1c0c0d5e-4a7b-4f2e-9d3a-6b8e2f1a7c90",
      "lineId": "3f2c1a9e-7b8d-4c6e-9a1f-2d3e4f5a6b7c",
      "lineTypeEnum": "Item",
      "publicationCode": "WEB",
      "lineEntityUrl": "/api/pimics/publication/v2.0/items(3f2c1a9e-7b8d-4c6e-9a1f-2d3e4f5a6b7c)",
      "parentLineId": "8a4d2b7c-1e3f-4a5b-8c6d-9e0f1a2b3c4d",
      "parentLineTypeEnum": "Product Group",
      "parentLineUrl": "/api/pimics/publication/v2.0/categories(8a4d2b7c-1e3f-4a5b-8c6d-9e0f1a2b3c4d)",
      "dateModified": "2026-11-09T08:15:00Z",
      "state": "Published"
    },
    {
      "id": "5e7f9a1b-2c3d-4e5f-8a9b-0c1d2e3f4a5b",
      "lineId": "9d4e5f6a-1b2c-4d3e-8f9a-0b1c2d3e4f5a",
      "lineTypeEnum": "Feature",
      "publicationCode": "WEB",
      "lineEntityUrl": "/api/pimics/publication/v2.0/features(9d4e5f6a-1b2c-4d3e-8f9a-0b1c2d3e4f5a)",
      "parentLineId": "2a5b7c9d-1e3f-4a6b-8c0d-2e4f6a8b0c1d",
      "parentLineTypeEnum": "Item",
      "parentLineUrl": "/api/pimics/publication/v2.0/items(2a5b7c9d-1e3f-4a6b-8c0d-2e4f6a8b0c1d)",
      "dateModified": "2026-11-09T08:15:00Z",
      "state": "Published"
    },
    {
      "lineId": "6b8c0d2e-4f6a-4b8c-9d0e-1f2a3b4c5d6e",
      "lineTypeEnum": "Picture",
      "publicationCode": "WEB",
      "lineEntityUrl": "/api/pimics/publication/v2.0/documents(6b8c0d2e-4f6a-4b8c-9d0e-1f2a3b4c5d6e)",
      "parentLineId": "7c9d1e3f-5a6b-4c8d-0e2f-4a6b8c0d1e3f",
      "parentLineTypeEnum": "Item",
      "parentLineUrl": "/api/pimics/publication/v2.0/items(7c9d1e3f-5a6b-4c8d-0e2f-4a6b8c0d1e3f)",
      "dateModified": "2026-11-09T08:15:00Z",
      "state": "Published"
    }
  ]
}

If more results are available, the response contains an @odata.nextLink value with the URL of the next page. Continue the same process for each page.

Fields of a changed line

Field Description
id System identifier of the publication line record.
lineId GUID of the publication line.
lineTypeEnum Type of the line, for example Item, Feature, Picture, or Document.
publicationCode Code of the publication channel that the line belongs to.
lineEntityUrl Relative address of the entity that holds the full data of the line. The value is empty if the line type has no matching entity in this endpoint.
parentLineId GUID of the parent line in the publication structure.
parentLineTypeEnum Type of the parent line.
parentLineUrl Relative address of the parent entity. The value is empty if the parent line type has no matching entity in this endpoint.
dateModified Date and time of the last change of the line. Use this field to find changes since your last synchronization.
state State of the line: Draft, Published, or Deleted.