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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Target remote endpoint URL. |
body | any | Yes | — | Request body to be serialized as JSON (Content-Type: application/json). |
options.headers | Record<string, string> | No | {} | Custom HTTP request headers. |
options.timeoutMs | number | No | 8000 | Request 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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Target URL resource to delete. |
options.headers | Record<string, string> | No | {} | Custom request headers. |
options.timeoutMs | number | No | 8000 | Request 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 #
| Scenario | Thrown Error | Resolution |
|---|---|---|
| Destination resolves to private IP | Error: Forbidden destination IP address | Verify 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 exceeded | DOMException: The operation was aborted | Optimize remote server response latency or wrap in try/catch. |
| Call quota exceeded | Error: 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.