---
id: post/demiliani-com/11796
type: post
title: "Dynamics 365 Business Central: using secrets in JsonObjects."
summary: Handling secrets securely in JSON objects for API integrations in Business Central requires using the new WriteWithSecretsTo method introduced in runtime 15.1 (version 26.1). This method replaces placeholder values with SecretText credentials before serializing the JSON, preventing secrets from being exposed during debugging.
tier: community
language: en
tags:
  - secrets
  - security
  - json
  - api integrations
  - al development
  - data types
system: integration
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:01:05.452Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 245de87985098becf9708ef205646fac040fe58f5ea568ee9fa3f8729ef1dc7e
evidence:
  - kind: blog
    url: https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/
    title: "Dynamics 365 Business Central: using secrets in JsonObjects."
    date: "2025-05-05"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/
    title: "Dynamics 365 Business Central: using secrets in JsonObjects."
    date: "2025-05-05"
    commit: null
    t: null
    quote: Using the SecretText data type in AL is absolutely a best practice for security.
  - kind: blog
    url: https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/
    title: "Dynamics 365 Business Central: using secrets in JsonObjects."
    date: "2025-05-05"
    commit: null
    t: null
    quote: With runtime 15.1, Microsoft introduces the new WriteWithSecretsTo method to a JsonObject.
  - kind: blog
    url: https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/
    title: "Dynamics 365 Business Central: using secrets in JsonObjects."
    date: "2025-05-05"
    commit: null
    t: null
    quote: Your secrets will be unvisible and secured from debugging now…
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
post_id: "11796"
source_id: demiliani-com
source_name: Stefano Demiliani
url: https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/
published_at: "2025-05-05T08:10:38.000Z"
author: Stefano Demiliani
full_text: false
words: 330
quotes:
  - text: Using the SecretText data type in AL is absolutely a best practice for security.
    why_it_matters: Establishes that SecretText is the recommended approach for handling credentials in Business Central development
  - text: With runtime 15.1, Microsoft introduces the new WriteWithSecretsTo method to a JsonObject.
    why_it_matters: Announces the solution to the previously unsolvable problem of embedding secrets in JSON structures
  - text: Your secrets will be unvisible and secured from debugging now…
    why_it_matters: Confirms the security benefit that secrets remain hidden during debugging operations
code_objects_mentioned: []
systems:
  - integration
  - development
versions_mentioned:
  - "23"
  - "26.0"
  - "26.1"
  - runtime 15.0
  - runtime 15.1
preview:
  embeddable: true
  frame_url: https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/embed/
  image: https://demiliani.com/wp-content/uploads/2025/05/aljsonsecrets_00.png
  image_alt: null
  image_w: 1140
  image_h: 378
  site_name: Stefano Demiliani
  favicon: https://demiliani.com/wp-content/uploads/2022/09/sd_wordpress_logo.png?w=32
  probed_at: "2026-10-07T11:52:09.863Z"
---

# Dynamics 365 Business Central: using secrets in JsonObjects.

[Read the post](https://demiliani.com/2025/05/05/dynamics-365-business-central-using-secrets-in-jsonobjects/) · Stefano Demiliani (Stefano Demiliani, MVP) · 2025-05-05 · 330 words · tier community · reviewed (checked by Opus)

> Handling secrets securely in JSON objects for API integrations in Business Central requires using the new WriteWithSecretsTo method introduced in runtime 15.1 (version 26.1). This method replaces placeholder values with SecretText credentials before serializing the JSON, preventing secrets from being exposed during debugging.

## Key points

- SecretText data type protects secrets from debugging exposure in AL code since version 23
- Runtime 15.0 (version 26.0) does not support passing SecretText directly to JsonObject or JsonToken
- WriteWithSecretsTo method in runtime 15.1 allows embedding secrets into JSON using placeholders and JPath format
- Method takes a Dictionary mapping paths to SecretText values and produces a new SecretText containing the serialized JSON with secrets replaced

## Quotes

- "Using the SecretText data type in AL is absolutely a best practice for security." (Establishes that SecretText is the recommended approach for handling credentials in Business Central development)
- "With runtime 15.1, Microsoft introduces the new WriteWithSecretsTo method to a JsonObject." (Announces the solution to the previously unsolvable problem of embedding secrets in JSON structures)
- "Your secrets will be unvisible and secured from debugging now…" (Confirms the security benefit that secrets remain hidden during debugging operations)

## Context

- Features: SecretText data type, WriteWithSecretsTo method, JsonObject, JsonToken
- Versions: 23, 26.0, 26.1, runtime 15.0, runtime 15.1

Source: Stefano Demiliani, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
