Getting started with Midflight
Welcome to Midflight's integration guide. By following the steps below, you'll be ready to send your emails with Midflight in no time. If you use Ruby on Rails check the Rails integration guide.
1. Before we start
Make sure you have your API key provided by Midflight. You can find it in the onboarding page of your project or in the settings page.
2. Make a POST request to our API
Integrating Midflight with your app is straightforward. Just make a POST request to your unique email ingress URL including a couple of headers. The body of the request should contain either the full RFC 822 content of the email or a JSON payload. Here's an example request using the POST
method:
POST https://mailbox.midflight.io/YOUR_API_KEY/ingress HTTP/1.1
content-type: message/rfc822
X-Midflight-Template: password_recovery
X-Midflight-Locale: en
…RFC 822 content…
POST https://mailbox.midflight.io/YOUR_API_KEY/ingress HTTP/1.1
content-type: application/json
X-Midflight-Template: password_recovery
X-Midflight-Locale: en
{
from: "support@acme.com",
subject: "Forgot your password?",
body: "<html>…</html>"
}
Detailed explanation:
https://mailbox.midflight.io/YOUR_API_KEY/ingress
: This is your unique ingress URL. Don't forget to replace the API key with the one provided by Midflight.
X-Midflight-Template
: Set this to a unique identifier for each mail template.
X-Midflight-Locale
: This should be set to the locale of the email, allowing for proper localization tracking within Midflight.
3. Test your integration
After setting up the code, send a test email to verify that Midflight is capturing it. You should see the email appear on your Midflight dashboard.
Troubleshooting
If your emails aren't appearing in Midflight:
- Double-check your API key.
- Make sure you're setting the headers correctly in every request.
- Review your environment settings to ensure emails are being sent.
For further assistance, reach out to us at support@midflight.io.