Skip to main content
Docs

Retrieves a list of M2M tokens for a given machine. Returns a PaginatedResourceResponse object with a data property that contains an array of M2M token objects, and a totalCount property that indicates the total number of M2M tokens in the system. This endpoint can be authenticated by either a Machine Secret Key or by a Clerk .

  • When fetching M2M tokens with a Machine Secret Key, only tokens associated with the authenticated machine can be retrieved.
  • When fetching M2M tokens with a Clerk Secret Key, tokens for any machine in the instance can be retrieved.

Note

are not stored by Clerk, so they cannot be fetched via the list endpoint (clerkClient.m2m.list()). The list endpoint will only return . Additionally, since JWT verification happens client-side, Clerk cannot track last_used_at for JWT tokens.

function list(queryParams: GetM2MTokenListParams): Promise<PaginatedResourceResponse<M2MToken[]>>
  • Name
    subject
    Type
    string
    Description

    The machine ID to query M2M tokens by.

  • Name
    machineSecretKey?
    Type
    string
    Description

    Custom machine secret key for authentication. If not provided, the SDK will use the value from the environment variable.

  • Name
    revoked?
    Type
    boolean
    Description

    Whether to include revoked M2M tokens. Defaults to false.

  • Name
    expired?
    Type
    boolean
    Description

    Whether to include expired M2M tokens. Defaults to false.

  • Name
    limit?
    Type
    number
    Description

    The maximum number of M2M tokens to return. Defaults to 10.

  • Name
    offset?
    Type
    number
    Description

    The number of M2M tokens to skip before returning results. Defaults to 0.

Note

Using clerkClient varies based on your framework. Refer to the JS Backend SDK overviewClerk Icon for usage details, including guidance on how to access the userId and other propertiesClerk Icon.

const machineId = 'mt_123'

const m2mTokens = await clerkClient.m2m.list({
  subject: machineId,
})
const machineId = 'mt_123'

const m2mTokens = await clerkClient.m2m.list({
  subject: machineId,
  revoked: true,
  expired: true,
})
const machineId = 'mt_123'

const m2mTokens = await clerkClient.m2m.list({
  subject: machineId,
  limit: 20,
  offset: 0,
})

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint GET/m2m_tokens. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on