Auth
In order to interact with the reportgen API, you need to authenticate your API requests using an access token. This token can be generated through the website or via the API itself.
Authentication Method
All API requests must include an X-API-Key header containing your access token. Without this token, the API will return a 401 Unauthorized error.
Example Request
Here's an example of how you would include the X-API-Key in a request:
curl -X GET "https://reportgen.io/api/v1/reports" \
-H "X-API-Key: YOUR_ACCESS_TOKEN"
Access Keys
Access keys are generated either through the API or on the website. When generating a key via the API, you'll need to provide a name for the key. Once the key is generated, the value of the key will be returned only once. If you forget to save it, you'll need to generate a new one, as the key is hashed and stored securely.
Create an Access Key via API
To create an access key via the API, send a POST request to /access-keys:
curl -X POST "https://reportgen.io/api/v1/access-keys" \
-H "X-API-Key: YOUR_EXISTING_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "My Access Key"
}'
This will return a response with the access key value:
{
"data": "YOUR_NEW_ACCESS_KEY"
}
Remember, this access key will only be shown once.
Retrieve Access Keys
You can retrieve a list of your existing access keys using the following endpoint:
curl -X GET "https://reportgen.io/api/v1/access-keys" \
-H "X-API-Key: YOUR_ACCESS_TOKEN"
This will return a list of keys associated with your account, including their names and creation dates.
Delete an Access Key
To delete an access key, make a DELETE request to /access-keys/{accessKeyID}:
curl -X DELETE "https://reportgen.io/api/v1/access-keys/ACCESS_KEY_ID" \
-H "X-API-Key: YOUR_ACCESS_TOKEN"
This action is irreversible, and the access key will no longer be usable for API calls.
Error Responses
If you fail to include a valid access token in your request, you'll receive a 401 Unauthorized response:
{
"error": "unauthorized"
}
In the event of server errors, you might encounter a 500 Internal Server Error. Ensure that your requests are properly formatted and authenticated.