> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# Net

## Functions

### httpRequest

Performs a regular HTTP or HTTPS request. To perform an HTTPS request, insert "https\://" at the URL's beginning. The default request method is **GET**, TCP connect timeout is **6** seconds and total request timeout is **90** seconds. Learn more about the [limits](/platform/voxengine/limits).

```ts
httpRequest(url: string, callback: (result: HttpRequestResult) => void, options?: HttpRequestOptions): void
```

**Parameters**

**`url`** `string` — required

---

**`callback`** `(result: HttpRequestResult) => void` — required

---

**`options`** `HttpRequestOptions`

---

### httpRequestAsync

Performs an asynchronous HTTP request. TCP connect timeout is 6 seconds and total request timeout is 90 seconds. Learn more about the [limits](/platform/voxengine/limits).

```ts
httpRequestAsync(url: string, options?: HttpRequestOptions): Promise<HttpRequestResult>
```

**Parameters**

**`url`** `string` — required

---

**`options`** `HttpRequestOptions`

---

### sendMail

Sends an email via the specified email server.

```ts
sendMail(mailServerAddress: string, from: string, to: string | string[], title: string, body: string, callback: (result: SendMailResult) => void, options?: SendMailOptions): void
```

**Parameters**

**`mailServerAddress`** `string` — required

---

**`from`** `string` — required

---

**`to`** `string | string[]` — required

---

**`title`** `string` — required

---

**`body`** `string` — required

---

**`callback`** `(result: SendMailResult) => void` — required

---

**`options`** `SendMailOptions`

---

### sendMailAsync

Sends an email via a specified email server.

```ts
sendMailAsync(mailServerAddress: string, from: string, to: string | string[], title: string, body: string, options?: SendMailOptions): Promise<SendMailResult>
```

**Parameters**

**`mailServerAddress`** `string` — required

---

**`from`** `string` — required

---

**`to`** `string | string[]` — required

---

**`title`** `string` — required

---

**`body`** `string` — required

---

**`options`** `SendMailOptions`

---

## Types

### HttpRequestOptions

Advanced HTTP request options.

**`connectionTimeout`** `number`

*optional*

Optional. Timeout for the TCP connection to the address in seconds. The default value is **6**. The value can be only decreased.

---

**`enableSystemLog`** `boolean`

*optional*

Optional. Whether to enable logging the POST request body. The default value is **false**.

---

**`externalLogging`** `boolean`

*optional*

Optional. Whether to enable extended logging of the raw HTTP request and response data. The default value is **false**.

---

**`headers`** `{ [key: string]: string }`

*optional*

Optional. Request headers: \{'Content-Type': 'text/html; charset=utf-8', 'User-Agent': 'YourCustomUserAgent/1.0'}. Note that the default value for the 'User-Agent' header is **VoxEngine/1.0**.

---

**`method`** `string`

*optional*

Optional. HTTP request type as a string: **GET**, **POST** etc. The default value is **GET**.

---

**`params`** `{\n      [key: string]: string;\n    }`

*optional*

Optional. Request parameters. They can be specified in the URL itself as well.

---

**`postData`** `string | number[]`

*optional*

Optional. Raw UTF-8 encoded data string or an array of bytes in any encoding generated by [str2bytes](/api-reference/voxengine/net) to send as the HTTP request body when 'method' is set to **POST**, **PUT**, or **PATCH**.

---

**`rawOutput`** `boolean`

*optional*

Optional. Whether [HttpRequestResult.data](/api-reference/voxengine/net#httprequestresult) should contain a list of 1-byte numbers corresponding to the HTTP response data. If set to **false**, [HttpRequestResult.data](/api-reference/voxengine/net#httprequestresult) is undefined.

---

**`timeout`** `number`

*optional*

Optional. Timeout for getting a response to the request in seconds. The default value is **90**. The value can be only decreased.

---

### HttpRequestResult

HTTP response.

**`code`** `number`

Response code. HTTP code (2xx-5xx) or one of our internal status codes

* `0`: [VoxEngine limits](/platform/voxengine/limits) are violated (e.g. HTTP request count exceeded)
* `-1`: Unknown error
* `-2`: Malformed URL
* `-3`: Host not found
* `-4`: Connection error
* `-5`: Too many redirects
* `-6`: Network error
* `-7`: Timeout
* `-8`: Internal error
* `-9`: Server response is larger than 2 MB

---

**`data`** `number[]`

*optional*

If [HttpRequestOptions.rawOutput](/api-reference/voxengine/net#httprequestoptions) is true, data contains a list of 1-byte numbers corresponding to HTTP response data. If [HttpRequestOptions.rawOutput](/api-reference/voxengine/net#httprequestoptions) is false, data is undefined.

---

**`error`** `string`

*optional*

In case of an error contains the error description

---

**`headers`** `{ key: string; value: string }[]`

*optional*

List of dictionaries with key and value fields representing HTTP headers returned by the remote server

---

**`raw_headers`** `string`

*optional*

HTTP header string returned by the remote server, without processing

---

**`text`** `string`

*optional*

HTTP response body if Content-Type is not binary

---

### SendMailOptions

Advanced options for the `Net.sendMail` method.

**`bcc`** `string[]`

*optional*

Optional. BCC addresses.

---

**`cc`** `string[]`

*optional*

Optional. CC addresses.

---

**`html`** `string`

*optional*

Optional. Alternative HTML body.

---

**`login`** `string`

Login for the mail server.

---

**`password`** `string`

Password for the mail server.

---

**`port`** `number`

Mail server port.

---

### SendMailResult

Result of sending an email.

**`code`** `number`

SMTP server response code.

---

**`error`** `string`

*optional*

Optional. SMTP server error message

---