GraphQL API

With MoonMail GraphQL API you have full access to all MoonMail features.
This API requires authentication and intended to be used server side.

If you want to know how GraphQL API works, check out How to GraphQL.

If you don't have a MoonMail account already, you’ll need to create one in order to use the GraphQL API.

GraphQL API Explorer

If you want to start playing with the API immediately, you can do it in the GraphQL API Explorer of your MoonMail account. You can run Queries and Mutations in the explorer to have and idea about what the MoonMail GraphQL API can offer you. The API Explorer is available to all the MoonMail users.

note

Heads up! MoonMail's GraphQL Explorer makes use of your real, live, production data.

Authentication

The API uses API keys to authenticate requests. You can view and manage your API key in the MoonMail Dashboard.

Your API key full access to all MoonMail resources, so be sure to keep it secure! Do not share your secret API key in publicly accessible areas such as GitHub, client-side code, and so forth.

Include your API Key as an Authorization header in all your GraphQL requests.

GraphQL API Endpoint

POST https://graphql.moonmail.io

Query GraphQL API

You can access GraphQL API endpoint using cURL or any other HTTP client.

curl --request POST 'https://graphql.moonmail.io' \
--header 'Authorization: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{Account {Id Status}}"}'
note

You can explore GraphQL API Queries and Mutations in the interactive GraphQL API Explorer in you MoonMail Dashboard.

Example Queries

In GraphQL, queries are the equivalent of REST’s GET action verb. Even though a POST is being sent to the GraphQL endpoint, if the body only contains queries, data will only be retrieved and not modified.

Query the Contact by Address

query {
Contact(Address: "email@example.com") {
Address
Attributes {
Key
Value
}
UserAttributes {
Key
Value
}
UserId
Metrics {
Key
Value
}
CreationDate
Demographic {
AppVersion
Locale
Make
Model
ModelVersion
Platform
PlatformVersion
Timezone
}
Id
OptOut
Location {
City
Country
Latitude
Longitude
PostalCode
Region
}
CohortId
}
}

Example Mutations

Mutations are the equivalent of REST’s data-modifying action verbs.

mutation {
putContacts(
input: {
Contacts: {
Address: "email@example.com"
UserAttributes: {Value: "John Doe", Key: "Name"}
}
}
) {
Address
Id
UserAttributes {
Key
Value
}
OptOut
UserId
}
}