# Generating Signature and Making API Requests

This section of the documentation explains how to generate a signature for requests and how to make requests to the E-Gates API to work with the payment method.

#### Generating a Signature

1. Prepare Parameters: For each request, prepare the parameters that will be passed. Include all necessary parameters in the request.
2. Create Query String: Formulate the query string, including all sorted parameters in the format key=value, separated by the & symbol.
3.  Sign Query String: Use your private key to create a signature for the query string. Depending on the programming language you're using, you can use the following functions:\


    In PHP:

    ```php
    $signature = hash_hmac('sha256', $queryString, $secretKey);
    ```

    \
    In JavaScript (using CryptoJS library):

    ```javascript
    let signature = CryptoJS.HmacSHA256(queryString, secretKey).toString();
    ```

#### Making API Requests

1. Set Headers: When making a request, set the following headers:
   * API-KEY: The value of the API key you created in your account.
   * SIGNATURE: The signature generated in the previous step.
2. Make Request: Use the programming language of your choice to perform an HTTP request to the E-Gates API. Pass all necessary parameters, headers, and the signature in the request.
3. Process Result: Handle the API response. Typically, successful responses contain required information, such as created invoices or other details.

#### Example: Creating an Invoice

```http
POST /api/external/v1/gateway/create-payment-invoice
```

```json
{
  "timestamp": 1691590025,
  "ticker": "USDT",
  "payment_method": "ETHER",
  "amount": 100,
  "order_number": "1aaa1",
  "meta_data": {"ads": "123"},
  "signature": "generated_signature"
}
```

### Conclusion

Following this guide, you'll be able to successfully generate signatures for requests and interact with the E-Gates API to work with the payment method. Please ensure you follow all security measures and provide accurate parameters when forming requests and signatures.
