A small TypeScript project for creating MantisBT support tickets through the MantisBT REST API.
It builds a MantisBT issue payload, sends it to /api/rest/issues, and returns the created issue ID with the raw API response.
- Node.js (npm)
- A MantisBT instance
- A MantisBT API token
git clone https://github.com/ItsLeon15/MantisBT-Create-Support-Ticket-API.git
cd MantisBT-Create-Support-Ticket-API
npm installImport createSupportTicket and pass in the ticket data:
import { createSupportTicket } from "./logic.js";
const ticket = await createSupportTicket({
summary: "Login button does not work",
description: "When clicking the login button, nothing happens.",
project: {
id: 1,
},
category: {
id: 1,
},
});
console.log(ticket.issueId);
console.log(ticket.raw);summary
description
project
category
steps_to_reproduce
reporter
handler
priority
severity
resolution
os
platform
os_version
tags
custom_fields
files
notes
Some MantisBT values can be referenced by ID or name.
project: {
id: 1
}project: {
name: "Example Project"
}Users can be referenced by ID, username, or email.
handler: {
id: 1
}handler: {
name: "administrator"
}handler: {
email: "admin@example.com"
}File content must be base64 encoded.
files: [
{
name: "example.txt",
content: Buffer.from("Example file content").toString("base64"),
}
]createSupportTicket returns:
{
issueId: number | null;
raw: MantisCreateIssueResponseBody | null;
}├── src
│ ├── fullTicket.ts
│ ├── logic.ts
│ ├── minimalTickett.ts
│ └── type.ts
├── .env.example
├── .gitignore
├── README.md
├── package.json
└── tsconfig.json- The project and category must already exist in MantisBT.
- Custom fields must already exist and be linked to the selected project.
- Tags must already exist unless the API user can create or apply them.
- Attachments must be base64 encoded.
- The API token user must have permission to create issues.
- Some fields may require extra MantisBT permissions.
This project is licensed under the MIT License. See the LICENSE file for details.