Me

The Me resource returns information about the currently authenticated identity — useful for verifying your API key, checking scopes, and discovering which organizations and projects you have access to.

Methods

MethodDescription
me.get()Fetch auth context: identity, organizations, API key details

me.get()

typescript
const { data: me } = await client.me.get()
 
console.log(me.id)    // User or key ID
console.log(me.email) // Authenticated email
console.log(me.name)  // Display name
 
// API key details (only present for apiKey auth)
if (me.apiKey) {
  console.log(me.apiKey.name)   // Key name from the console
  console.log(me.apiKey.prefix) // First 8 chars (e.g., 'ck_live_')
  console.log(me.apiKey.scopes) // ['tasks:read', 'tasks:write', ...]
}
 
// Organization memberships
for (const org of me.organizations) {
  console.log(org.name, org.slug, org.role) // 'Acme Corp', 'acme', 'admin'
}

Common uses

Validate an API key at startup:

typescript
async function validateApiKey() {
  try {
    const { data: me } = await client.me.get()
    console.log(`Authenticated as ${me.email}`)
    return true
  } catch (err) {
    if (err instanceof ClockworkError && err.status === 401) {
      console.error('Invalid API key')
      return false
    }
    throw err
  }
}

Check if a scope is available before calling:

typescript
const { data: me } = await client.me.get()
const scopes = me.apiKey?.scopes ?? []
 
const canWrite = scopes.includes('*') || scopes.includes('tasks:write')
if (!canWrite) {
  throw new Error('This key does not have tasks:write scope')
}

Type reference

typescript
interface Me {
  id: string
  email: string
  name: string
  organizations: MeOrganization[]
  apiKey?: MeApiKey
}
 
interface MeOrganization {
  id: string
  name: string
  slug: string
  role: 'owner' | 'admin' | 'member'
}
 
interface MeApiKey {
  id: string
  name: string
  prefix: string
  scopes: string[]
}