title: REST API post request authenticate with API Key
body: <p>I'm building out a RESTful API. I'm using API keys for my GET requests (base64 encoded over https to be secure) however I'm confused how to "authenticate" with POST requests.</p>
  
  <p>I've read about basic authentication but that uses a username and password.</p>
  
  <p>Is it good practice/correct to authenticate a POST request with an API key also? Is that something you would include as part of the headers?</p>
  
  <p>How do I process the authentication on the server side (endpoint)?</p>
  
  <p>Here's an example of the endpoint that I have for logging in (POST request):</p>
  
  <pre><code>if ($_POST) {
  
      $email = $_POST['email'];
      $email = stripslashes($email);
      $email = strip_tags($email);
      $password = $_POST['password'];
      $password = stripslashes($password);
      $password = strip_tags($password);
  
      // Regular Login
  
      $user = system::shared()-&gt;customers-&gt;login(
          $email,
          $password,
          $error
      );
  
      if ($user) {
  
          $output = json_encode($user);
  
      } else {
  
          $output = "Incorrect email/password. Please try again.";
  
      }
  
      echo $output;
  
  } else {
      http_response_code(405);
  }
  </code></pre>
  
  <p>How would I use the code above to "authenticate" an API key. Is that just a POST field?</p>
  
  <p>Thank you for your assistance</p>