gotify/server · error

appid not found

Error message

appid not found

What it means

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.

Source

Thrown at api/message.go:380

//	        $ref: "#/definitions/Error"
func (a *MessageAPI) CreateMessage(ctx *gin.Context) {
	message := model.CreateMessage{}
	if err := ctx.Bind(&message); err != nil {
		return
	}

	app := auth.GetApplication(ctx)
	if app == nil {
		if message.ApplicationID == 0 {
			ctx.AbortWithError(400, errors.New("appid is required when not authenticating with an application token"))
			return
		}
		fetchedApp, err := a.DB.GetApplicationByID(message.ApplicationID)
		if success := successOrAbort(ctx, 500, err); !success {
			return
		}
		if fetchedApp == nil || fetchedApp.UserID != auth.GetUserID(ctx) {
			ctx.AbortWithError(400, errors.New("appid not found"))
			return
		}
		app = fetchedApp
	}

	message.ApplicationID = app.ID
	if strings.TrimSpace(message.Title) == "" {
		message.Title = app.Name
	}

	if message.Priority == nil {
		message.Priority = &app.DefaultPriority
	}

	msgInternal := toInternalMessage(&message)
	if success := successOrAbort(ctx, 500, a.DB.CreateMessage(msgInternal)); !success {
		return
	}

View on GitHub (pinned to 14bfc25627)

Solutions

  1. Verify the appid exists: GET /application and find the correct ID.
  2. Ensure you authenticate as the user who owns that application.
  3. If the app is gone, create a new application and use its ID/token.
  4. Check you are connected to the intended Gotify instance.

Example fix

// before
{"appid": 99, "message":"hi"} // app 99 belongs to another user
// after
{"appid": 7, "message":"hi"} // app owned by authenticated user
Defensive patterns

Strategy: validation

Validate before calling

const apps = await fetch('/application', {headers:{'X-Gotify-Key': token}}).then(r=>r.json());
if (!apps.some(a => a.id === body.appid)) throw new Error('appid ' + body.appid + ' not found for this user');

Type guard

function appExistsForUser(apps, appid, userId) { return apps.some(a => a.id === appid && a.userId === userId); }

Try / catch

try {
  await gotify.post('/message', body);
} catch (e) {
  if (e.response?.status === 400 && /appid not found/.test(e.response.data)) {
    const apps = await gotify.get('/application');
    body.appid = apps[0].id; // recover with a valid app
  } else throw e;
}

Prevention

When it happens

Trigger: POST /message with client-token/basic auth and a body appid referencing a nonexistent app, or an app owned by another user.

Common situations: 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.

Related errors


AI-assisted analysis of gotify/server@14bfc25627 (2026-09-05). Data as JSON: /api/errors/b30e203255323966. Report an issue: GitHub.