Skip to main content
This function and all other functions in this graphql sdk are deprecated. Please migrate to the new rest api.
This operation is only available on the server.

Required Permissions

  • member:basic:read
  • member:email:read (optional)
  • member:phone:read (optional)

Usage

import { whopSdk } from "@/lib/whop-sdk";

const result = await whopSdk.companies.listMembers({
	// ID of the company, either the tag (biz_xxx) or the page route (whop-dev)
	companyId: "biz_XXXXXXXX" /* Required! */,

	after: "pageInfo.endCursor",

	before: "pageInfo.startCursor",

	direction: "asc" /* Valid values: asc | desc */,

	first: 10,

	last: 10,

	order:
		"created_at" /* Valid values: created_at | id | joined_at | most_recent_action | usd_total_spent */,

	filters: {
		// The access pass IDs to filter the members by
		accessPassIds: ["xxxxxxxxxxx"],

		// The end date to filter the members by
		endDate: 1716931200,

		// The membership status to filter the members by
		membershipStatus:
			"active" /* Valid values: active | canceled | completed | drafted | expired | past_due | trialing | unresolved */,

		// The most recent actions to filter the members by
		mostRecentActions: [
			"canceling" /* Valid values: canceling | churned | drafted | expiring | finished_split_pay | joined | left | paid_once | paid_subscriber | past_due | paused | pending_entry | renewing | trialing */,
		],

		// The plan IDs to filter the members by
		planIds: ["xxxxxxxxxxx"],

		// The promo code IDs to filter the members by
		promoCodeIds: ["xxxxxxxxxxx"],

		// The name, username, or email to filter the members by. The email filter will
		// only apply if the current actor has the `member:email:read` permission.
		query: "some string",

		// The start date to filter the members by
		startDate: 1716931200,

		// The statuses to filter the members by
		statuses: ["drafted" /* Valid values: drafted | joined | left */],

		// The tracking link IDs to filter the members by
		trackingLinkIds: ["xxxxxxxxxxx"],
	},
});

Example output

const result = {
	// The members for the company
	members: {
		// The total number of items in this connection.
		totalCount: 10,

		// Information to aid in pagination.
		pageInfo: {
			// When paginating backwards, the cursor to continue.
			startCursor: "some string",

			// When paginating backwards, are there more items?
			hasPreviousPage: true,

			// When paginating forwards, are there more items?
			hasNextPage: true,

			// When paginating forwards, the cursor to continue.
			endCursor: "some string",
		},

		// A list of nodes.
		nodes: [
			{
				// The ID of the member
				id: "xxxxxxxxxxx",

				// When the member was created
				createdAt: 1716931200,

				// The timestamp (in milliseconds since epoch) of when the product member was last updated
				updatedAtMs: "9999999",

				// When the member joined the company
				joinedAt: 1716931200,

				// The status of the member
				status: "drafted" /* Valid values: drafted | joined | left */,

				// The phone number for the member, if available.
				phone: "some string",

				// The access level of the product member. If its admin, the member is an
				// authorized user of the company. If its customer, the member has a valid
				// membership to any product on the company. If its no_access, the member does
				// not have access to the product.
				accessLevel: "admin" /* Valid values: admin | customer | no_access */,

				// How much they have spent on the company's passes.
				totalSpent: 10,

				// How much they have spent on the company's passes.
				usdTotalSpent: "some string",

				// An estimated MRR for the member.
				mrr: "some string",

				// The user for this member, if any.
				user: {
					// The internal ID of the user account.
					id: "xxxxxxxxxxx",

					// The digital mailing address of the user.
					email: "some string",

					// The user's full name.
					name: "some string",

					// The whop username.
					username: "some string",
				},

				// The image for the member, derived from either the User or the Company Buyer.
				imageSrcset: {
					// Image url with requested image resolution.
					original: "some string",
				},
			},
		],
	},
};