Admin Package (REST)
The Memberstack REST Admin API allows you to verify webhooks and JWT tokens, and use CRUD methods on Members.
Getting Started
Authentication
The Memberstack Admin API uses secret keys to authenticate requests. You can view and manage your API keys in the Memberstack dashboard.
Test mode (sandbox) secret keys have the prefix sk_sb_
and live mode secret keys have the prefix sk_live_
.
Rate Limits -> 25 requests per second.
Secret Keys -> Your Secret keys carry administrative privileges, so keep them secure and use them in server-side environments only! Do not use your secret keys in publicly accessible places like Webflow, GitHub, or client-side code.
Memberstack REST API
Base REST URL:
https://admin.memberstack.com
Use X-API-KEY
headers with your secret key to authenticate with the API.
"X-API-KEY": "sk_sb_..."
Actions
List all members
List all members connected to your application.
URL Parameters:
after
number
TheendCursor
after which the querying should start.order
ASC | DESC
The order in which the members should be queried. Default:ASC
limit
number
The maximum amount of members to query. Default:50
Request Example:
curl --location --request GET 'https://admin.memberstack.com/members' \
--header 'x-api-key: sk_sb_...'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
await axios.get(BASE_URL, { headers })
Response:
totalCount
number
The total amount of queryable members.endCursor
number
TheendCursor
of the last queried member.hasNextPage
boolean
An indicator showing whether there are more members to query.data
boolean
List of queried members.
Response Example:
{
totalCount: 2,
endCursor: 456,
hasMore: false,
data: [
{
id: "mem_...",
createdAt: "2022-05-19T18:57:35.143Z",
lastLogin: "2022-05-19T18:57:35.143Z",
auth: {
email: "john@doe.com"
},
customFields: {
country: "Germany"
},
metaData: {
avatar: "photo.png"
},
loginRedirect: "/john-welcome",
permissions: ["view:basic:workouts"],
planConnections: [
{
id: "con_...",
status: "ACTIVE"
planId: "pln_...",
type: "FREE",
payment: null
},
]
},
{
id: "mem...",
createdAt: "2021-04-20T18:57:35.143Z",
lastLogin: "2022-05-19T18:57:35.143Z",
auth: {
email: "jane@doe.com"
},
customFields: {
country: "USA"
},
metaData: {
avatar: "photo2.png"
},
loginRedirect: "/jane-welcome",
permissions: ["view:all:workouts"],
planConnections: [
{
id: "con_...",
status: "ACTIVE"
planId: "pln_...",
type: "FREE",
payment: null
},
]
},
]
}
Retrieve a member
Retrieve a member by their id or email.
URL Parameters:
id
string
Theid
of the member to retrieve
OR
email
string
The
email
of the member to retrieve
Request Example With ID:
curl --location --request GET 'https://admin.memberstack.com/members/mem_sb_cl3ddkq070005njvl997d9mf8' \
--header 'x-api-key: sk_sb_...'
Request Example With ID and Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
await axios.get(`${BASE_URL}/mem_sb_cl3ddkq070005njvl997d9mf8`, { headers })
Request Example With Email:
👉 We recommend URI encoding the email before adding it as a param.
curl --location --request GET 'https://admin.memberstack.com/members/example%40test.com' \
--header 'x-api-key: sk_sb_...'
Request Example With Email and Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
await axios.get(`${BASE_URL}/example%40test.com`, { headers })
Response:
data
object
TheMember
object
Response Example:
{
data: {
"id": "mem_sb_cl3ddkq070005njvl997d9mf8",
"auth": {
"email": "user-1652986650386@test.com"
},
"createdAt": "2022-05-19T18:57:35.143Z",
"lastLogin": "2022-05-19T18:57:35.143Z",
"metaData": {
"language": "Swedish"
},
"customFields": {
country: "Sweden"
},
"permissions": ["per_basic"],
"loginRedirect": "login-redirect-1",
"planConnections": [{
"id": "con_cl3ddkq060004njvl2zx6cnub",
"active": true,
"status": "ACTIVE",
"planId": "pln_sb_cl3d9q5yi00040tczdir41rsy",
"planName": "My Awesome Free Plan",
"type": "FREE",
"payment": null
}]
}
}j
Create a member
Create a member connected to a free plan.
URL Parameters:
email required
string
The member's emailpassword required
string
The member's passwordplans
array
Optional for free plans. Array of planId objects.[{"planId": "pln_abc"}]
customFields
object
Optional custom fields.metaData
object
Optional metadata object.json
object
Optional json object.loginRedirect
string
Optional loginRedirect
Request Example:
curl --location --request POST 'https://admin.memberstack.com/members' \
--header 'x-api-key: sk_sb_...'
--header 'Content-Type: application/json' \
--data-raw '{
"email": "john2@doe.com",
"password": "123123123",
"plans": [
{
"planId": "pln_abc123"
}
],
"customFields": {
"country": "Sweden"
},
"metaData": {
"language": "Swedish"
},
"json": {
"counter": 5
},
"loginRedirect": "/welcome"
}'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
const data = {
email: "john2@doe.com",
password: "123123123",
plans: [{
"planId": "pln_abc123"
}],
customFields: {
country: "Sweden"
},
json: {
friends: ["mem_123...", "mem_456..."]
},
metaData: {
language: "Swedish"
},
loginRedirect: "/welcome"
}
await axios.post(BASE_URL, data, { headers })
Response:
data
object
TheMember
object
Response Example:
{
data: {
"id": "mem_sb_cl3ddkq070005njvl997d9mf8",
"auth": {
"email": "user-1652986650386@test.com"
},
"createdAt": "2022-05-19T18:57:35.143Z",
"metaData": {
"hi": "there"
},
json: {
friends: ["mem_123...", "mem_456..."]
},
"customFields": {
"name": "Tyler"
},
"permissions": ["per_basic"],
"loginRedirect": "login-redirect-1",
"planConnections": [{
"id": "con_cl3ddkq060004njvl2zx6cnub",
"active": true,
"status": "ACTIVE",
"planId": "pln_sb_cl3d9q5yi00040tczdir41rsy",
"type": "FREE",
"payment": null
}]
}
}
Update a member
Update a member by their id.
URL Parameters:
id required
string
Theid
of the member to update.
Request Example:
curl --location --request PATCH 'https://admin.memberstack.com/members/mem_..' \
--header 'x-api-key: sk_sb_...'
--header 'Content-Type: application/json' \
--data-raw '{
"customFields": {
country: "Sweden"
},
"email": "updated-email@test.com"
"metaData": {
"language": "Swedish"
},
json: {
friends: ["mem_123...", "mem_456..."]
},
}'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
const data = {
customFields: {
country: "Sweden"
},
metaData: {
language: "Swedish"
},
json: {
friends: ["mem_123...", "mem_456..."]
},
}
await axios.post(`$BASE_URL}/mem_...`, data, { headers })
Response:
data
object
TheMember
object
Response Example:
{
data: {
"id": "mem_sb_cl3ddkq070005njvl997d9mf8",
"auth": {
"email": "user-1652986650386@test.com"
},
"createdAt": "2022-05-19T18:57:35.143Z",
"metaData": {
"language": "Swedish"
},
"customFields": {
country: "Sweden"
},
"permissions": ["per_basic"],
"loginRedirect": "login-redirect-1",
"planConnections": [{
"id": "con_cl3ddkq060004njvl2zx6cnub",
"active": true,
"status": "ACTIVE",
"planId": "pln_sb_cl3d9q5yi00040tczdir41rsy",
"type": "FREE",
"payment": null
}]
}
}
Delete a member
Delete a member by their id.
URL Parameters:
id required
string
Theid
of the member to deletedeleteStripeCustomer
boolean
optional - delete stripe customer associated with membercancelStripeSubscriptions
boolean
optional - cancel subscriptions associated with member
Request Example:
curl --location --request DELETE 'https://admin.memberstack.com/members/mem_sb_cl3ddkq070005njvl997d9mf8' \
--header 'x-api-key: sk_sb_...'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
const data = {
deleteStripeCustomer: true, // default false
cancelStripeSubscriptions: true // default false
}
await axios.delete(`${BASE_URL}/mem_sb_cl3ddkq070005njvl997d9mf8`, data, { headers })
Response:
data
string
The deletedmember's
id.
Response Example:
{
data: {
"id": "mem_..."
}
}
Add a free plan to a member
Add a free plan to a member.
URL Parameters:
planId required
string
TheplanId
of the plan to add
Request Example:
curl --location --request POST 'https://admin.memberstack.com/members/mem_sb_cl3ddkq070005n/add-plan' \
--header 'x-api-key: sk_sb_...'
--header 'Content-Type: application/json' \
--data-raw '{
"planId": "pln_abc"
}'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
const data = {
planId: "pln_abc"
}
await axios.post(`${BASE_URL}/mem_sb_cl3ddkq070005n/add-plan`, data, { headers })
Response:
200
status
Remove free plan from a member
Remove a free plan from a member.
URL Parameters:
planId required
string
TheplanId
of the plan to remove
Request Example:
curl --location --request POST 'https://admin.memberstack.com/members/mem_sb_cl3ddkq070005n/remove-plan' \
--header 'x-api-key: sk_sb_...'
--header 'Content-Type: application/json' \
--data-raw '{
"planId": "pln_abc"
}'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY
const BASE_URL = 'https://admin.memberstack.com/members'
const headers = { "X-API-KEY": API_KEY }
const data = {
planId: "pln_abc"
}
await axios.post(`${BASE_URL}/mem_sb_cl3ddkq070005n/remove-plan`, data, { headers })
Response:
200
status
Verification
Verify member token
Verify a member’s token.
Parameters:
token
string
Thetoken
to verify
Request Example:
curl --location --request POST 'https://admin.memberstack.com/members/verify-token' \
--header 'x-api-key: sk_sb_...' \
--header 'Content-Type: application/json' \
--data-raw '{"token": "your_token_here"}'
Request Example With Axios:
var axios = require('axios');
const API_KEY = process.env.MEMBERSTACK_SECRET_KEY;
const BASE_URL = 'https://admin.memberstack.com/members';
const headers = {
"X-API-KEY": API_KEY,
"Content-Type": "application/json" // Ensure the content type is set to application/json
};
const token = "your_token_here"; // Replace 'your_token_here' with the actual token value
await axios.post(`${BASE_URL}/verify-token`, { token }, { headers });
Response:
data
object
TheMember
object
Response Example:
{
data: {
"id": "mem_sb_cl50gxp5u0001xfvl3fn81131",
"type": "member",
"iat": 1681414876,
"exp": 1682624476,
"aud": "app_cf3d3n9fh00027tcz48xr7dkp",
"iss": "https://api.memberstack.com"
}
}
Last updated