{"record":{"id":"b30e203255323966","repo":"gotify/server","slug":"appid-not-found","errorCode":null,"errorMessage":"appid not found","messagePattern":"appid not found","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"api/message.go","lineNumber":380,"sourceCode":"//\t        $ref: \"#/definitions/Error\"\nfunc (a *MessageAPI) CreateMessage(ctx *gin.Context) {\n\tmessage := model.CreateMessage{}\n\tif err := ctx.Bind(&message); err != nil {\n\t\treturn\n\t}\n\n\tapp := auth.GetApplication(ctx)\n\tif app == nil {\n\t\tif message.ApplicationID == 0 {\n\t\t\tctx.AbortWithError(400, errors.New(\"appid is required when not authenticating with an application token\"))\n\t\t\treturn\n\t\t}\n\t\tfetchedApp, err := a.DB.GetApplicationByID(message.ApplicationID)\n\t\tif success := successOrAbort(ctx, 500, err); !success {\n\t\t\treturn\n\t\t}\n\t\tif fetchedApp == nil || fetchedApp.UserID != auth.GetUserID(ctx) {\n\t\t\tctx.AbortWithError(400, errors.New(\"appid not found\"))\n\t\t\treturn\n\t\t}\n\t\tapp = fetchedApp\n\t}\n\n\tmessage.ApplicationID = app.ID\n\tif strings.TrimSpace(message.Title) == \"\" {\n\t\tmessage.Title = app.Name\n\t}\n\n\tif message.Priority == nil {\n\t\tmessage.Priority = &app.DefaultPriority\n\t}\n\n\tmsgInternal := toInternalMessage(&message)\n\tif success := successOrAbort(ctx, 500, a.DB.CreateMessage(msgInternal)); !success {\n\t\treturn\n\t}","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/gotify/server/blob/14bfc256276775c425f988d621dccfe705de18ac/api/message.go#L362-L398","documentation":"CreateMessage throws 400 'appid not found' when an appid was supplied with user/client authentication but no application with that ID exists, or the application exists but is owned by a different user than the authenticated one.","triggerScenarios":"POST /message with client-token/basic auth and a body appid referencing a nonexistent app, or an app owned by another user.","commonSituations":"Typo in appid; app was deleted and IDs reused/shifted; copying appid from another Gotify instance or another user account; pointing a client at a shared server where the app belongs to someone else.","solutions":["Verify the appid exists: GET /application and find the correct ID.","Ensure you authenticate as the user who owns that application.","If the app is gone, create a new application and use its ID/token.","Check you are connected to the intended Gotify instance."],"exampleFix":"// before\n{\"appid\": 99, \"message\":\"hi\"} // app 99 belongs to another user\n// after\n{\"appid\": 7, \"message\":\"hi\"} // app owned by authenticated user","handlingStrategy":"validation","validationCode":"const apps = await fetch('/application', {headers:{'X-Gotify-Key': token}}).then(r=>r.json());\nif (!apps.some(a => a.id === body.appid)) throw new Error('appid ' + body.appid + ' not found for this user');","typeGuard":"function appExistsForUser(apps, appid, userId) { return apps.some(a => a.id === appid && a.userId === userId); }","tryCatchPattern":"try {\n  await gotify.post('/message', body);\n} catch (e) {\n  if (e.response?.status === 400 && /appid not found/.test(e.response.data)) {\n    const apps = await gotify.get('/application');\n    body.appid = apps[0].id; // recover with a valid app\n  } else throw e;\n}","preventionTips":["Sync appids from GET /application instead of hardcoding.","Re-check app IDs after app deletion or instance migration.","Use the app token of the target app rather than a raw appid.","Confirm you are on the intended Gotify instance/user."],"tags":["http-400","validation","ownership","gotify"],"backgroundTag":"resource-not-found-or-not-owned","analyzedSha":"14bfc256276775c425f988d621dccfe705de18ac","analyzedAt":"2026-09-05T12:52:36.781Z","contentChangedAt":"2026-09-05T12:52:36.781Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}