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

# Authentication

> Learn how to authenticate with the StarkFi API

StarkFi API uses API keys to authenticate requests. Include your API key in the `x-api-key` header on every request, including configuration routes such as [`GET /config/products`](/products) and the [Quote](/quote) service. Your API keys carry many privileges, so be sure to keep them secure!

<Info>
  **Base URL:** `https://api.starkfi.io`

  Use the paths exactly as shown in this documentation — for example `GET /yield/strategies`, `POST /payment/register/intents-create-order`.
</Info>

## Getting an API Key

<Steps>
  <Step title="Sign up for StarkFi">
    Create an account at [starkfi.io](https://starkfi.io)

    <Info>
      KYC/KYB is required for **financial transactions** with fiat payment methods. **Checkout (order)** flows and pure **crypto** transactions do not require verification. See [StarkPay overview](/starkpay).
    </Info>
  </Step>

  <Step title="Navigate to Dashboard Account">
    <Info>
      Create your account –– Follow the link [<u>https://dashboard.starkfi.io</u>](https://dashboard.starkfi.io)
    </Info>

    <Frame>
      <img src="https://mintcdn.com/starkfi/Lu1bDXqeqMESnfq5/images/login-auth-dash.png?fit=max&auto=format&n=Lu1bDXqeqMESnfq5&q=85&s=32cfc3c15279d985f0ac7780a03902df" alt="Login Auth Dash" width="1512" height="1258" data-path="images/login-auth-dash.png" />
    </Frame>
  </Step>

  <Step title="Copy and Storage " iconType="duotone">
    Copy your API key immediately - you won’t be able to see it again!

    <Frame>
      <img src="https://mintcdn.com/starkfi/Lu1bDXqeqMESnfq5/images/Screenshot-2026-05-15-at-18.44.55.png?fit=max&auto=format&n=Lu1bDXqeqMESnfq5&q=85&s=1c8b7f5a803f7683c5d23fb1200e21b1" alt="Screenshot 2026 05 15 At 18 44 55" style={{ width: "100%" }} width="1230" height="570" data-path="images/Screenshot-2026-05-15-at-18.44.55.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/starkfi/Lu1bDXqeqMESnfq5/images/Screenshot-2026-05-15-at-18.45.04.png?fit=max&auto=format&n=Lu1bDXqeqMESnfq5&q=85&s=32222116eb32123f51f389ba17aecd05" alt="Screenshot 2026 05 15 At 18 45 04" title="Screenshot 2026 05 15 At 18 45 04" style={{ width:"49%" }} width="960" height="1068" data-path="images/Screenshot-2026-05-15-at-18.45.04.png" />
    </Frame>

    <Warning>
      **Keep your API keys secure!** Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, etc.
    </Warning>
  </Step>
</Steps>

### Using your API Key

Include your API key in the `x-api-key` header with every request:

<CodeGroup>
  ```javascript Typescript/Javascript theme={null}
  import axios from 'axios'

  const starkfi = axios.create({
    baseURL: 'https://api.starkfi.io',
    headers: {
      'x-api-key': process.env.STARKFI_API_KEY
    }
  })

  // Make authenticated request
  const response = await starkfi.get('/payment/:id/status')
  console.log(response.data)
  ```

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

  session = requests.Session()
  session.headers.update({
      'x-api-key': os.environ['STARKFI_API_KEY']
  })

  # Make authenticated request
  response = session.get('https://api.starkfi.io/yield/strategies')
  data = response.json()
  print(data)
  ```

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

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

  func main() {
    client := &http.Client{}
    req, _ := http.NewRequest("GET", "https://api.starkfi.io/yield/strategies", nil)

    // Set API key header
    req.Header.Set("x-api-key", os.Getenv("STARKFI_API_KEY"))

    resp, _ := client.Do(req)
    defer resp.Body.Close()
    fmt.Println(resp.Status)
  }
  ```

  ```rust Rust theme={null}
  use reqwest::Client;
  use std::env;

  #[tokio::main]
  async fn main() -> Result<(), reqwest::Error> {
      let api_key = env::var("STARKFI_API_KEY")
          .expect("STARKFI_API_KEY not set");

      let client = Client::new();

      // Make authenticated request
      let response = client
          .get("https://api.starkfi.io/yield/strategies")
          .header("x-api-key", api_key)
          .send().await?
          .json::<serde_json::Value>().await?;

      println!("{:?}", response);
      Ok(())
  }
  ```

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

  $apiKey = $_ENV['STARKFI_API_KEY'];

  $ch = curl_init('https://api.starkfi.io/yield/strategies');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER     => [
          'x-api-key: ' . $apiKey,
          'Content-Type: application/json'
      ]
  ]);

  // Make authenticated request
  $response = json_decode(curl_exec($ch), true);
  curl_close($ch);

  var_dump($response);
  ```
</CodeGroup>

<Note>
  Store your API key in a secure server-side environment variable (e.g. `STARKFI_API_KEY`). Do not expose it in frontend code or commit it to git.
</Note>

### Common API Response Errors

<AccordionGroup>
  <Accordion title="Rate Limits">
    ### Rate Limits

    API keys are subject to rate limits to ensure fair usage:

    <Card title="Rate limits" icon="timer">
      * **600 requests per minute** per API key
      * **Unlimited** number of requests **per month**.
    </Card>

    ### **Handling Rate Limits**

    When you exceed the rate limit, you’ll receive a`429 Too Many Requests`response:

    ```json theme={null}
    {
      "code": 429,
      "message": "Too many requests. The limit is 600 request per minute and 10 requests per second.",
      "docs": "https://docs.starkfi.io/"
    }
    ```
  </Accordion>

  <Accordion title="Unauthorized or API Key Invalid">
    #### Unauthorized or API Key Invalid

    Your request was rejected by the server. This error can have multiple causes:

    1. Invalid or expired API Key

    The API key provided may be incorrect, expired, or has been revoked. Please verify your key is active in the dashboard.

    2. Wrong header format

    The API key must be sent in the request header exactly as:

    x-api-key: YOUR\_KEY

    Any variation (e.g. Authorization, api\_key, X-API-Key) will result in this error.

    ```json theme={null}
    {
      "code": 403,
      "message": "Access denied. A valid API Key is required.",
      "docs": "https://docs.starkfi.io/"
    }
    ```
  </Accordion>
</AccordionGroup>
