dolfin.http.put & dolfin.http.delete #

Use put to replace or update existing remote resources, and delete to decommission or remove records in downstream applications.


TypeScript Signatures #

typescript
dolfin.http.put<T = unknown>(
  url: string,
  body: unknown,
  options?: {
    headers?: Record<string, string>;
    timeoutMs?: number;
  }
): Promise<{ status: number; body: T }>;

dolfin.http.delete<T = unknown>(
  url: string,
  options?: {
    headers?: Record<string, string>;
    timeoutMs?: number;
  }
): Promise<{ status: number; body: T }>;

Method Details #

dolfin.http.put(url, body, options?) #

Performs an outbound HTTP PUT request with a JSON request payload.

Parameters

ParameterTypeRequiredDefaultDescription
urlstringYes—Target remote endpoint URL.
bodyanyYes—Request body to be serialized as JSON (Content-Type: application/json).
options.headersRecord<string, string>No{}Custom HTTP request headers.
options.timeoutMsnumberNo8000Request timeout in milliseconds (max 8,000 ms).

dolfin.http.delete(url, options?) #

Performs an outbound HTTP DELETE request to remove or decommission external resources.

Parameters

ParameterTypeRequiredDefaultDescription
urlstringYes—Target URL resource to delete.
options.headersRecord<string, string>No{}Custom request headers.
options.timeoutMsnumberNo8000Request timeout in milliseconds (max 8,000 ms).

Minimal Example #

typescript
async function run(context: Context, dolfin: DolfinApi): Promise<void> {
  const { lead } = context;

  // Update external billing system contact info
  if (lead.meta?.billing_customer_id) {
    const res = await dolfin.http.put(
      `https://billing.example.com/customers/${lead.meta.billing_customer_id}`,
      {
        email: lead.email,
        phone: lead.phone
      },
      {
        headers: { "Authorization": "Bearer BILLING_API_KEY" }
      }
    );
    console.log(`Billing update response status: ${res.status}`);
  }
}

Production Recipe: Decommissioning Inactive External Trial #

When a lead transitions to Closed Lost, automatically decommission their external cloud trial instance:

typescript
async function run(context: Context, dolfin: DolfinApi): Promise<void> {
  const { lead } = context;
  const crm = await dolfin.crm.module(lead.moduleId);

  // If lead is marked Closed Lost and had an active external sandbox provisioned
  if (lead.meta?.sandbox_environment_id) {
    const envId = lead.meta.sandbox_environment_id;
    console.log(`Terminating trial sandbox #${envId} for lead ${lead.id}`);

    const res = await dolfin.http.delete(
      `https://cloud-provisioner.example.com/environments/${envId}`,
      {
        headers: { "X-Api-Key": "PROVISIONER_SECRET" },
        timeoutMs: 5000
      }
    );

    if (res.status === 200 || res.status === 204) {
      await crm.leads.update(lead.id, {
        meta: {
          ...lead.meta,
          sandbox_environment_id: null,
          sandbox_deprovisioned_at: new Date().toISOString()
        }
      });

      await crm.leads.notes.add(
        lead.id,
        `Cloud trial sandbox #${envId} successfully deprovisioned.`
      );
    }
  }
}

Error Handling & Guardrails #

ScenarioThrown ErrorResolution
Destination resolves to private IPError: Forbidden destination IP addressVerify destination URL is a publicly accessible domain. Private IPs (10.0.0.0/8, 192.168.0.0/16, 127.0.0.1) are blocked.
Timeout exceededDOMException: The operation was abortedOptimize remote server response latency or wrap in try/catch.
Call quota exceededError: Exceeded maximum HTTP calls per execution (5)Maximum 5 outbound HTTP calls allowed per execution cycle.
🛑 Caution

HTTP DELETE operations are destructive on remote systems. Always verify condition guards (such as matching lead stage or confirmed environment IDs) before triggering delete requests.