Skip to main content

Widget API Reference

The BugPin Widget API is a public REST API that allows any application to submit bug reports programmatically, without using the browser-based widget. This is useful for building custom feedback forms, server-side report submission, automated testing pipelines, or integrating with non-browser environments. Authentication uses API key headers rather than session cookies.

Submit Report​

Submit a new bug report.

POST /api/widget/submit

Authentication​

Provide the API key via query parameter or header:

# Query parameter
POST /api/widget/submit?apiKey=your-project-api-key

# Header
POST /api/widget/submit
X-Api-Key: your-project-api-key

Request Body (JSON)​

{
"title": "Button not working on checkout page",
"description": "When I click the submit button, nothing happens.",
"priority": "high",
"reporterName": "John Doe",
"reporterEmail": "[email protected]",
"metadata": {
"url": "https://example.com/checkout",
"title": "Checkout - Example Store",
"referrer": "https://example.com/cart",
"browser": {
"name": "Chrome",
"version": "120.0.0",
"userAgent": "Mozilla/5.0..."
},
"device": {
"type": "desktop",
"os": "macOS",
"osVersion": "14.0"
},
"viewport": {
"width": 1920,
"height": 1080,
"devicePixelRatio": 2,
"orientation": "landscape"
},
"timestamp": "2024-01-15T10:30:00.000Z",
"timezone": "America/New_York",
"pageLoadTime": 1234,
"consoleErrors": [
{
"type": "error",
"message": "Uncaught TypeError: Cannot read property 'submit' of null",
"source": "checkout.js",
"line": 42,
"timestamp": "2024-01-15T10:29:55.000Z"
}
]
}
}

Request Body (Multipart Form Data)​

For requests with screenshots:

curl -X POST "https://bugs.example.com/api/widget/submit?apiKey=your-project-api-key" \
-F 'data={"title":"Bug report","description":"Description here","priority":"medium","metadata":{...}}' \

Fields​

FieldTypeRequiredDescription
titlestringYesReport title (4-200 characters)
descriptionstringNoDetailed description
prioritystringNolowest, low, medium (default), high, highest
reporterNamestringNoName of the person reporting
reporterEmailstringNoEmail of the reporter
metadataobjectYesBrowser and page context
annotationsobjectNoAnnotation data from the editor

Metadata Object​

FieldTypeRequiredDescription
urlstringYesCurrent page URL
titlestringNoPage title
referrerstringNoReferring page URL
browserobjectYesBrowser information
deviceobjectYesDevice information
viewportobjectYesViewport dimensions
timestampstringYesISO 8601 timestamp
timezonestringNoUser's timezone
pageLoadTimenumberNoPage load time in ms
consoleErrorsarrayNoCaptured console errors

Browser Object​

FieldTypeDescription
namestringBrowser name (Chrome, Firefox, Safari, etc.)
versionstringBrowser version
userAgentstringFull user agent string

Device Object​

FieldTypeDescription
typestringdesktop, tablet, or mobile
osstringOperating system name
osVersionstringOS version (optional)

Viewport Object​

FieldTypeDescription
widthnumberViewport width in pixels
heightnumberViewport height in pixels
devicePixelRationumberDevice pixel ratio
orientationstringlandscape or portrait (optional)

Console Error Object​

FieldTypeDescription
typestringerror, warn, or log
messagestringError message
sourcestringSource file (optional)
linenumberLine number (optional)
timestampstringWhen the error occurred

Success Response​

{
"success": true,
"reportId": "rpt_abc123def456",
"message": "Bug report submitted successfully"
}

Error Responses​

401 Unauthorized - Missing or invalid API key:

{
"success": false,
"error": "UNAUTHORIZED",
"message": "API key is required"
}

403 Forbidden - Origin not allowed:

{
"success": false,
"error": "FORBIDDEN",
"message": "Origin not allowed"
}

400 Bad Request - Validation error:

{
"success": false,
"error": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"field": "title",
"message": "Title must be at least 4 characters"
}
]
}

429 Too Many Requests - Rate limited:

{
"success": false,
"error": "RATE_LIMITED",
"message": "Too many requests"
}

Get Widget Configuration​

Retrieve widget configuration for a project.

GET /api/widget/config/:apiKey

Parameters​

ParameterLocationDescription
apiKeypathProject API key

Success Response​

{
"success": true,
"config": {
"projectName": "My Project",
"branding": {},
"brandingPrimaryColor": "#6366f1",
"features": {
"screenshot": true,
"annotation": true,
"attachments": false,
"consoleCapture": true
},
"theme": "auto",
"position": "bottom-right",
"buttonText": null,
"buttonShape": "rectangle",
"buttonIcon": "bug",
"buttonIconSize": 18,
"buttonIconStroke": 2,
"lightButtonColor": "#6366f1",
"lightTextColor": "#ffffff",
"lightButtonHoverColor": "#4f46e5",
"lightTextHoverColor": "#ffffff",
"darkButtonColor": "#818cf8",
"darkTextColor": "#1e1b4b",
"darkButtonHoverColor": "#a5b4fc",
"darkTextHoverColor": "#1e1b4b",
"dialogLightButtonColor": "#ebebeb",
"dialogLightTextColor": "#575757",
"dialogLightButtonHoverColor": "#ebebeb",
"dialogLightTextHoverColor": "#575757",
"dialogDarkButtonColor": "#3c3c3c",
"dialogDarkTextColor": "#c3c3c3",
"dialogDarkButtonHoverColor": "#3c3c3c",
"dialogDarkTextHoverColor": "#c3c3c3",
"enableHoverScaleEffect": true,
"tooltipEnabled": false,
"tooltipText": null,
"captureMethod": "visible",
"useScreenCaptureAPI": false
}
}

Error Response​

404 Not Found - Invalid API key:

{
"success": false,
"error": "NOT_FOUND",
"message": "Project not found"
}

Example: Custom Integration​

Here's a complete example of submitting a bug report from a custom form:

async function submitBugReport(formData) {
const metadata = {
url: window.location.href,
title: document.title,
referrer: document.referrer,
browser: {
name: getBrowserName(),
version: getBrowserVersion(),
userAgent: navigator.userAgent,
},
device: {
type: getDeviceType(),
os: getOS(),
},
viewport: {
width: window.innerWidth,
height: window.innerHeight,
devicePixelRatio: window.devicePixelRatio,
},
timestamp: new Date().toISOString(),
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
};

const response = await fetch("https://bugs.example.com/api/widget/submit", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Key": "your-project-api-key",
},
body: JSON.stringify({
title: formData.title,
description: formData.description,
priority: formData.priority || "medium",
reporterName: formData.name,
reporterEmail: formData.email,
metadata,
}),
});

const result = await response.json();

if (result.success) {
console.log("Report submitted:", result.reportId);
} else {
console.error("Submission failed:", result.message);
}

return result;
}

With Screenshot Upload​

async function submitWithScreenshot(formData, screenshotBlob) {
const metadata = {
/* ... same as above ... */
};

const body = new FormData();
body.append(
"data",
JSON.stringify({
title: formData.title,
description: formData.description,
priority: formData.priority || "medium",
metadata,
}),
);
body.append("media", screenshotBlob, "screenshot.png");

const response = await fetch(
"https://bugs.example.com/api/widget/submit?apiKey=your-project-api-key",
{
method: "POST",
body,
},
);

return response.json();
}

We use cookies for analytics to improve our website. More information in our Privacy Policy.