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.
A string of characters (text).
An integer (whole number).
A true or false value.
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:
Important: 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>

Important: 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.
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 potentially return large numbers of records will require pagination to navigate the large result set. Pagination in GraphQL can be a bit tricky at first, so we’ve prepared this color-coded cheatsheet to help explain how to use pagination:
API Pagination
after
, before
, first
, last
.
