Auto Accept Quests[]
by cTheDragons
(Note: An upgraded version of this script with an easy step-by-step setup guide with pictures can be found on this link)
Updated Version August 2025[]
In August, 2025, Habitica API changes caused errors in User:CTheDragons original script. The following script will run, or you can explore the alternatives linked above.
Run hourly, this script will join a quest automatically if the invite is available in your party.
- Go to script.google.com. If this is your first script, this will automatically create a new Google script for you and open an editor for it. Otherwise, edit an existing project by clicking the pencil icon next to it, or create another.
- If you already have the old script, delete it or remove the trigger.
- Paste the code snippet below into the editor, replacing the spaces marked #HabiticaUserID# and #HabiticaAPIToken# with Habitica User ID and API Token (leave the single quotes). These can be found under https://habitica.com/user/settings/general Site Settings).
function autoAcceptHabiticaQuest() {
const habiticaUserId = 'UserID'; // ← Replace with your User ID, keep single quotes
const habiticaApiToken = 'API Token'; // ← Replace with your API Token, keep single quotes
const userAgentId = 'scheduleJoinQuest'; // ← Any unique name, in single quotes
const headers = { 'x-api-user': habiticaUserId, 'x-api-key': habiticaApiToken, 'x-client': userAgentId, 'Content-Type': 'application/json' };
const partyUrl = 'https://habitica.com/api/v3/groups/party';
try { // Get party info
const partyResponse = UrlFetchApp.fetch(partyUrl, {
method: 'get',
headers: headers,
muteHttpExceptions: true
});
const partyData = JSON.parse(partyResponse.getContentText());
if (!partyData.success) { throw new Error(`Failed to fetch party info: ${partyData.message}`); }
const quest = partyData.data.quest;
// Check for pending quest invitation
const isQuestPending = quest.key && !quest.active && !quest.members[habiticaUserId];
if (isQuestPending) {
const acceptUrl = 'https://habitica.com/api/v3/groups/party/quests/accept';
const acceptResponse = UrlFetchApp.fetch(acceptUrl, { method: 'post', headers: headers, muteHttpExceptions: true });
const acceptData = JSON.parse(acceptResponse.getContentText());
if (acceptData.success) {
Logger.log('✅ Quest accepted successfully!'); }
else { Logger.log(`⚠️ Failed to accept quest: ${acceptData.message}`); } }
else { Logger.log('ℹ️ No pending quest to accept.'); } }
catch (e) { Logger.log(`❌ Error: ${e.message}`);
}
}
- From the sidebar on the left, select Triggers. Then add a trigger that runs scheduleJoinQuest Time-driven on an Hour timer with the parameter of Every hour.
- Save and you're done!
Original Version[]
This software stopped working after late July 2025 when Habitica started enforcing x-client requirements.
Information about the API change can be found at Application Programming Interface.
Run hourly, this script will join a quest automatically if the invite is available in your party.
- Go to script.google.com. If this is your first script, this will automatically create a new Google script for you and open an editor for it. Otherwise, edit an existing project by clicking the pencil icon next to it, or create another.
- Paste the code snippet below into the editor, replacing the spaces marked #HabiticaUserID# and #HabiticaAPIToken# with Habitica User ID and API Token (leave the quotes). These can be found under the API tab in your Habitica settings.
function scheduleJoinQuest() {
var habId = "#HabiticaUserID#";
var habToken = "#HabiticaAPIToken#";
var paramsTemplate = {
"method" : "get",
"headers" : {
"x-api-user" : habId,
"x-api-key" : habToken
}
}
var response = UrlFetchApp.fetch("https://habitica.com/api/v3/groups/party", paramsTemplate);
var party = JSON.parse(response);
if ((party.data.quest.key != undefined) && (party.data.quest.active != true) && (party.data.quest.members[habId] == undefined)){
paramsTemplate = {
"method" : "post",
"headers" : {
"x-api-user" : habId,
"x-api-key" : habToken
}
}
var params = paramsTemplate;
UrlFetchApp.fetch("https://habitica.com/api/v3/groups/party/quests/accept", params)
}
}
OR more clear code below:
const scheduleJoinQuest = () => {
const habId = '#HabiticaUserID#';
const habToken = '#HabiticaAPIToken#';
const partyAPI = 'https://habitica.com/api/v3/groups/party';
const headers = {
'x-api-user': habId,
'x-api-key': habToken,
};
const response = UrlFetchApp.fetch(
partyAPI,
{
method: 'get',
headers
}
);
const { data: { quest } } = JSON.parse(response);
if (quest.key && !quest.active && !quest.members[habId]) {
UrlFetchApp.fetch(
`${partyAPI}/quests/accept`,
{
method: 'post',
headers
}
);
}
}
- From the sidebar on the left, select Triggers. Then add a trigger that runs scheduleJoinQuest Time-driven on an Hour timer with the parameter of Every hour.
- Save and you're done!