> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revoengine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# api reference

> Execution, platform, Database, HTTP, automation, and compatibility methods.

<Note>
  Generated from the same public contract that feeds the Monaco editor. Declaration-marked deprecated compatibility methods are intentionally excluded. Do not edit this page manually.
</Note>

This page contains **70 methods**. Search the docs for an exact method name, or use this index:

* [`api.createDatabase()`](#api-createDatabase)
* [`api.cloneDatabase()`](#api-cloneDatabase)
* [`api.exportDatabase()`](#api-exportDatabase)
* [`api.exportDatabaseView()`](#api-exportDatabaseView)
* [`api.updateDatabase()`](#api-updateDatabase)
* [`api.deleteDatabase()`](#api-deleteDatabase)
* [`api.restoreDatabase()`](#api-restoreDatabase)
* [`api.truncateDatabase()`](#api-truncateDatabase)
* [`api.transactionDatabase()`](#api-transactionDatabase)
* [`api.getDatabaseData()`](#api-getDatabaseData)
* [`api.getDatabaseViewData()`](#api-getDatabaseViewData)
* [`api.getDatabaseAudit()`](#api-getDatabaseAudit)
* [`api.insertDatabaseData()`](#api-insertDatabaseData)
* [`api.upsertDatabaseData()`](#api-upsertDatabaseData)
* [`api.updateDatabaseData()`](#api-updateDatabaseData)
* [`api.deleteDatabaseData()`](#api-deleteDatabaseData)
* [`api.updateDatabaseDataRequest()`](#api-updateDatabaseDataRequest)
* [`api.deleteDatabaseDataRequest()`](#api-deleteDatabaseDataRequest)
* [`api.queryDatabase()`](#api-queryDatabase)
* [`api.currentUser()`](#api-currentUser)
* [`api.isDebug()`](#api-isDebug)
* [`api.disableDebug()`](#api-disableDebug)
* [`api.enableDebug()`](#api-enableDebug)
* [`api.getCache()`](#api-getCache)
* [`api.setCache()`](#api-setCache)
* [`api.getContext()`](#api-getContext)
* [`api.getErrors()`](#api-getErrors)
* [`api.getWarnings()`](#api-getWarnings)
* [`api.getExecutionId()`](#api-getExecutionId)
* [`api.getLogs()`](#api-getLogs)
* [`api.getOperationId()`](#api-getOperationId)
* [`api.executeComponent()`](#api-executeComponent)
* [`api.input()`](#api-input)
* [`api.log()`](#api-log)
* [`api.exit()`](#api-exit)
* [`api.throw()`](#api-throw)
* [`api.getCurrentInstance()`](#api-getCurrentInstance)
* [`api.getInstanceData()`](#api-getInstanceData)
* [`api.getInstanceDetails()`](#api-getInstanceDetails)
* [`api.getSecret()`](#api-getSecret)
* [`api.getSecrets()`](#api-getSecrets)
* [`api.publishMessage()`](#api-publishMessage)
* [`api.getInstanceCache()`](#api-getInstanceCache)
* [`api.setInstanceCache()`](#api-setInstanceCache)
* [`api.setInstanceCacheIfNotExists()`](#api-setInstanceCacheIfNotExists)
* [`api.getOrSetInstanceCache()`](#api-getOrSetInstanceCache)
* [`api.removeInstanceCache()`](#api-removeInstanceCache)
* [`api.existsInstanceCache()`](#api-existsInstanceCache)
* [`api.persistInstanceCache()`](#api-persistInstanceCache)
* [`api.expireInstanceCache()`](#api-expireInstanceCache)
* [`api.getExpireInstanceCache()`](#api-getExpireInstanceCache)
* [`api.listInstanceCache()`](#api-listInstanceCache)
* [`api.incrementInstanceCache()`](#api-incrementInstanceCache)
* [`api.decrementInstanceCache()`](#api-decrementInstanceCache)
* [`api.compareAndSetInstanceCache()`](#api-compareAndSetInstanceCache)
* [`api.acquireIdempotencyKey()`](#api-acquireIdempotencyKey)
* [`api.getIdempotencyKey()`](#api-getIdempotencyKey)
* [`api.releaseIdempotencyKey()`](#api-releaseIdempotencyKey)
* [`api.concurrencyLimit()`](#api-concurrencyLimit)
* [`api.rateLimit()`](#api-rateLimit)
* [`api.releaseRateLimit()`](#api-releaseRateLimit)
* [`api.releaseConcurrencyLimit()`](#api-releaseConcurrencyLimit)
* [`api.triggerEvent()`](#api-triggerEvent)
* [`api.triggerTarget()`](#api-triggerTarget)
* [`api.triggerJob()`](#api-triggerJob)
* [`api.triggerWebhook()`](#api-triggerWebhook)
* [`api.httpCall()`](#api-httpCall)
* [`api.sftpExec()`](#api-sftpExec)
* [`api.sftpPut()`](#api-sftpPut)
* [`api.sftpGet()`](#api-sftpGet)

<span id="api-createDatabase" aria-hidden="true" />

## `api.createDatabase()`

Creates a logical database. The server assigns databaseId, version, and timestamps;
never generate or send those values. A normal database needs at least one definition.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static createDatabase(data: DatabaseCreateInput): Promise<Database>;
```

### Example

```ts theme={null}
await api.createDatabase({
  name: 'audit_log',
  category: 'Ops',
  desc: 'Audit',
  restricted: false,
  groups: [],
  users: [],
  definition: [{
    name: 'auditId', type: 'UUID',
    isPrimaryKey: true, isArray: false, isUnique: true,
    isNullable: false, isIndex: true, foreignReferences: [],
  }],
});
```

<span id="api-cloneDatabase" aria-hidden="true" />

## `api.cloneDatabase()`

Clones a logical database by name or database id.

Notes:

* No-op in debug mode.
* By default waits for the clone and returns cloned database metadata.
* Set `&#123; async: true &#125;` to start a backend clone task and return immediately with an accepted response.
* Omit `name` to use the backend default source-name plus `_Clone`.

### Signature

```ts theme={null}
static cloneDatabase<TAsync extends boolean = false>(
      databaseIdOrName: string,
      options?: DatabaseCloneInput & { async?: TAsync },
    ): Promise<
      TAsync extends true
        ? CloneDatabaseAcceptedResponse
        : TAsync extends false
          ? CloneDatabaseCompletedResponse
          : CloneDatabaseResponse
    >;
```

### Example

```ts theme={null}
const result = await api.cloneDatabase('customers', {
  includeItems: false,
  includePartitions: true,
});

return result.databases;
```

<span id="api-exportDatabase" aria-hidden="true" />

## `api.exportDatabase()`

Exports logical database rows directly into Storage as CSV.

Notes:

* No-op in debug mode.
* By default waits for the export, final compose, and storage entry persistence.
* Set `&#123; async: true &#125;` to return immediately with an accepted response.
* Omit `storageDestination` for private user storage, use `ROOT` for Explorer root,
  or provide an accessible Explorer folder storageEntryId.

### Signature

```ts theme={null}
static exportDatabase<TAsync extends boolean = false>(
      databaseIdOrName: string,
      options?: ExportDatabaseOptions & { async?: TAsync },
    ): Promise<
      TAsync extends true
        ? ExportDatabaseAcceptedResponse
        : TAsync extends false
          ? ExportDatabaseCompletedResponse
          : ExportDatabaseResponse
    >;
```

### Example

```ts theme={null}
const result = await api.exportDatabase('contracts', {
  storageDestination: 'ROOT',
  fileName: 'contracts-full.csv',
  restricted: false,
  fields: ['contractId', 'customerId'],
  sort: { contractId: 'ASC' },
});

return result.storageEntryId;
```

<span id="api-exportDatabaseView" aria-hidden="true" />

## `api.exportDatabaseView()`

Exports a saved database view or materialized view directly into Storage as CSV.
The saved view owns its joins and CTEs; callers may add projection, filters,
grouping, sorting, and paging over the resulting view definition.
Defaults to waiting for the completed Storage entry. Set `async: true` for kickoff semantics.

### Signature

```ts theme={null}
static exportDatabaseView<TAsync extends boolean = false>(
      databaseViewIdOrName: string,
      options?: ExportDatabaseOptions & { async?: TAsync },
    ): Promise<
      TAsync extends true
        ? ExportDatabaseAcceptedResponse
        : TAsync extends false
          ? ExportDatabaseCompletedResponse
          : ExportDatabaseResponse
    >;
```

<Note>No dedicated example is encoded in the current editor declaration. The signature is authoritative.</Note>

<span id="api-updateDatabase" aria-hidden="true" />

## `api.updateDatabase()`

Updates selected logical-database fields. The public contract requires the current
version for optimistic locking; send only the fields that should change. Do not
copy server-owned databaseId, timestamps, or size into this payload.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static updateDatabase(databaseId: string, data: DatabaseUpdateInput): Promise<Database>;
```

### Example

```ts theme={null}
await api.updateDatabase(databaseId, {
  version: current.version,
  audit: true,
});
```

<span id="api-deleteDatabase" aria-hidden="true" />

## `api.deleteDatabase()`

Soft-deletes a logical database.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static deleteDatabase(databaseId: string): Promise<void>;
```

### Example

```ts theme={null}
await api.deleteDatabase(databaseId);
```

<span id="api-restoreDatabase" aria-hidden="true" />

## `api.restoreDatabase()`

Restores a deleted logical database.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static restoreDatabase(databaseId: string): Promise<void>;
```

### Example

```ts theme={null}
await api.restoreDatabase(databaseId);
```

<span id="api-truncateDatabase" aria-hidden="true" />

## `api.truncateDatabase()`

Removes all rows from a logical database.

Notes:

* No-op in debug mode.
* TRUNCATE does not create row audit events, even when database audit is enabled.
* Use an ordinary filtered delete, such as primary key IS NOT NULL, to preserve row audit events.
* Identity counters are preserved by default.
* Set restartIdentity only when generated key reuse is explicitly intended.

### Signature

```ts theme={null}
static truncateDatabase(
      databaseId: string,
      options?: TruncateDatabaseOptions,
    ): Promise<void>;
```

### Example

```ts theme={null}
await api.truncateDatabase(databaseId, { restartIdentity: false });
```

<span id="api-transactionDatabase" aria-hidden="true" />

## `api.transactionDatabase()`

Runs database-data operations inside a short-lived transaction.

Notes:

* Commits automatically when the callback resolves.
* Rolls back automatically when the callback throws.
* The default timeout is 15,000 ms.
* Use `&#123; flexTimeout: true &#125;` when the transaction intentionally needs
  the enclosing execution's remaining timeout budget.
* Long transactions reserve a database connection and may retain locks;
  keep waits and remote side effects outside the callback when possible.
* SERIALIZABLE is the default isolation level.
* Parallel tx.\* operations are rejected; await each tx.\* call sequentially.

### Signature

```ts theme={null}
static transactionDatabase<T>(
      callback: (tx: DatabaseTransactionApi) => Promise<T> | T,
      options?: DatabaseTransactionStartOptions,
    ): Promise<T>;
```

### Example

```ts theme={null}
await api.transactionDatabase(async (tx) => {
  const existing = await tx.getDatabaseData(
    'contracts',
    { filter: { field: 'contractId', op: 'eq', value: api.input('contractId') }, take: 1 },
    { lock: 'update' },
  );
  if (existing.results === 0) {
    await tx.insertDatabaseData('contracts', [
      { contractId: api.input('contractId') },
    ]);
  }
});
```

<span id="api-getDatabaseData" aria-hidden="true" />

## `api.getDatabaseData()`

Reads database rows using the structured query shape.

Notes:

* This is the canonical read API.

### Signature

```ts theme={null}
static getDatabaseData<T = any>(
      name: string,
      request?: SelectInput,
    ): Promise<GetDatabaseDataResponse<T>>;
```

### Example

```ts theme={null}
const rows = await api.getDatabaseData('customers', {
  fields: ['customerId', 'name'],
  filter: { field: 'status', op: 'eq', value: 'ACTIVE' },
  sort: { name: 'ASC' },
  take: 100,
});
```

<span id="api-getDatabaseViewData" aria-hidden="true" />

## `api.getDatabaseViewData()`

Reads a saved database view by its logical name. The saved view owns its
joins and CTEs; callers may add projection, filters, casts, grouping,
sorting, count, and pagination over the resulting definition.

### Signature

```ts theme={null}
static getDatabaseViewData<T = any>(
      name: string,
      request?: SelectInput,
    ): Promise<GetDatabaseDataResponse<T>>;
```

<Note>No dedicated example is encoded in the current editor declaration. The signature is authoritative.</Note>

<span id="api-getDatabaseAudit" aria-hidden="true" />

## `api.getDatabaseAudit()`

Reads newest-first audit events. Prefer narrow fields and changed/filter over a
full snapshot.\* or changes.\* payload. Missing requested paths return null.

### Signature

```ts theme={null}
static getDatabaseAudit(
      name: string,
      query?: DatabaseAuditQuery,
    ): Promise<DatabaseAuditResponse>;
```

<Note>No dedicated example is encoded in the current editor declaration. The signature is authoritative.</Note>

<span id="api-insertDatabaseData" aria-hidden="true" />

## `api.insertDatabaseData()`

Inserts rows.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static insertDatabaseData(
      name: string,
      data: LooseObject<any>[],
    ): Promise<DatabaseDataActionResponse>;
```

### Example

```ts theme={null}
await api.insertDatabaseData('customers', [
  { customerId: 'c-1', name: 'Acme' },
]);
```

<span id="api-upsertDatabaseData" aria-hidden="true" />

## `api.upsertDatabaseData()`

Upserts rows.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static upsertDatabaseData(
      name: string,
      data: LooseObject<any>[],
    ): Promise<DatabaseDataActionResponse>;
```

### Example

```ts theme={null}
await api.upsertDatabaseData('customers', [
  { customerId: 'c-1', status: 'ACTIVE' },
]);
```

<span id="api-updateDatabaseData" aria-hidden="true" />

## `api.updateDatabaseData()`

Updates rows matched by oldObject.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static updateDatabaseData(
      name: string,
      oldObject: LooseObject<any>,
      newObject: LooseObject<any>,
    ): Promise<ResourceItem>;
```

### Example

```ts theme={null}
await api.updateDatabaseData(
  'customers',
  { customerId: 'c-1' },
  { status: 'ACTIVE' },
);
```

<span id="api-deleteDatabaseData" aria-hidden="true" />

## `api.deleteDatabaseData()`

Deletes rows.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static deleteDatabaseData(name: string, data: ResourceItem[]): Promise<any>;
```

### Example

```ts theme={null}
await api.deleteDatabaseData('customers', [
  { customerId: 'c-1' },
]);
```

<span id="api-updateDatabaseDataRequest" aria-hidden="true" />

## `api.updateDatabaseDataRequest()`

Bulk-updates rows matched by an advanced structured filter.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static updateDatabaseDataRequest(
      name: string,
      request: DatabaseMutationRequest,
      payload: Record<string, any>,
      options?: { return?: boolean; onlyKeys?: boolean },
    ): Promise<{ success: number; elapsed: number; data?: any }>;
```

### Example

```ts theme={null}
await api.updateDatabaseDataRequest(
  'customers',
  { filter: { field: 'status', op: 'eq', value: 'NEW' } },
  { status: 'PROCESSED' },
);
```

<span id="api-deleteDatabaseDataRequest" aria-hidden="true" />

## `api.deleteDatabaseDataRequest()`

Bulk-deletes rows matched by an advanced structured filter.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static deleteDatabaseDataRequest(
      name: string,
      request: DatabaseMutationRequest,
      options?: { return?: boolean; onlyKeys?: boolean },
    ): Promise<{ success: number; elapsed: number; data?: any }>;
```

### Example

```ts theme={null}
await api.deleteDatabaseDataRequest('customers', {
  filter: { field: 'archivedAt', op: 'isNotNull' },
});
```

<span id="api-queryDatabase" aria-hidden="true" />

## `api.queryDatabase()`

Executes raw SELECT/WITH SQL when the structured helpers are not enough.
Do not use this for writes; use insert/upsert/update/delete helpers or
transactionDatabase for write flows.

### Signature

```ts theme={null}
static queryDatabase(query: string, params?: any[]): Promise<any>;
```

### Example

```ts theme={null}
const rows = await api.queryDatabase('SELECT NOW() AS now');
```

<span id="api-currentUser" aria-hidden="true" />

## `api.currentUser()`

Returns the current logged user or service account.

### Signature

```ts theme={null}
static currentUser(): LoggedUser;
```

### Example

```ts theme={null}
const user = api.currentUser();
```

<span id="api-isDebug" aria-hidden="true" />

## `api.isDebug()`

Returns true when debug mode is enabled.

### Signature

```ts theme={null}
static isDebug(): boolean;
```

### Example

```ts theme={null}
if (api.isDebug()) {
  api.log('Debug mode', 'WARN');
}
```

<span id="api-disableDebug" aria-hidden="true" />

## `api.disableDebug()`

Disables debug mode for the current execution.

### Signature

```ts theme={null}
static disableDebug(): void;
```

### Example

```ts theme={null}
api.disableDebug();
```

<span id="api-enableDebug" aria-hidden="true" />

## `api.enableDebug()`

Enables debug mode for the current execution.

### Signature

```ts theme={null}
static enableDebug(): void;
```

### Example

```ts theme={null}
api.enableDebug();
```

<span id="api-getCache" aria-hidden="true" />

## `api.getCache()`

Reads request-scoped in-memory cache.

### Signature

```ts theme={null}
static getCache(key: string): any;
```

### Example

```ts theme={null}
const token = api.getCache('token');
```

<span id="api-setCache" aria-hidden="true" />

## `api.setCache()`

Writes request-scoped in-memory cache.

### Signature

```ts theme={null}
static setCache(key: string, value: any): void;
```

### Example

```ts theme={null}
api.setCache('token', 'abc');
```

<span id="api-getContext" aria-hidden="true" />

## `api.getContext()`

Returns the current execution context.

### Signature

```ts theme={null}
static getContext(): Context;
```

### Example

```ts theme={null}
const ctx = api.getContext();
```

<span id="api-getErrors" aria-hidden="true" />

## `api.getErrors()`

Returns collected error logs.

### Signature

```ts theme={null}
static getErrors(): ProcessLog[];
```

### Example

```ts theme={null}
const errors = api.getErrors();
```

<span id="api-getWarnings" aria-hidden="true" />

## `api.getWarnings()`

Returns collected warning logs.

### Signature

```ts theme={null}
static getWarnings(): ProcessLog[];
```

### Example

```ts theme={null}
const warnings = api.getWarnings();
```

<span id="api-getExecutionId" aria-hidden="true" />

## `api.getExecutionId()`

Returns the UUID that identifies the current low-code execution.
For durable jobs this is the job id. Endpoint and Sandbox executions
receive an independent execution UUID while retaining their operation id
for distributed request tracing.

### Signature

```ts theme={null}
static getExecutionId(): string;
```

### Example

```ts theme={null}
const executionId = api.getExecutionId();
```

<span id="api-getLogs" aria-hidden="true" />

## `api.getLogs()`

Returns collected info logs.

### Signature

```ts theme={null}
static getLogs(): LooseObject<any>[];
```

### Example

```ts theme={null}
const logs = api.getLogs();
```

<span id="api-getOperationId" aria-hidden="true" />

## `api.getOperationId()`

Returns the current operation id.

### Signature

```ts theme={null}
static getOperationId(): string;
```

### Example

```ts theme={null}
const op = api.getOperationId();
```

<span id="api-executeComponent" aria-hidden="true" />

## `api.executeComponent()`

Executes another active component in the managed RevoEngine runtime and returns its execution result.

Notes:

* Supports CODE\_JS, CODE\_TS, and CUSTOM\_NODEJS components.
* CODE\_JS and CODE\_TS run in a fresh, isolated RevoEngine V8 environment.
* CUSTOM\_NODEJS runs in its governed RevoEngine component environment.
* If timeoutMs is omitted, the child receives the parent execution's remaining timeout budget.
* A larger timeoutMs is clamped to that remaining budget.
* At least 1 second of parent budget is required for nested component execution.
* Promise.all() starts independent child component executions.

### Signature

```ts theme={null}
static executeComponent<T = LooseObject<any>>(
      request: ComponentExecuteRequest,
    ): Promise<ComponentExecuteResult<T>>;
```

### Example

```ts theme={null}
const [pricing, taxes] = await Promise.all([
  api.executeComponent({ componentId: pricingComponentId, inputs: { customerId }, timeoutMs: 9000 }),
  api.executeComponent({ componentId: taxComponentId, inputs: { customerId }, timeoutMs: 9000 }),
]);
```

<span id="api-input" aria-hidden="true" />

## `api.input()`

Returns the current execution payload.

Notes:

* In endpoint context this usually includes body, query, headers, params, path, and method.
* In event or job context it commonly includes type and message.
* Passing a name returns a single top-level property.

### Signature

```ts theme={null}
static input(name?: string): Input;
```

### Example

```ts theme={null}
const customerId = api.input()?.body?.customerId;
```

<span id="api-log" aria-hidden="true" />

## `api.log()`

Adds a log entry.

### Signature

```ts theme={null}
static log(
      log: string | LogInterface,
      type?: 'ERROR' | 'WARN' | 'INFO' | 'DEBUG',
      duration?: number,
      time?: string,
    ): void;
```

### Example

```ts theme={null}
api.log(
  { message: 'Call finished', args: { status: 200 } },
  'INFO',
  120,
);
```

<span id="api-exit" aria-hidden="true" />

## `api.exit()`

Stops execution early without marking it as a sandbox failure.

### Signature

```ts theme={null}
static exit(): void;
```

### Example

```ts theme={null}
if (!enabled) {
  api.exit();
}
```

<span id="api-throw" aria-hidden="true" />

## `api.throw()`

Stores an HTTP-style response and aborts execution.

Notes:

* Reserved 502 and 503 codes are not allowed from Endpoint user code.

### Signature

```ts theme={null}
static throw(code: number, body?: any): void;
```

### Example

```ts theme={null}
api.throw(400, { message: 'customerId is required' });
```

<span id="api-getCurrentInstance" aria-hidden="true" />

## `api.getCurrentInstance()`

Returns the current instance id.

### Signature

```ts theme={null}
static getCurrentInstance(): string;
```

### Example

```ts theme={null}
const instanceId = api.getCurrentInstance();
```

<span id="api-getInstanceData" aria-hidden="true" />

## `api.getInstanceData()`

Reads data from platform-managed sources.

### Signature

```ts theme={null}
static getInstanceData(
      dataSource:
        | 'Users'
        | 'Groups'
        | 'RoleGroups'
        | 'Keys'
        | 'Secrets'
        | 'SecretsData'
        | 'Templates'
        | 'Events'
        | 'Schedule'
        | 'Jobs'
        | 'Webhooks'
        | 'Components'
        | 'Logs'
        | 'Files'
        | 'EventsHistory'
        | 'Endpoints'
        | 'Databases'
        | 'DatabaseData',
      request?: InstanceData,
    ): Promise<any>;
```

### Example

```ts theme={null}
const files = await api.getInstanceData('Files', {
  take: 20,
  sort: ['-createdAt'],
});
```

<span id="api-getInstanceDetails" aria-hidden="true" />

## `api.getInstanceDetails()`

Returns public instance metadata.

### Signature

```ts theme={null}
static getInstanceDetails(): InstanceDetails;
```

### Example

```ts theme={null}
const details = api.getInstanceDetails();
```

<span id="api-getSecret" aria-hidden="true" />

## `api.getSecret()`

Resolves a single secret value by name.

### Signature

```ts theme={null}
static getSecret(name: string): Promise<string>;
```

### Example

```ts theme={null}
const apiKey = await api.getSecret('CRM_API_KEY');
```

<span id="api-getSecrets" aria-hidden="true" />

## `api.getSecrets()`

Resolves multiple secret values by name.

### Signature

```ts theme={null}
static getSecrets(name: string[]): Promise<{ [key: string]: string }>;
```

### Example

```ts theme={null}
const secrets = await api.getSecrets([
  'CRM_API_KEY',
  'CRM_API_URL',
]);
```

<span id="api-publishMessage" aria-hidden="true" />

## `api.publishMessage()`

Publishes a realtime message.

Notes:

* No-op in debug mode.
* Currently only the 'ALL' channel is supported.

### Signature

```ts theme={null}
static publishMessage(channel: string, message: any): Promise<void>;
```

### Example

```ts theme={null}
await api.publishMessage('ALL', { state: 'started' });
```

<span id="api-getInstanceCache" aria-hidden="true" />

## `api.getInstanceCache()`

Reads instance-scoped cache.

### Signature

```ts theme={null}
static getInstanceCache(key: string): Promise<any>;
```

### Example

```ts theme={null}
const state = await api.getInstanceCache('sync:state');
```

<span id="api-setInstanceCache" aria-hidden="true" />

## `api.setInstanceCache()`

Writes instance-scoped cache.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static setInstanceCache(
      key: string,
      value: any,
      seconds?: number,
    ): Promise<void>;
```

### Example

```ts theme={null}
await api.setInstanceCache('sync:state', { step: 'loading' }, 300);
```

<span id="api-setInstanceCacheIfNotExists" aria-hidden="true" />

## `api.setInstanceCacheIfNotExists()`

Writes instance-scoped cache only when the key does not exist.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static setInstanceCacheIfNotExists(
      key: string,
      value: any,
      seconds?: number,
    ): Promise<boolean>;
```

### Example

```ts theme={null}
const created = await api.setInstanceCacheIfNotExists('sync:state', { step: 'queued' }, 300);
```

<span id="api-getOrSetInstanceCache" aria-hidden="true" />

## `api.getOrSetInstanceCache()`

Reads a cache key or stores the fallback value atomically if it is missing.

### Signature

```ts theme={null}
static getOrSetInstanceCache(
      key: string,
      value: any,
      seconds?: number,
    ): Promise<any>;
```

### Example

```ts theme={null}
const state = await api.getOrSetInstanceCache('sync:state', { step: 'queued' }, 300);
```

<span id="api-removeInstanceCache" aria-hidden="true" />

## `api.removeInstanceCache()`

Removes cache keys.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static removeInstanceCache(key: string, wildcard?: boolean): Promise<void>;
```

### Example

```ts theme={null}
await api.removeInstanceCache('sync:*', true);
```

<span id="api-existsInstanceCache" aria-hidden="true" />

## `api.existsInstanceCache()`

Checks whether an instance cache key exists.

### Signature

```ts theme={null}
static existsInstanceCache(key: string): Promise<boolean>;
```

### Example

```ts theme={null}
const exists = await api.existsInstanceCache('sync:state');
```

<span id="api-persistInstanceCache" aria-hidden="true" />

## `api.persistInstanceCache()`

Makes a cache key persistent.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static persistInstanceCache(key: string): Promise<void>;
```

### Example

```ts theme={null}
await api.persistInstanceCache('sync:state');
```

<span id="api-expireInstanceCache" aria-hidden="true" />

## `api.expireInstanceCache()`

Sets cache TTL in seconds.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static expireInstanceCache(key: string, ttl: number): Promise<void>;
```

### Example

```ts theme={null}
await api.expireInstanceCache('sync:state', 600);
```

<span id="api-getExpireInstanceCache" aria-hidden="true" />

## `api.getExpireInstanceCache()`

Returns cache TTL in seconds, 0 for no expiry, or null when the key does not exist.

### Signature

```ts theme={null}
static getExpireInstanceCache(key: string): Promise<number | null>;
```

### Example

```ts theme={null}
const ttl = await api.getExpireInstanceCache('sync:state');
```

<span id="api-listInstanceCache" aria-hidden="true" />

## `api.listInstanceCache()`

Lists instance cache keys by prefix or pattern.

### Signature

```ts theme={null}
static listInstanceCache(key: string): Promise<string[]>;
```

### Example

```ts theme={null}
const keys = await api.listInstanceCache('sync:*');
```

<span id="api-incrementInstanceCache" aria-hidden="true" />

## `api.incrementInstanceCache()`

Atomically increments an integer cache key.

Notes:

* No-op in debug mode.
* 'by' must be an integer.

### Signature

```ts theme={null}
static incrementInstanceCache(
      key: string,
      by?: number,
      seconds?: number,
    ): Promise<number>;
```

### Example

```ts theme={null}
const count = await api.incrementInstanceCache('sync:counter', 1, 300);
```

<span id="api-decrementInstanceCache" aria-hidden="true" />

## `api.decrementInstanceCache()`

Atomically decrements an integer cache key.

Notes:

* No-op in debug mode.
* 'by' must be an integer.

### Signature

```ts theme={null}
static decrementInstanceCache(
      key: string,
      by?: number,
      seconds?: number,
    ): Promise<number>;
```

### Example

```ts theme={null}
const count = await api.decrementInstanceCache('sync:counter');
```

<span id="api-compareAndSetInstanceCache" aria-hidden="true" />

## `api.compareAndSetInstanceCache()`

Atomically updates a cache key only when the current value matches 'expected'.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static compareAndSetInstanceCache(
      key: string,
      expected: any,
      value: any,
      seconds?: number,
    ): Promise<boolean>;
```

### Example

```ts theme={null}
const swapped = await api.compareAndSetInstanceCache('sync:state', { step: 'queued' }, { step: 'running' }, 300);
```

<span id="api-acquireIdempotencyKey" aria-hidden="true" />

## `api.acquireIdempotencyKey()`

Acquires an idempotency key in the instance-scoped managed cache.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static acquireIdempotencyKey(
      key: string,
      ttl: number,
      value?: any,
    ): Promise<boolean>;
```

### Example

```ts theme={null}
const first = await api.acquireIdempotencyKey('orders:123', 600, { state: 'running' });
```

<span id="api-getIdempotencyKey" aria-hidden="true" />

## `api.getIdempotencyKey()`

Reads stored idempotency metadata.

### Signature

```ts theme={null}
static getIdempotencyKey(key: string): Promise<any>;
```

### Example

```ts theme={null}
const current = await api.getIdempotencyKey('orders:123');
```

<span id="api-releaseIdempotencyKey" aria-hidden="true" />

## `api.releaseIdempotencyKey()`

Releases an idempotency key.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static releaseIdempotencyKey(key: string): Promise<void>;
```

### Example

```ts theme={null}
await api.releaseIdempotencyKey('orders:123');
```

<span id="api-concurrencyLimit" aria-hidden="true" />

## `api.concurrencyLimit()`

Acquires an instance-scoped concurrency token.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static concurrencyLimit(
      key: string,
      limit: number,
      ttl: number,
    ): Promise<boolean>;
```

### Example

```ts theme={null}
const locked = await api.concurrencyLimit('sync:customers', 1, 300);
```

<span id="api-rateLimit" aria-hidden="true" />

## `api.rateLimit()`

Acquires an instance-scoped rate-limit token.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static rateLimit(key: string, limit: number, ttl: number): Promise<boolean>;
```

### Example

```ts theme={null}
const allowed = await api.rateLimit('outbound:crm', 10, 60);
```

<span id="api-releaseRateLimit" aria-hidden="true" />

## `api.releaseRateLimit()`

Releases a rate-limit key.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static releaseRateLimit(key: string): Promise<void>;
```

### Example

```ts theme={null}
await api.releaseRateLimit('outbound:crm');
```

<span id="api-releaseConcurrencyLimit" aria-hidden="true" />

## `api.releaseConcurrencyLimit()`

Releases a concurrency-limit key.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static releaseConcurrencyLimit(key: string): Promise<void>;
```

### Example

```ts theme={null}
await api.releaseConcurrencyLimit('sync:customers');
```

<span id="api-triggerEvent" aria-hidden="true" />

## `api.triggerEvent()`

Schedules a custom event.

Notes:

* The existing Date argument and `scheduleDate` option remain supported.
* New code should use `scheduleFor` with a Date, ISO 8601 date-time, or Unix timestamp in milliseconds.
* The absolute time cannot be in the past or more than 30 days ahead.
* No-op in debug mode.

### Signature

```ts theme={null}
static triggerEvent(
      name: string,
      message: any,
      scheduleDateOrOptions?: Date | TriggerEventOptions,
    ): Promise<string>;
```

### Example

```ts theme={null}
const eventId = await api.triggerEvent(
  'customer_sync',
  { customerId: 'c-1' },
  {
    scheduleFor: new Date(Date.now() + 5 * 60 * 1000).toISOString(),
    metadata: { correlationId: 'sync-123' },
  },
);
```

<span id="api-triggerTarget" aria-hidden="true" />

## `api.triggerTarget()`

Schedules generic execution against a normalized target.

Notes:

* Use `JOB_TEMPLATE` for legacy template execution or `AGENT` for agent-native dispatch.
* The existing absolute Date argument remains supported.
* New code should pass `&#123; scheduleFor &#125;`; the maximum horizon is 30 days.
* No-op in debug mode.

### Signature

```ts theme={null}
static triggerTarget(
      targetType: ExecutionTargetType,
      targetId: string,
      input?: any,
      scheduleDate?: Date | AutomationScheduleOptions,
    ): Promise<string>;
```

### Example

```ts theme={null}
const jobId = await api.triggerTarget(
  'JOB_TEMPLATE',
  templateId,
  { customerId: 'c-1' },
  { scheduleFor: Date.now() + 5 * 60 * 1000 },
);
```

<span id="api-triggerJob" aria-hidden="true" />

## `api.triggerJob()`

Schedules a job template.

Notes:

* No-op in debug mode.
* Convenience wrapper for `api.triggerTarget('JOB_TEMPLATE', templateId, ...)`.
* The existing absolute Date argument remains supported.
* New code should pass `&#123; scheduleFor &#125;`; the maximum horizon is 30 days.

### Signature

```ts theme={null}
static triggerJob(
      templateId: string,
      input?: any,
      scheduleDate?: Date | AutomationScheduleOptions,
    ): Promise<string>;
```

### Example

```ts theme={null}
const jobId = await api.triggerJob(
  templateId,
  { customerId: 'c-1' },
  { scheduleFor: new Date(Date.now() + 15 * 60 * 1000) },
);
```

<span id="api-triggerWebhook" aria-hidden="true" />

## `api.triggerWebhook()`

Schedules a webhook delivery.

Notes:

* The existing absolute Date argument remains supported.
* New code should pass `&#123; scheduleFor &#125;`; the maximum horizon is 30 days.
* No-op in debug mode.

### Signature

```ts theme={null}
static triggerWebhook(
      webhook: WebhookInput,
      scheduleDate?: Date | AutomationScheduleOptions,
    ): Promise<Webhook>;
```

### Example

```ts theme={null}
const webhook = await api.triggerWebhook({
  request: {
    url: 'https://example.com/hook',
    method: 'POST',
    body: { ok: true },
  },
}, {
  scheduleFor: new Date(Date.now() + 5 * 60 * 1000).toISOString(),
});
```

<span id="api-httpCall" aria-hidden="true" />

## `api.httpCall()`

Performs an outbound HTTP request.

Notes:

* Supports proxy mode, form-data, Storage streaming, and optional current credentials.
* Use `source: &#123; storageEntryId &#125;` when streaming an Explorer Storage file into an HTTP request.
* Use `target: &#123; name, ... &#125;` or `target: &#123; storageEntryId, replace: true &#125;` when streaming an HTTP response into Explorer Storage.
* `source` and `target` may be used together to stream a Storage entry through an external conversion API and save its response into Storage.
* For multipart requests, put `formData` on the first config argument. Use one empty part with `source`, or put `storageEntryId` directly on each binary `formData` part.
* HTTP Storage targets use one provider-streamed direct upload and are finalized automatically. Use `storage.createUploadSession` plus `storage.uploadPart` for resumable/chunked session workflows.
* `requestType: 'storage'` and `responseType: 'storage'` are not valid; Storage is selected by `source`/`target` while `requestType`/`responseType` describe HTTP encoding.
* `response.data` is `undefined` when the response is stored; use `response.storage.entry` after successful finalization.
* For text files, prefer `computeStats: 'sync'` on the storage target so line stats are immediately available after finalize.
* JSON is the default request and response format. Explicit `requestType: 'json'` is valid for every supported HTTP method and may be combined with any response type because it does not declare a request body.

### Signature

```ts theme={null}
static httpCall(
      config: HttpRequestInterface,
      options?: HttpRequestOptionsInterface & {
        timeout?: number;
        proxy?: boolean;
      },
    ): Promise<{
      status: number;
      statusText: string;
      time: number;
      headers: LooseObject<string>;
      data: any;
      storage?: { session: StorageUploadSession; entry: StorageEntryView };
      request: {
        config: HttpRequestInterface & { timeout?: number };
        options: HttpRequestOptionsInterface & {
          timeout?: number;
          proxy?: boolean;
        };
      };
    }>;
```

### Example

```ts theme={null}
const response = await api.httpCall(
  {
    url: 'https://example.com/customers',
    method: 'POST',
    data: { customerId: 'customer-1' },
  },
  {
    requestType: 'json',
    responseType: 'json',
    timeout: 15000,
  },
);

Multipart request with one Storage file:
const response = await api.httpCall(
  {
    url: 'https://example.com/upload',
    method: 'POST',
    formData: [
      { key: 'description', value: 'Contract' },
      { key: 'file' },
    ],
  },
  {
    requestType: 'form-data',
    source: { storageEntryId },
  },
);

Multipart request with multiple Storage files:
const response = await api.httpCall(
  {
    url: 'https://example.com/merge',
    method: 'POST',
    formData: [
      { key: 'contract', storageEntryId: contractEntryId },
      { key: 'attachments', storageEntryId: attachmentsEntryId },
    ],
  },
  { requestType: 'form-data' },
);

Storage response stream:
const response = await api.httpCall(
  { url: 'https://example.com/report.csv', method: 'GET' },
  {
    responseType: 'stream',
    target: {
      name: 'report.csv',
      contentTypeHint: 'text/csv',
      computeStats: 'sync',
    },
  },
);

Storage request stream:
await api.httpCall(
  { url: 'https://example.com/import', method: 'POST' },
  { requestType: 'stream', source: { storageEntryId } },
);

Storage conversion:
await api.httpCall(
  { url: 'https://example.com/convert', method: 'POST' },
  {
    requestType: 'stream',
    source: { storageEntryId: sourceEntryId },
    responseType: 'stream',
    target: { name: 'converted.pdf', contentTypeHint: 'application/pdf' },
  },
);
```

<span id="api-sftpExec" aria-hidden="true" />

## `api.sftpExec()`

Executes multiple SFTP commands in order.

Notes:

* No-op in debug mode.

### Signature

```ts theme={null}
static sftpExec(commands: any[], config: SFTPClient): Promise<any>;
```

### Example

```ts theme={null}
await api.sftpExec([['mkdir', '/archive']], connection);
```

<span id="api-sftpPut" aria-hidden="true" />

## `api.sftpPut()`

Streams an Explorer Storage entry directly to SFTP without loading file bytes into low-code memory.

Notes:

* No-op in debug mode.
* Prefer \{ storageEntryId } for Explorer Storage files. String inputs are legacy fileIds.
* SFTP references use Explorer Storage; namespace is not part of this API.

### Signature

```ts theme={null}
static sftpPut(
      source: SFTPFileSourceRef,
      path: string,
      config: SFTPClient,
    ): Promise<void>;
```

### Example

```ts theme={null}
await api.sftpPut({ storageEntryId }, '/outbound/report.csv', connection);
```

<span id="api-sftpGet" aria-hidden="true" />

## `api.sftpGet()`

Streams an SFTP file directly into Explorer Storage and returns the finalized Storage entry.

Notes:

* No-op in debug mode.
* Use \{ storage: ... } to create an entry or \{ storageEntryId, replace: true } to replace one.
* Repeated finalization signals are idempotent.
* For text files, computeStats: 'sync' makes line statistics available immediately.

### Signature

```ts theme={null}
static sftpGet(
      target: SFTPFileTargetRef,
      path: string,
      config: SFTPClient,
    ): Promise<void | { session: StorageUploadSession; entry: StorageEntryView }>;
```

### Example

```ts theme={null}
const result = await api.sftpGet({
  storage: {
    name: 'daily.csv',
    parentStorageEntryId: folderId,
    contentTypeHint: 'text/csv',
    computeStats: 'sync',
    retention: { ttlSeconds: 604800 },
  },
}, '/incoming/report.csv', connection);
```
