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

# Authentication

> Learn how to authenticate securely with the LatePoint API

## Introduction

LatePoint API Extension uses an **API Keys** based authentication system to ensure the security of your data. Each API request must include a valid key to be processed.

## API Key Generation

### Create a New API Key

1. Go to **LatePoint > API Settings** in your WordPress dashboard
2. Click **"Generate New API Key"**
3. Assign a descriptive name (e.g., "Mobile App", "CRM System")
4. Copy and save the generated key securely

<Warning>
  **Important**: The API Key is only shown once. If you lose it, you'll need to generate a new one.
</Warning>

## Using the API Key

### Authentication Header

Include your API Key in the `X-API-Key` header of each request:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://your-site.com/wp-json/latepoint-api/v1/bookings" \
    -H "X-API-Key: lp__1234567890abcdef" \
    -H "Content-Type: application/json"
  ```

  ```javascript JavaScript theme={null}
  const apiKey = 'lp__1234567890abcdef';

  const response = await fetch('https://your-site.com/wp-json/latepoint-api/v1/bookings', {
    method: 'GET',
    headers: {
      'X-API-Key': apiKey,
      'Content-Type': 'application/json'
    }
  });
  ```

  ```python Python theme={null}
  import requests

  api_key = 'lp__1234567890abcdef'
  headers = {
      'X-API-Key': api_key,
      'Content-Type': 'application/json'
  }

  response = requests.get(
      'https://your-site.com/wp-json/latepoint-api/v1/bookings',
      headers=headers
  )
  ```

  ```php PHP theme={null}
  <?php
  $apiKey = 'lp_1234567890abcdef';
  $headers = [
      'X-API-Key: ' . $apiKey,
      'Content-Type: application/json'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://your-site.com/wp-json/latepoint-api/v1/bookings');
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  curl_close($ch);
  ?>
  ```
</CodeGroup>

## Authentication Errors

### 401 Unauthorized

**Cause:** Missing or invalid API Key

```json theme={null}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key"
  }
}
```

**Solution:**

* Verify that you include the `X-API-Key` header
* Confirm that the API Key is correct
* Make sure the key hasn't expired

## API Key Management

### List Active Keys

In **LatePoint > API Settings**, you can see:

* All generated API Keys
* Creation date and last use
* Status (active/inactive)

### Remove an API Key

1. Go to **LatePoint > API Settings**
2. Find the key you want to remove
3. Click **"Remove"**
4. Confirm the action

<Warning>
  Once revoked, the API Key will stop working immediately in all applications that use it.
</Warning>

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Explore all available endpoints
  </Card>

  <Card title="Error Handling" icon="exclamation-triangle" href="/api-reference/errors">
    Learn to handle errors correctly
  </Card>

  <Card title="Rate Limiting" icon="gauge" href="/api-reference/rate-limiting">
    Optimize your request quota usage
  </Card>

  <Card title="Code Examples" icon="code" href="/api-reference/bookings/list">
    See practical implementation examples
  </Card>
</CardGroup>
