Preparing an API query or mutation
To fetch data from Memberful’s API or make changes to Memberful data via the API, you’ll need to prepare a query or mutation, respectively. The easiest and safest way to do this would be using the GraphQL API Explorer. This approach requires minimal setup so you can start querying the API right away. Once you’ve verified that the query or mutation works as expected, you can copy the query or mutation and use it in your own app or Zapier (if needed). Here’s a process you can follow to prepare a query or mutation (we’ll go into more detail later in this article):
Preparing an API query or mutation
- Add a Custom App under Settings → Custom applications and click Open API Explorer.
- Determine what information you need or which change you’d like to make via the API.
- Browse the API’s documentation to find out how to ask for this.
- Write the query or mutation.
- Test the query or mutation using the GraphQL API Explorer to make sure you get the desired result.

Press
Ctrl-Space to get auto-complete suggestions as you write your query or mutation.As you browse this documentation, keep in mind that fields with an exclamation mark (!) are required.
text
A string of characters (text).
whole number
An integer (whole number).
boolean
A true or false value.
identifier
A unique identifier.
Member is a type that represents a Memberful member, and contains fields of different types. When you encounter a type you don’t recognize, click on it to learn more.
Using the GraphQL API Explorer
The GraphQL API Explorer serves as live, always up-to-date documentation. It also allows you to construct and test your queries and mutations. Running queries or mutations in the GraphQL API Explorer works just like running them from your app, but without having to set up custom code that calls the API, so it’s a great place to quickly craft and test your query or mutation before worrying about whether your code works. It’s also a great way to perform one-off operations that don’t need to be automatically performed with regularity. Once you’ve added a Custom App under Settings → Custom applications, you can access our GraphQL API Explorer by clicking the Open API Explorer button for your app:
The GraphQL API Explorer makes use of your real, production data.




Calling Memberful’s API outside GraphQL explorer
This diagram shows the lifecycle of a request to Memberful’s API:
Lifecycle of an API request

Calling Memberful's API outside GraphQL explorer
- Add a Custom App under Settings → Custom applications. Copy the API key.
- Inside your app, make a test request with a short query/mutation that you’ve already tested in the GraphQL Explorer.
- If the request is successful, replace the test query/mutation with your actual query/mutation.
- Test in a real-life scenario to make sure everything’s working properly.
Calling Memberful’s API from Zapier
Zapier allows you to connect different apps together. It’s a great way to automate tasks that involve multiple apps without writing any code. You can use the Webhooks by Zapier action to call Memberful’s API from a zap. To do this, create a Webhooks by Zapier action with a POST event.
- URL:
https://ACCOUNT-URL.memberful.com/api/graphql - Payload Type:
Json - Data - 1st box:
query(regardless of whether you’re sending a query or mutation) - Data - 2nd box:
<Your query or mutation> - Headers - 1st box:
Authorization - Headers - 2nd box:
Bearer <Your API key>

Any test that you do via Zapier will use your real, production data, even as you’re going through the process of setting it up. Start with a query (which won’t make any changes) and once you’ve confirmed that it’s working, switch to a mutation if that’s what you need.
Endpoint
The Memberful GraphQL API has a single endpoint:query with your query or mutation. The endpoint will always return a JSON response, even if there was an error (although in that case, the JSON response will contain an appropriately-named “errors” object).
Authentication
Each API request needs to include an authorization header:Error handling
The GraphQL endpoint should always respond with aHTTP 200 status code. If there is a problem processing your request, the response’s “errors” payload will include details about the error.
Plans and prices in the API
The Memberful dashboard uses the terms Plan and Price, but the API uses different names for the same concepts:
A pass can have multiple plans—for example, a “Premium” pass might offer both a $10/month and a $100/year plan. All plans on the same pass give members the same access, so if your integration makes access decisions, use the
Pass, not the individual Plan.
You can query passes directly with pass(id:) or passes, and each Plan links back to its parent Pass via the pass field. The Subscription type also exposes a pass field for convenience.
Several fields on the Plan type that duplicate data now owned by Pass—like name, requireAddress, and taxable—are deprecated. Use the nested pass { … } field instead. Refer to the API Explorer for the full list of deprecated fields and their replacements.
Queries and mutations
Memberful’s API supports both queries and mutations. Queries allow you to fetch data from Memberful’s API. Mutations allow you to create, update, or delete data.Pagination
Queries that can return many records use pagination. Instead of returning every record in one response, Memberful returns a smaller group, or page, of records at a time.For a complete walkthrough, watch How to use Memberful’s API starting at 24:24. The video demonstrates forward pagination in the GraphQL API Explorer.
Identify a paginated query
In the API Explorer, a query requires pagination when it accepts these four arguments:first: Returns the first specified number of records.after: Returns records that come after a particular cursor.last: Returns the last specified number of records.before: Returns records that come before a particular cursor.
first and after.
Request the first page
Start by usingfirst to choose how many records to return.
For example, this query requests the first 10 members:
nodes: The member records returned on the current page.pageInfo: Information about the current page and whether more records are available.startCursor: The cursor for the first record on the current page.endCursor: The cursor for the last record on the current page.hasNextPage: Whether more records are available after the current page.hasPreviousPage: Whether records are available before the current page.
Request the next page
WhenhasNextPage is true, copy the value of endCursor and pass it to the after argument in your next query.
For example:
1
Run the query
Send the query using your chosen
first value.2
Process the records
Process the records returned in
nodes.3
Check for another page
Review
hasNextPage to determine whether more records are available.4
Request the next page
When
hasNextPage is true, use endCursor as the next query’s after value.5
Stop pagination
Stop when
hasNextPage is false.Paginate backward
You can also move backward through a result set usinglast and before:
- Use
lastto choose how many records to return. - Use
beforewith the starting cursor from the current page.
first and after is simpler.
Pagination example
The following sequence retrieves records in groups of 100:1
Request the first group
Send
members(first: 100).2
Save the records
Save the records returned in
nodes.3
Check for more records
Review
pageInfo.hasNextPage.4
Request the next group
When
hasNextPage is true, send members(first: 100, after: pageInfo.endCursor).5
Repeat the process
Continue until
hasNextPage is false.
API Pagination
