# Fuel Switch API

{% hint style="info" %}
&#x20;For more information about data format and validation, see [data-format-and-validation](https://docs.fuelswitch.io/manage-your-projects/upload-energy-data/data-format-and-validation "mention")
{% endhint %}

## Swagger

{% hint style="info" %}
All timestamps should use the ISO8601 format.

Example of a valid timestamp: `2023-09-30T22:00:00.000Z`
{% endhint %}

* Production Swagger: <https://app.fuelswitch.io/swagger>
* Sandbox Swagger: <https://app-testnet.fuelswitch.io/swagger>

The Fuel Switch API allows third-party services to interact directly with the Fuel Switch backend (instead of going through our [web application](https://app.fuelswitch.io/)). The features available are listed below.

## Sandbox Environment

We offer a complete sandbox environment that developers can use to build and test integrations with our system, without affecting anything on production. To use the sandbox, you will need an approved account on the [Fuel Switch sandbox environment](https://app-testnet.fuelswitch.io/). Sign up, verify your email, and fill out the KYC information. If the KYC approval takes longer than expected, reach out to the Fuel Switch administrator via [support@fuelswitch.io](mailto://support@fuelswitch.io) to approve your account.

The Fuel Switch production and sandbox web applications can be accessed here:

* Production Web App: <https://app.fuelswitch.io/>
* Sandbox Web App: <https://app-testnet.fuelswitch.io/>

## Base URL

The following endpoints are available for Fuel Switch:

* Production API: <https://app.fuelswitch.io/api/v1>
* Sandbox API: <https://app-testnet.fuelswitch.io/api/v1>

## Generating an API Key

To interact with the API, you first need to generate an API key. Follow these steps to create a new API key:

* **Log in to Your Account**\
  Visit the website and log into your account using your credentials.
* **Navigate to Account Settings**\
  After logging in, click on your account icon in the top-right corner of the page.\
  In the dropdown menu, select **Account Settings**.
* **Go to API Keys Section**\
  Inside Account Settings, locate and click on the **API Keys** tab. This is where you can manage your existing keys or generate new ones.
* **Generate a New API Key**\
  Click on the **Generate New Key** button.\
  You will be prompted to provide a name for your API key to help identify it in the future.
* **Copy and Store the Key**\
  After generating the key, make sure to copy it and store it securely. You will not be able to view the key again after this point.

## Authentication

* **Type**: API Key
* **Key Name**: `fuelswitch-api-key`
* **Description**: Our API uses an API key-based authentication mechanism. Each request to the API must include a valid API key in the request headers. You can generate an API key via the web UI by navigating to the **Account Settings → API Keys** section and creating a new key (see above section). Once generated, you can copy the `fuelswitch-api-key` and use it in your requests.
* **How to Use**:
  * The API key should be added to the request header of each API call as follows:

    ```json
    fuelswitch-api-key: YOUR_API_KEY
    ```
* **Example**: In a cURL request, the API key would be included like this:

  ```bash
  curl -X GET "https://app-testnet.fuelswitch.io/api/v1" \
  -H "fuelswitch-api-key: YOUR_API_KEY"
  ```
* **Important Notes**:
  * Ensure the API key is kept confidential and secure.
  * The API key is unique to your account and should be regenerated if compromised.
  * If the API key is missing or invalid, the API will return an authentication error with a message of "UNAUTHORIZED"


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fuelswitch.io/fuel-switch-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
