Skip to Content
SDK ReferencesubmitRequest()

submitRequest()

Programmatically submit a bug report or feature request. This is the method the widget calls internally, but you can also use it directly for custom UIs.

const result = await maestrio.submitRequest({ title: "Button doesn't work on mobile", description: "The submit button is unresponsive on iOS Safari.", type: "bug", }); if (result.isOk()) { console.log("Request created:", result.value.id); } else { console.error("Failed:", result.error.message); }

Signature

submitRequest( params: SubmitRequestParams ): Promise<Result<SubmitRequestResponse, SdkError>>

Parameters

PropertyTypeRequiredDescription
titlestringYesA short summary of the bug or feature request.
descriptionstringYesDetailed description of the issue or suggestion.
type"bug" | "feature"YesThe type of request.
pointedElementsPointedElement[]NoDOM elements the user highlighted as relevant.

PointedElement

When using the widget’s element picker, users can select page regions related to their feedback. Each selected element is captured as:

PropertyTypeDescription
selectorstringCSS selector for the element
tagNamestringHTML tag name (e.g. "button", "div")
textstringText content of the element
htmlstringOuter HTML of the element

Return value

Returns a Result from the better-result library. This is a discriminated union that is either a success or an error.

On success

interface SubmitRequestResponse { id: string; // Unique request ID status: string; // Initial status (usually "received") queued: boolean; // Whether the request was queued for AI processing }

On error

Returns one of the following error types:

ErrorWhen
NotIdentifiedErroridentify() was not called before submitting
ValidationErrorMissing or invalid parameters
ApiErrorThe API returned a non-2xx response
NetworkErrorThe request failed to reach the server

Working with Result

const result = await maestrio.submitRequest({ title: "Add dark mode", description: "It would be great to have a dark mode option.", type: "feature", }); if (result.isOk()) { const { id, status, queued } = result.value; console.log(`Request ${id} created (status: ${status}, queued: ${queued})`); } else { const error = result.error; switch (error._tag) { case "NotIdentifiedError": console.error("User not identified"); break; case "ValidationError": console.error(`Invalid field: ${error.field}`); break; case "ApiError": console.error(`API error (${error.status}): ${error.message}`); break; case "NetworkError": console.error("Network error:", error.message); break; } }

Prerequisite

You must call identify() before submitRequest(). If the user is not identified, the method returns a NotIdentifiedError result.