---
url: https://veles.beyondthecloud.dev/docs/developer/api.md
description: >-
  Read configuration values from Apex and Flow, and use merge fields in workflow
  actions.
---

# Apex and Flow API

The package namespace is `btcveles`. Every call below returns the value for the org the code runs in: production gets production's value, a sandbox gets its own.

## Apex

```apex
String url = btcveles.Veles.forConfig('Payment_Gateway').getText('Endpoint URL');
Decimal timeout = btcveles.Veles.forConfig('Payment_Gateway').getNumber('Timeout');
Boolean testMode = btcveles.Veles.forConfig('Payment_Gateway').getBoolean('Test mode');
```

`Veles.forConfig(configName)` returns a `Veles.Config` with one getter per field type:

| Method                     | Returns                   |
| -------------------------- | ------------------------- |
| `getText(fieldName)`       | `String`                  |
| `getLongText(fieldName)`   | `String`                  |
| `getNumber(fieldName)`     | `Decimal`                 |
| `getBoolean(fieldName)`    | `Boolean`                 |
| `getDate(fieldName)`       | `Date`                    |
| `getDatetime(fieldName)`   | `Datetime`                |
| `getLabel()`               | the configuration's label |
| `getFieldLabel(fieldName)` | a field's label           |

Use the configuration and field **names**, not labels. A field with no value returns `null`. A field of secret type **Credential** always returns `null`: it exists only to be written into a Named or External Credential by a workflow action. Masked and Protected values are returned. A blank configuration or field name throws `Veles.ConfigException`.

Values are cached for the Apex transaction, so calling the same getter many times costs one query.

## Flow

Six invocable actions in the **Veles** category, one per field type: **Get Text Config Value**, **Get Long Text Config Value**, **Get Number Config Value**, **Get Boolean Config Value**, **Get Date Config Value**, **Get Datetime Config Value**. Inputs **Config Name** and **Field Name**, output **Value**. Same rules as Apex, including `null` for Credential fields.

## Merge fields in workflow actions

Any action parameter can take a value from a configuration at run time, resolved on the target org:

```text
{{Payment_Gateway.Endpoint URL}}
{{Payment_Gateway.Timeout:number}}
{{Payment_Gateway.API Key:text:credential}}
```

The type suffix is optional (`text`, `longtext`, `number`, `boolean`, `date`, `datetime`). The `:credential` suffix is the only way to read a Credential field, and it works only in parameters that allow it, such as **Authentication Parameters** of Manage Credential; anywhere else it resolves to `null`. The action form's **Insert Merge Field** button writes the syntax for you.
