httpPost(url, data, [options]) Last updated: 15. Oct 2026
API only function
Calls specified web service with HTTP POST, sending a JSON body. Expects JSON in the response and parses it to an object.
Parameters
| Name | Type | Description |
|---|---|---|
| url | string | URL to call with HTTP POST. |
| data | object | Object that will be passed as JSON body. |
| options (optional) | object | Specify any of the following options parameters: |
| • headers | object | Name / value object that will be converted to HTTP headers. |
Returns
Returns the JSON answer parsed to an object.
Errors do not throw: if the call fails, or the answer is not JSON, the result is { DoclyError: "<message>" }. The HTTP status code is not returned — use httpFetch when you need it. A string as data is sent as it is; an object is serialised as JSON.
Security: requests to Docly's own platform domains (and their subdomains) and to cloud metadata / link-local addresses are always blocked — also after a redirect — and the call returns { DoclyError }. The Host header cannot be set. Private networks are only blocked by httpFetch with blockPrivateNetworks: true.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.export default () => {
let config = docly.getJson("#/Config") || {}; // keep credentials in #/Config, never in code
let headers = {
"Authorization": "Basic " + docly.base64(config.ApiUser + ":" + config.ApiPassword)
};
let data = { "Field1": "123" };
// Call some API — data is sent as JSON
let result = docly.httpPost("https://api.example.com/v1/items", data, headers);
if (result && result.DoclyError) throw new Error("The external API did not answer");
return result;
}