The Memberstack REST Admin API allows you to perform full CRUD (create, read, update, delete) operations on members as well as verify member tokens (JWTs) programmatically in your JavaScript application. (There is no REST endpoint for verifying webhooks; see the Webhook Events Reference for verifying them with the @memberstack/admin package.) This enables you to build custom admin panels, sync members with external databases, integrate with third-party services, and more. The Admin API uses standard REST conventions with JSON request and response bodies, making it easy to use with any JavaScript HTTP client like axios or the native fetch API.
View the full Admin Package Guide for more additional guidance.
1) Getting Started
Authentication
The Admin REST Package uses secret API keys to authenticate requests. You can find your API keys in your Memberstack dashboard under Developer → Keys & IDs.
Use your sk_sb_... key for development and sk_... in production.
Here's an example using axios to authenticate requests:
const apiKey = process.env.MEMBERSTACK_API_KEY;
const headers = { "X-API-KEY": apiKey };
const axios = require('axios');
axios.get('https://admin.memberstack.com/members', {headers});Rate Limits - 25 requests per second. Memberstack will not increase the rate limits.
Security - Keep your secret keys secure and use only in server-side code, not client-side.
2) Base URL
The base URL for all requests is:
https://admin.memberstack.com 3) Actions
List Members
Get a paginated list of members:
const url = 'https://admin.memberstack.com/members';
axios.get(url, {headers}).then(res => {
console.log(res.data);
});Optional parameters:
- after - The
endCursorfrom the previous response (each response also hashasNextPageandtotalCount) - order - ASC or DESC
- limit - Max number to return (default 50, maximum 100)
Get a Member
Get a member by id:
const memberId = 'mem_1234';
const url = `https://admin.memberstack.com/members/${memberId}`;
axios.get(url, {headers}).then(res => {
console.log(res.data);
});Or by email:
const email = 'john@doe.com';
const encodedEmail = encodeURIComponent(email);
const url = `https://admin.memberstack.com/members/${encodedEmail}`;
axios.get(url, {headers}).then(res => {
console.log(res.data);
});Create a Member
const url = 'https://admin.memberstack.com/members';
const data = {
email: 'john@doe.com',
password: 'password123',
plans: [{planId: 'pln_1234'}],
};
axios.post(url, data, {headers}).then(res => {
console.log(res.data);
// Created member
});Required parameters:
- email - The member's email
- password - The member's password
Optional parameters:
- plans - Free plans only. Array of planId objects. [{"planId": "pln_abc"}]
- customFields - Object of custom fields.
- metaData - Metadata object.
- json - JSON object.
- loginRedirect - loginRedirect string.
Update a Member
const memberId = 'mem_1234';
const url = `https://admin.memberstack.com/members/${memberId}`;
const data = {
customFields: {
country: 'Sweden'
}
};
axios.patch(url, data, {headers}).then(res => {
console.log(res.data);
// Updated member
});Delete a Member
const memberId = 'mem_1234';
const url = `https://admin.memberstack.com/members/${memberId}`;
axios.delete(url, {headers}).then(res => {
console.log(res.data);
// Deleted member ID
});Add/Remove Free Plans
const memberId = 'mem_1234';
// Add plan
const addUrl = `https://admin.memberstack.com/members/${memberId}/add-plan`;
await axios.post(addUrl, {planId: 'pln_4567'}, {headers}); // responds with the text "OK"
// Remove plan
const removeUrl = `https://admin.memberstack.com/members/${memberId}/remove-plan`;
await axios.post(removeUrl, {planId: 'pln_4567'}, {headers});4) Verify a Token
const url = 'https://admin.memberstack.com/members/verify-token';
axios.post(url, {token: 'jwt_token'}, {headers}).then(res => {
console.log(res.data);
// Verified member
})The response is { data: { id, type, iat, exp, aud, iss } }, where id is the member ID. The endpoint only accepts tokens issued for the app your secret key belongs to; any other token gets a 400 with code INVALID_TOKEN. Logging out doesn't invalidate a token: it keeps verifying until it expires.
Alternative: Raw HTTP API Verification (No SDK)
If you do not want to parse the JWT cryptography locally and prefer to offload the verification to Memberstack via standard HTTP POST, you can call our raw token verification endpoint directly.
- Endpoint: POST https://admin.memberstack.com/members/verify-token
- Headers:
- X-API-KEY: YOUR_SECRET_KEY (Your sk_... or sk_sb_... key)
- Content-Type: application/json
- JSON Payload:
Comments
No comments yet. Start the conversation below.
Please sign in to leave a comment.