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

# Authentication

> Learn how to authenticate your API requests using Bearer tokens

## Overview

The GameBoost API uses **Bearer Token authentication** to secure all API endpoints. You'll need to include your API key in the `Authorization` header of every request.

<Info>
  All API requests must be made over HTTPS. Requests made over plain HTTP will fail.
</Info>

## Getting Your API Key

Your API key is available in the GameBoost Partner Dashboard. Follow these steps to retrieve it:

<Steps>
  <Step title="Log in to Partner Dashboard">
    Navigate to [gameboost.com/dashboard](https://gameboost.com/login) and sign in with your partner account.

    <Note>
      Not a partner yet? Go to [jobs.gameboost.com](https://jobs.gameboost.com) and apply as a seller.
    </Note>
  </Step>

  <Step title="Access API Settings">
    From the dashboard, navigate to **Settings** → **Developers** in the left sidebar.

    <Frame>
      <img src="https://mintcdn.com/gameboost-e9a07691/jEGkYEGWikF0sbvC/images/authentication/empty-api-key.png?fit=max&auto=format&n=jEGkYEGWikF0sbvC&q=85&s=f27840e8544ffe4f7e2fcfe8fe392c4a" alt="API Keys navigation in Partner Dashboard" width="1920" height="1138" data-path="images/authentication/empty-api-key.png" />
    </Frame>
  </Step>

  <Step title="Generate or View API Key">
    * If you haven't created an API key yet, click **New API Key**
    * Give your API key a descriptive name to help you identify it later.
    * By default, all API keys have **full access** to your account.

    <Frame>
      <img src="https://mintcdn.com/gameboost-e9a07691/jEGkYEGWikF0sbvC/images/authentication/create-api-key.png?fit=max&auto=format&n=jEGkYEGWikF0sbvC&q=85&s=c62d4e337b3d0cd8170c5b18a7f90c94" alt="API Keys navigation in Partner Dashboard" width="1920" height="1138" data-path="images/authentication/create-api-key.png" />
    </Frame>

    <Warning>
      Your API key will only be shown in full once during generation. Make sure to copy and store it securely.
    </Warning>
  </Step>

  <Step title="Copy and Secure Your Key">
    Copy your API key and store it in a secure location such as:

    * Environment variables in your application
    * A secure secrets manager (1Password, AWS Secrets Manager, etc.)
    * Encrypted configuration files

    <Check>
      Your API key is ready to use! You can now make authenticated requests to the GameBoost API.
    </Check>
  </Step>
</Steps>

## Making Authenticated Requests

Include your API key in the `Authorization` header using the Bearer token scheme:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET 'https://api.gameboost.com/v2/orders' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -H 'Content-Type: application/json'
  ```

  ```javascript Node.js theme={null}
  const fetch = require('node-fetch');

  const apiKey = process.env.GAMEBOOST_API_KEY;

  const response = await fetch('https://api.gameboost.com/v2/orders', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json'
    }
  });

  const data = await response.json();
  console.log(data);
  ```

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

  api_key = os.getenv('GAMEBOOST_API_KEY')

  headers = {
      'Authorization': f'Bearer {api_key}',
      'Content-Type': 'application/json'
  }

  response = requests.get(
      'https://api.gameboost.com/v2/orders',
      headers=headers
  )

  data = response.json()
  print(data)
  ```

  ```php PHP theme={null}
  <?php

  $apiKey = getenv('GAMEBOOST_API_KEY');

  $ch = curl_init('https://api.gameboost.com/v2/orders');

  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer ' . $apiKey,
      'Content-Type: application/json'
  ]);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  $data = json_decode($response, true);

  curl_close($ch);
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "io"
      "net/http"
      "os"
  )

  func main() {
      apiKey := os.Getenv("GAMEBOOST_API_KEY")

      client := &http.Client{}
      req, _ := http.NewRequest("GET", "https://api.gameboost.com/v2/orders", nil)

      req.Header.Add("Authorization", "Bearer "+apiKey)
      req.Header.Add("Content-Type", "application/json")

      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</CodeGroup>

<Tip>
  Store your API key in environment variables rather than hardcoding it in your source code. This improves security and makes it easier to manage keys across different environments.
</Tip>

## Managing Your API Keys

### Rotating API Keys

For security best practices, we recommend rotating your API keys periodically:

<Steps>
  <Step title="Generate a new API key">
    In the Partner Dashboard, click **New API Key** to create a second API key.
  </Step>

  <Step title="Update your applications">
    Gradually update your applications and services to use the new API key.
  </Step>

  <Step title="Revoke the old key">
    Once all services are using the new key, revoke the old key from the dashboard.
  </Step>
</Steps>

<Note>
  You can have up to 2 active API keys at once to facilitate smooth key rotation without downtime.
</Note>

### Revoking API Keys

If your API key is compromised or no longer needed, revoke it immediately:

<Steps>
  <Step title="Navigate to Developers Settings">
    Go to **Settings** → **Developers** in the Partner Dashboard.
  </Step>

  <Step title="Select the key to revoke">
    Find the API key you want to revoke in the list of active keys.
  </Step>

  <Step title="Click Delete">
    Click the **Delete** (trash icon) button next to the key and confirm the action.

    <Frame>
      <img src="https://mintcdn.com/gameboost-e9a07691/jEGkYEGWikF0sbvC/images/authentication/delete-api-key.png?fit=max&auto=format&n=jEGkYEGWikF0sbvC&q=85&s=1016c37cebd0a9dc085a1e0a0862eb57" alt="Delete API Key" width="1920" height="1138" data-path="images/authentication/delete-api-key.png" />
    </Frame>

    <Warning>
      Revoking an API key is immediate and cannot be undone. All requests using the revoked key will fail immediately.
    </Warning>
  </Step>

  <Step title="Generate a replacement">
    If needed, generate a new API key to replace the revoked one.

    <Check>
      The old key has been revoked and can no longer be used to access the API.
    </Check>
  </Step>
</Steps>

## Security Best Practices

<AccordionGroup>
  <Accordion title="Store keys securely">
    * Never commit API keys to version control
    * Use environment variables or secure secrets management services
    * Encrypt configuration files that contain API keys
    * Restrict access to API keys on a need-to-know basis
  </Accordion>

  <Accordion title="Use HTTPS only">
    * Always make API requests over HTTPS
    * Never send API keys over unencrypted connections
    * Validate SSL certificates in your API client
  </Accordion>

  <Accordion title="Rotate keys regularly">
    * Rotate API keys every 90 days as a best practice
    * Immediately rotate keys if you suspect compromise
    * Use the dual-key system to enable zero-downtime rotation
  </Accordion>

  <Accordion title="Protect against scams">
    * Never share API keys between team members or applications
    * Be wary of phishing attempts asking for your API key
    * Never enter your API key on suspicious websites or third-party tools
    * Report any suspicious activity or unauthorized access immediately
  </Accordion>
</AccordionGroup>

## Next Steps

Now that you've set up authentication, you're ready to start making API requests:

<CardGroup cols={2}>
  <Card title="API Responses" icon="message" href="/api/get-started/api-responses">
    Learn about response formats and error handling
  </Card>

  <Card title="Rate Limiting" icon="clock" href="/api/get-started/rate-limiting">
    Understand rate limits and best practices
  </Card>

  <Card title="API Reference" icon="book" href="/api/reference/account-offers/list-account-offers">
    Explore available endpoints and start building
  </Card>

  <Card title="Webhooks" icon="webhook" href="/api/get-started/configure-webhooks">
    Set up real-time event notifications
  </Card>
</CardGroup>
