Amba

Achievements

Badges and achievements that unlock automatically based on event counts, streak lengths, or XP thresholds.

Achievements are badges that unlock automatically when users meet specific criteria. They can award bonus XP on unlock and support hidden achievements.

How it works

  1. Admin defines achievements with criteria (event count, streak length, XP threshold, or property value)
  2. Amba evaluates criteria in the background
  3. When a user meets the criteria, the achievement unlocks and optional bonus XP is awarded
  4. Hidden achievements only appear in the user's list after being unlocked

SDK usage

Get all achievements with progress

const achievements = await client.achievements.getAll();
// Returns achievements with unlock status and progress:
// [
//   { key: "first_workout", name: "First Workout", unlocked_at: "2025-01-10T...", progress: { current: 1, target: 1 } },
//   { key: "streak_master_7", name: "Streak Master", unlocked_at: null, progress: { current: 4, target: 7 } }
// ]

Get a specific achievement

const achievement = await client.achievements.get('streak_master_7');

Criteria types

TypeDescriptionRequired fields
event_countTrack an event N timesevent_name, target_value
streak_lengthMaintain a streak for N daysstreak_definition_id, target_value
xp_thresholdReach N total XPtarget_value
property_valueUser property reaches Nproperty_key, target_value

Manual grant & revoke (support & moderation)

Achievements normally unlock through automatic criteria evaluation. For support, promos, or corrections you can also award or claw one back for a specific user with amba_achievements_grant and amba_achievements_revoke (REST: POST /admin/achievements/:id/grant, POST /admin/achievements/:id/revoke).

A manual grant is idempotent — re-granting an already-unlocked achievement keeps the original unlock time. It does not auto-award the achievement's xp_reward (that's reserved for a genuine criteria-driven unlock); award XP separately with amba_xp_grant if you want it. Revoke removes the user's unlock entirely, returning a not-found error if they didn't hold it.

Agent: "Manually unlock the launch-day badge for our beta testers"
amba_achievements_grant({ project_id: "proj_xxx", achievement_id: "ach_xxx", app_user_id: "user_xxx" })

Agent: "That badge was awarded by mistake — take it back"
amba_achievements_revoke({ project_id: "proj_xxx", achievement_id: "ach_xxx", app_user_id: "user_xxx" })

Admin API reference

MethodPathDescription
POST/admin/achievementsCreate achievement
GET/admin/achievementsList all achievements
POST/admin/achievements/:id/grantManually unlock for a user (support)
POST/admin/achievements/:id/revokeClaw back a user's unlock

Client API reference

MethodPathDescription
GET/client/achievementsGet all achievements with user progress
GET/client/achievements/:idGet specific achievement with progress

MCP tools

ToolDescription
amba_achievements_createCreate an achievement with criteria and optional XP reward
amba_achievements_listList all achievements for a project
amba_achievements_grantManually unlock an achievement for a user (support / promo)
amba_achievements_revokeClaw back a user's unlock (inverse of grant)

Example: Fitness app achievements

Agent: "Create achievements for a fitness app"

amba_achievements_create({
  key: "first_workout",
  name: "First Workout",
  description: "Complete your first workout",
  xp_reward: 100,
  criteria: { type: "event_count", event_name: "workout_completed", target_value: 1 }
})

amba_achievements_create({
  key: "streak_master_7",
  name: "Streak Master",
  description: "Maintain a 7-day workout streak",
  xp_reward: 500,
  criteria: { type: "streak_length", streak_definition_id: "streak_xxx", target_value: 7 }
})

amba_achievements_create({
  key: "xp_legend",
  name: "XP Legend",
  description: "Earn 10,000 XP",
  xp_reward: 1000,
  is_hidden: true,
  criteria: { type: "xp_threshold", target_value: 10000 }
})

On this page