GraphQL email mail API is a powerful tool for managing email.

Fetch and read emails with Graph-QL mail APIs. Control and inbox using MailSlurp and Graph query language instead of SMTP protocol.

  • Table of contents

graphql email accounts

MailSlurp offers powerful email inbox APIs over REST and GraphQL. The GraphQL API is accessible via HTTP POST at Let's see how we can use GraphQL to create email addresses, send and even receive emails and attachments using GraphQL.


Note you must set an x-api-key header in your GraphQL client and pass a valid MailSlurp API Key (which you can create for free here). The GraphQL endpoints cover most but not all MailSlurp functionality - for instance file upload/download is exclusive to the REST API and SDK clients.


Open GraphQL explorer

Setup code

You can call MailSlurp's GraphQL email API using any React/GraphQL client. This includes fetch, curl etc. An easier way might be using the excellent open source graphql-request library. First install the NPM dependencies

// npm install --save graphql-request
import { gql, GraphQLClient } from 'graphql-request';

Next we need to create a client that sets the x-api-key header using to the value of your MailSlurp account API KEY.

// create a new graphql-request client using the MailSlurp graphql endpoint
// and passing a headers map including your MailSlurp API Key using "x-api-key" header
const client = new GraphQLClient('', {
  headers: {
    'x-api-key': YOUR_API_KEY,

Editor config

If you want to enable auto-complete in gql, VSCode, IntelliJ, or another editor create a .graphqlconfig file in the root of your project and include this endpoint:

  "name": "Remote Schema",
  "schemaPath": "remote-schema.graphql",
  "extensions": {
    "endpoints": {
      "mailslurp": {
        "url": "",
        "headers": {
          "x-api-key": "YOUR_API_KEY"
        "introspect": true


You can make queries like so. Note that the example gql method call should use backticks ` to use template string invocation. They are shown below as double quotes " because of formatting issues. Note you can use raw strings without gql too if you prefer.

const query = gql`
    inboxes {
const { inboxes } = await client.request(query);

The great thing about graphql is that you can explore the MailSlurp API schema yourself using the provided GraphQL Playground


const { createInbox } = await client.request(gql`
  mutation {
    createInbox {

Send email

const { sendEmail } = await client.request(
    mutation SendEmail(
      $fromInboxId: String!
      $to: [String!]!
      $subject: String!
    ) {
      sendEmail(fromInboxId: $fromInboxId, to: $to, subject: $subject) {
    to: [createInbox.emailAddress],
    subject: 'Test',