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

# Authentication

> How API key authentication works in the D3 Business API.

## API key authentication

Business API routes under `/api/v1` are protected with an API‑key–based middleware (`APIKeyAuth`) that verifies requests using a hashed key and encrypted digest stored in the `developer_app_details` (or equivalent) table.

Send your key using the `Authorization` header with Bearer token:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.dragdropdo.com/api/v1/status/task_abc123 \
    -H "Authorization: Bearer d3_live_xxx"
  ```

  ```ts NODE theme={null}
  import { Dragdropdo } from "dragdropdo-sdk";

  const client = new Dragdropdo({
    apiKey: "d3_live_xxx",
    baseURL: "https://api.dragdropdo.com",
  });

  // API key is automatically included in all requests
  ```

  ```python PYTHON theme={null}
  from dragdropdo_sdk import Dragdropdo, D3ClientConfig

  client = Dragdropdo(
      api_key="d3_live_xxx",
      base_url="https://api.dragdropdo.com"
  )

  # API key is automatically included in all requests
  ```

  ```php PHP theme={null}
  use DragdropdoSdk\Dragdropdo;

  $client = new Dragdropdo([
      'api_key' => 'd3_live_xxx',
      'base_url' => 'https://api.dragdropdo.com',
  ]);

  // API key is automatically included in all requests
  ```

  ```ruby RUBY theme={null}
  require 'dragdropdo_sdk'

  client = DragdropdoSdk::Dragdropdo.new(
    api_key: 'd3_live_xxx',
    base_url: 'https://api.dragdropdo.com'
  )

  # API key is automatically included in all requests
  ```

  ```go GO theme={null}
  import "github.com/d3/dragdropdo-sdk-go"

  client, _ := d3.NewDragdropdo(d3.Config{
      APIKey:  "d3_live_xxx",
      BaseURL: "https://api.dragdropdo.com",
  });

  // API key is automatically included in all requests
  ```

  ```java JAVA theme={null}
  import com.dragdropdo.sdk.Dragdropdo;
  import com.dragdropdo.sdk.DragdropdoConfig;

  Dragdropdo client = new Dragdropdo(
      new DragdropdoConfig("d3_live_xxx")
          .setBaseUrl("https://api.dragdropdo.com")
  );

  // API key is automatically included in all requests
  ```
</CodeGroup>

Under the hood the middleware:

1. Looks up the stored record by API key prefix or mapping.
2. Decrypts the stored digest using AES.
3. Recomputes the hash using `(digest + provided_api_key)`.
4. Compares it with the stored hash and verifies `ExpireAt` / `IsActive`.

If the key is invalid or expired, the request is rejected with an authentication error.

## Generating API keys

API keys are generated through the D3 dashboard:

1. **Sign in** to your account at [dragdropdo.com/auth/signin](https://dragdropdo.com/auth/signin)
2. Navigate to your **Account** section
3. Go to the **Generate API Key** section
4. Create a new API key with a descriptive name
5. Copy and securely store your API key

Once you have your API key, you can use it to initialize the client:

<CodeGroup>
  ```ts NODE theme={null}
  import { Dragdropdo } from "dragdropdo-sdk";

  const client = new Dragdropdo({
  apiKey: "d3_live_xxx", // Your API key from the dashboard
  baseURL: "https://api.dragdropdo.com",
  });

  ```

  ```python PYTHON theme={null}
  from dragdropdo_sdk import Dragdropdo, D3ClientConfig

  client = Dragdropdo(
      api_key="d3_live_xxx",  # Your API key from the dashboard
      base_url="https://api.dragdropdo.com"
  )
  ```

  ```php PHP theme={null}
  use DragdropdoSdk\Dragdropdo;

  $client = new Dragdropdo([
      'api_key' => 'd3_live_xxx', // Your API key from the dashboard
      'base_url' => 'https://api.dragdropdo.com',
  ]);
  ```

  ```ruby RUBY theme={null}
  require 'dragdropdo_sdk'

  client = DragdropdoSdk::Dragdropdo.new(
    api_key: 'd3_live_xxx', # Your API key from the dashboard
    base_url: 'https://api.dragdropdo.com'
  )
  ```

  ```go GO theme={null}
  import "github.com/d3/dragdropdo-sdk-go"

  client, _ := d3.NewDragdropdo(d3.Config{
      APIKey:  "d3_live_xxx", // Your API key from the dashboard
      BaseURL: "https://api.dragdropdo.com",
  });
  ```

  ```java JAVA theme={null}
  import com.dragdropdo.sdk.Dragdropdo;
  import com.dragdropdo.sdk.DragdropdoConfig;

  Dragdropdo client = new Dragdropdo(
      new DragdropdoConfig("d3_live_xxx") // Your API key from the dashboard
          .setBaseUrl("https://api.dragdropdo.com")
  );
  ```
</CodeGroup>
