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

# API Request

> Authentication, headers, and request configuration for the Messaging API

Plivo exposes REST APIs to send and manage SMS, MMS, and WhatsApp messages. All API requests use HTTPS.

## Base URL

```
https://api.plivo.com/v1/Account/{auth_id}/
```

***

## Authentication

All requests to the Messaging API are authenticated with **BasicAuth** using your Auth ID and Auth Token, which you can find on the Overview page of the Plivo [console](https://cx.plivo.com/home).

<CodeGroup>
  ```python Python theme={null}
  import plivo

  client = plivo.RestClient('<auth_id>', '<auth_token>')
  ```

  ```javascript Node.js theme={null}
  const plivo = require('plivo');

  const client = new plivo.Client('<auth_id>', '<auth_token>');
  ```

  ```ruby Ruby theme={null}
  require 'plivo'

  api = Plivo::RestClient.new('<auth_id>', '<auth_token>')
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';
  use Plivo\RestClient;

  $client = new RestClient('<auth_id>', '<auth_token>');
  ```

  ```java Java theme={null}
  import com.plivo.api.Plivo;

  Plivo.init("<auth_id>", "<auth_token>");
  ```

  ```csharp .NET theme={null}
  using Plivo;

  var api = new PlivoApi("<auth_id>", "<auth_token>");
  ```

  ```go Go theme={null}
  package main

  import "github.com/plivo/plivo-go/v7"

  func main() {
      client, _ := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
  }
  ```

  ```bash cURL theme={null}
  curl -i --user AUTH_ID:AUTH_TOKEN \
      https://api.plivo.com/v1/Account/{auth_id}/Message/
  ```
</CodeGroup>

***

## Content-Type

For POST requests, set the `Content-Type` header to `application/json`:

```
Content-Type: application/json
```

For media uploads, use `multipart/form-data`:

```
Content-Type: multipart/form-data
```

***

## Timeouts and Proxies

Configure timeouts and proxy settings when initializing the client:

<CodeGroup>
  ```python Python theme={null}
  import plivo

  proxies = {
      'http': 'https://username:password@proxyurl:proxyport',
      'https': 'https://username:password@proxyurl:proxyport'
  }
  client = plivo.RestClient('<auth_id>', '<auth_token>', proxies=proxies, timeout=5)
  ```

  ```javascript Node.js theme={null}
  const plivo = require('plivo');

  let options = {
      timeout: 5000, // ms
      host: 'https://proxyurl',
      port: 'proxyport',
      auth: {
          username: 'my-user',
          password: 'my-password'
      }
  };

  const client = new plivo.Client('<auth_id>', '<auth_token>', options);
  ```

  ```ruby Ruby theme={null}
  require 'plivo'

  proxy = {
      proxy_host: 'https://proxyurl',
      proxy_port: 'proxyport',
      proxy_user: 'username',
      proxy_pass: 'password'
  }
  api = Plivo::RestClient.new('<auth_id>', '<auth_token>', proxy, timeout=5)
  ```
</CodeGroup>

***

## Pagination

Plivo uses offset-based pagination to list resources.

### Parameters

<ParamField query="limit" type="integer">
  Number of results to return per page. Range: 1-20. Default: 20.
</ParamField>

<ParamField query="offset" type="integer">
  Number of records to skip before returning results. Default: 0.
</ParamField>

### Example

If you have 100 results with `limit=10` and `offset=50`, objects with indices 51-60 are returned.

***

## Asynchronous Requests

For high-throughput scenarios, use asynchronous request patterns:

<CodeGroup>
  ```python Python theme={null}
  import plivo
  import asyncio

  async def send_message():
      client = plivo.RestClient('<auth_id>', '<auth_token>')
      response = await client.messages.create_async(
          src='+14151234567',
          dst='+14157654321',
          text='Hello!'
      )
      return response
  ```

  ```javascript Node.js theme={null}
  const plivo = require('plivo');

  const client = new plivo.Client('<auth_id>', '<auth_token>');

  // Using promises
  client.messages.create({
      src: '+14151234567',
      dst: '+14157654321',
      text: 'Hello!'
  }).then(response => {
      console.log(response);
  }).catch(error => {
      console.error(error);
  });
  ```
</CodeGroup>
