Integrate

Authorization (Your API Token)



Integrate with Airer API

To integrate with the Airer API, you can use our SDK or import it via npm:

        
        npm install airer
        
    

Or include it directly in your HTML:

        
        <script src="https://airer.vercel.app/sdk.js"></script>
        
    

To report an error using the SDK or npm, include the following in your JavaScript code:

        
          // Import Airer SDK
          const Airer = require('airer'); // Only required if using NPM

          // Initialize Airer instance with API URL and token
          const airer = new Airer('your-authorization-token');

          // Use the `report` function
          airer.report(
              { message: 'Test Error', stack: 'Test Stack' }, // ErrorConstructor use default js error
              { additional: 'This is extra context data.' } // Additional data
          )
          .then((reportID) => {
              console.log('Error report submitted successfully. Report ID:', reportID);
          })
          .catch((error) => {
              console.error('Error while submitting report:', error.message);
          });
        
    

API Documentation - Report Endpoint

POST /api/report

Endpoint to submit a report. Requires authentication via a Bearer token.

Headers

  • Authorization: Bearer <token> (required)
  • User-Agent: Automatically included by the client. Adds the user-agent to the report unless already provided in additional.

Request Body

{
     "error": "Description of the error (error constructor)",
     "additional": {
       "key": "value", // Any additional information in JSON format
       "example": "data"  
     }
   }

Response

The response returns the unique report ID if successfully created:

{
     "reportID": "uniqueReportID"
   }

Example Curl Request

curl -X POST https://airer.vercel.app/api/report \
   -H "Authorization: Bearer your_token" \
   -H "Content-Type: application/json" \
   -d '{
     "error": "An unexpected error occurred.",
     "additional": {
       "details": "More information about the error."
     }
   }'