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

# Authentication

Modem Pay uses API keys to authenticate requests, ensuring that only authorized applications can access payment functions. API keys are generated in the Modem Pay dashboard and can be used in either live or test modes.

1. **API Keys**\
   Modem Pay provides two types of API keys:

   * **Public Key**: Used on the client side for initial requests (e.g., HTML form submissions).
   * **Secret Key**: Used on the server side for secure API calls and operations that need high trust (e.g., managing payment intents, accessing sensitive customer data).

2. **Using API Keys in Requests**\
   To authenticate a request, include the appropriate key in the request header:

   <CodeGroup>
     ```javascript nodejs theme={null}
     import ModemPay from "modem-pay";

     const modempay = new ModemPay("sk_test_b9596....4865");
     ```

     ```python python theme={null}
     from modempay import ModemPay

     modem_pay = ModemPay(api_key="sk_test_b9596....4865")
     ```

     ```php php theme={null}
     use ModemPay\ModemPay;

     $modemPay = new ModemPay('YOUR_MODEM_PAY_API_KEY');
     ```

     ```http http theme={null}
     Authorization: Bearer sk_test_b9596....4865
     ```
   </CodeGroup>

   Alternatively, in HTML forms, pass the `public_key` as a hidden field.

3. **Test and Live Modes**

   Modem Pay separates test and live keys, enabling you to test transactions without impacting real accounts. Test keys operate in a sandbox environment, allowing you to simulate payment flows before going live.
