API reference

Mailbox, file, calendar, and contact migrations, account authorization, and webhooks.

Migrata Systems Public API

Programmatic access to mailbox, file, calendar, and contact migrations, account authorization, and webhook callbacks. Version v1 on the Production API (https://api.migrata.systems).

Overview

The Migrata Systems Public API lets you create and monitor mailbox, file, calendar, and contact migrations on behalf of your users. Typical flow:

  1. Validate mailbox credentials with POST /v1/validate-credentials, or file, calendar, and contact credentials with the matching /validate route.
  2. Create a mailbox migration with POST /v1, or a file, calendar, or contact migration with POST /v1/files, /calendars, or /contacts.
  3. Authorize OAuth accounts by opening sourceAuthorizationUrl and destinationAuthorizationUrl in the user's browser. Do not send the API key on that redirect.
  4. Receive webhooks as the migration progresses, or poll GET /v1/{id}.

Base URL & Versioning

This page is served by the Production API. Sample requests below use https://api.migrata.systems.

EnvironmentBase URL
Testhttps://test.api.migrata.systems
QAhttps://qa.api.migrata.systems
Production (this server)https://api.migrata.systems

All endpoints are prefixed with /v1. Breaking changes ship under a new version prefix; additive changes are made in place.

Authentication

Every request must include your API key in the X-Api-Key header. Keys are issued from your Migrata Systems dashboard. The same key starts mail, file, calendar, and contact jobs.

X-Api-Key: mm_live_3f9c…a01b
Content-Type: application/json
Keep keys secret. Treat API keys like passwords. Never expose them in browsers, mobile apps, or public repositories. Rotate immediately on suspected leak.

Scopes

Each API key is granted one or more scopes. The endpoint reference below shows the required scope.

ScopeGrants
credentials:validateValidate mailbox, file, calendar, and contact credentials without creating a migration.
migrations:createCreate mail, file, calendar, and contact jobs, and register an OAuth app.
migrations:readRead job status and OAuth app status.

Rate Limits

PolicyApplies toLimit
DefaultAll public endpoints60 requests / minute per API key (fallback: per client IP).
ValidationPOST /v1/validate-credentials and the file, calendar, and contact /validate routes10 requests / minute per API key (stricter, because it probes external servers).

When exceeded, the API returns HTTP 429 Too Many Requests. Back off and retry with exponential delay.

Errors

Errors return a stable JSON envelope and an appropriate HTTP status code.

{
  "code": "validation_failed",
  "message": "One or more fields are invalid.",
  "details": {
	"source": ["Source server, username and password are required."]
  }
}
HTTPCommon codesMeaning
400invalid_body, validation_failed, invalid_idThe request is malformed or fails validation.
401—Missing or invalid X-Api-Key.
403—The API key is valid but does not have the required scope.
404not_foundResource does not exist or is not owned by this key.
429—Rate limit exceeded.
500—Unexpected server error. Safe to retry with backoff.

POST/v1/validate-credentials

Scope: credentials:validateRate limit: validation

Performs an IMAP login attempt against the supplied source and/or destination mailbox. Recommended pre-flight before creating a migration, because incorrect credentials are the most common failure mode.

Request body

FieldTypeNotes
sourceMailboxEndpoint?Optional. At least one of source or destination is required.
destinationMailboxEndpoint?Optional. At least one of source or destination is required.

MailboxEndpoint

FieldTypeDefaultNotes
serverstring—IMAP hostname. May be left blank to trigger autoconfig from the email address.
portint993IMAP port.
usernamestring—Usually the full email address. Required.
passwordstring—IMAP password or app-password. Required. Sent in plaintext over TLS; never logged.
useSslbooltrueUse implicit TLS (recommended).

Example request

POST /v1/validate-credentials HTTP/1.1
Host: api.migrata.systems
X-Api-Key: mm_live_…
Content-Type: application/json

{
  "source": {
	"server": "imap.gmail.com",
	"port": 993,
	"username": "alice@example.com",
	"password": "app-password-xxxx",
	"useSsl": true
  },
  "destination": {
	"server": "outlook.office365.com",
	"port": 993,
	"username": "alice@contoso.com",
	"password": "s3cret",
	"useSsl": true
  }
}

Example response (200 OK)

{
  "source": {
	"verified": true,
	"server": "imap.gmail.com",
	"port": 993,
	"useSsl": true,
	"providerName": "Gmail",
	"failureReason": null,
	"message": "Login succeeded."
  },
  "destination": {
	"verified": false,
	"server": "outlook.office365.com",
	"port": 993,
	"useSsl": true,
	"providerName": "Microsoft 365",
	"failureReason": "auth_failed",
	"message": "Authentication failed. Check the username and password."
  }
}

Failure reasons

CodeMeaning
auth_failedServer reachable; username/password rejected.
host_unreachableCould not establish a TCP connection.
tls_errorTLS handshake failed (certificate or protocol).
timeoutConnection or login timed out.
unknown_hostDNS lookup failed for the supplied server.
invalid_emailSupplied username is not a valid address and autoconfig was needed.
internal_errorUnexpected server-side error.

POST/v1

Scope: migrations:create

Creates and queues a single mailbox migration. Returns 201 Created with the new migration's status object, including a stable id that you can poll or expect in webhook events.

Request body

FieldTypeNotes
namestringRequired. Human-readable label.
sourceMailboxEndpointRequired.
destinationMailboxEndpointRequired.
foldersstring[]Optional. If empty, all folders are migrated.
fromDateISO-8601 datetimeOptional date-range filter (inclusive).
toDateISO-8601 datetimeOptional date-range filter (inclusive). Must be ≥ fromDate.
startAtISO-8601 datetimeOptional. UTC time when the copy may begin. Omit it to queue the migration immediately. A value with an offset is converted to UTC. Digits with no offset are already UTC. A time that is not in the future is rejected.
returnUrlstringOptional https URL. After consent, the browser returns to that origin with id and status only. The origin must already be registered. Omit it to use the Migrata Systems completion page.
oauthAppIdnumberOptional. Use an OAuth app your organization registered. Omit it to use Migrata's application.

Example request

POST /v1 HTTP/1.1
Host: api.migrata.systems
X-Api-Key: mm_live_…
Content-Type: application/json

{
  "name": "Alice → Contoso",
  "source": {
	"server": "imap.gmail.com", "port": 993, "useSsl": true,
	"username": "alice@example.com", "password": "app-password-xxxx"
  },
  "destination": {
	"server": "outlook.office365.com", "port": 993, "useSsl": true,
	"username": "alice@contoso.com", "password": "s3cret"
  },
  "folders": ["INBOX", "Sent", "Archive"],
  "fromDate": "2023-01-01T00:00:00Z"
}

Example response (201 Created)

{
  "id": "mig_8f3c1d2b5a",
  "name": "Alice → Contoso",
  "status": "Scheduled",
  "statusMessage": null,
  "totalMessages": 0,
  "messagesCopied": 0,
  "totalSizeBytes": 0,
  "sizeBytesCopied": null,
  "createdAt": "2025-01-15T12:04:08Z",
  "startAt": null,
  "startedAt": null,
  "completedAt": null,
  "error": null
}

GET/v1/{id}

Scope: migrations:read

Returns the current status of a single migration.

Path parameters

NameTypeNotes
idstringThe migration id returned by POST /v1.

Response fields

FieldTypeNotes
idstringPublic migration id.
kindstringmail, files, calendar, or contacts.
namestringThe label you supplied.
statusstringawaiting_authorization until every OAuth account has consented. Then Scheduled, Running, Completed, Failed, or Cancelled.
sourceAuthorizationUrlstring?Present while the source account still needs consent. Open it in the user's browser. Do not send the API key on that redirect.
destinationAuthorizationUrlstring?Same for the destination account.
statusMessagestring?Optional context for the current status.
totalMessagesintTotal messages discovered to migrate.
messagesCopiedintMessages copied so far.
totalSizeBytesnumberTotal size to migrate, in bytes.
sizeBytesCopiednumber?Size copied so far, in bytes.
createdAtdatetimeUTC.
startAtdatetime?UTC time the copy may begin. Null when the migration was not scheduled. This is not the moment the worker started.
startedAtdatetime?Set when the worker begins.
completedAtdatetime?Set on terminal status.
errorstring?Failure reason on Failed.

GET/v1/bulk-migrations/{id}

Scope: migrations:read

Returns a bulk mailbox migration summary including all child jobs. File, calendar, and contact jobs are read with GET /v1/{id}.

Example response (200 OK)

{
  "id": "bulk_2a91…",
  "label": "Acme tenant cutover",
  "status": "Running",
  "totalJobs": 25,
  "completedJobs": 9,
  "failedJobs": 1,
  "totalSizeBytes": 187234567890,
  "totalCost": 49.50,
  "currency": "USD",
  "createdAt": "2025-01-15T11:00:00Z",
  "jobs": [
	{ "id": "mig_…", "name": "user1@acme.com", "status": "Completed", "...": "..." }
  ]
}

Files, calendars, and contacts

Create scope: migrations:createValidate scope: credentials:validate

The same key that creates a mailbox migration also creates file, calendar, and contact migrations. Send X-Product-Key when you want a specific product recorded on the job. When that header is absent, files use filemigrata, calendars use calendarmigrata, and contacts use contactmigrata.

CreateValidatekind
POST /v1/filesPOST /v1/files/validatefiles
POST /v1/calendarsPOST /v1/calendars/validatecalendar
POST /v1/contactsPOST /v1/contacts/validatecontacts

A create returns 201 Created and the same status object as POST /v1, including kind. GET /v1/{id} finds a mail, file, calendar, or contact job owned by this key. Another organization's id is 404.

returnUrl and oauthAppId mean the same thing as on a mailbox create. Omit oauthAppId to use Migrata's application. The consent screen then shows the name Mailmigrata. A logo you upload for the partnership can appear on the pages around that redirect.

Shared fields

FieldTypeNotes
namestringRequired label.
source / destinationobjectRequired. provider and username are required on each side.
startAtdatetimeOptional UTC start. Same rules as a mailbox create.
returnUrlstringOptional https URL whose origin is already registered.
oauthAppIdnumberOptional. An OAuth app this organization registered.

OAuth providers reject a password and reject a refresh token with 400. Password providers accept the password once. It is stored encrypted and is never returned. The public API does not list folders, calendars, or contacts.

Password providers

KindproviderRequired besides username and password
filess3 or awss3bucket. Username is the access key and password is the secret. region is optional. Set server only when it is an http:// or https:// service URL.
filesftp or ftpsserver. Port defaults to 21. useSsl defaults to true, which stores the side as FTPS. Send useSsl: false for plain FTP, or set provider to ftps.
fileswebdavAn https URL in baseUrl or server.
calendarcaldavAn https URL in baseUrl or server.
contactscarddavAn https URL in baseUrl or server.

Validate asks the provider whether the password side can sign in. OAuth validate reports whether that account has already authorized Mailmigrata. A validate call does not create a job.

Example — Dropbox file migration

POST /v1/files HTTP/1.1
Host: api.migrata.systems
X-Api-Key: mm_live_…
Content-Type: application/json

{
  "name": "Alice files",
  "source": { "provider": "dropbox", "username": "alice@example.com" },
  "destination": { "provider": "dropbox", "username": "alice@contoso.com" }
}
{
  "id": "mig_files_1",
  "kind": "files",
  "name": "Alice files",
  "status": "awaiting_authorization",
  "sourceAuthorizationUrl": "https://api.migrata.systems/v1/authorize/mig_files_1/source",
  "destinationAuthorizationUrl": "https://api.migrata.systems/v1/authorize/mig_files_1/destination"
}

OAuth providers

Create the job with the provider value in this table. The response sourceAuthorizationUrl and destinationAuthorizationUrl are browser links on this API. Opening one redirects to the provider. Do not send the API key on that request. The provider URL's client_id, redirect_uri, state, and scope belong to Migrata. The examples use the placeholder client id migrata-application. The redirect URI is Migrata's callback at https://api.migrata.systems/api/oauth/callback. Every provider URL also includes code_challenge and code_challenge_method=S256.

After the user consents, the browser returns to your registered returnUrl origin, or to Migrata's completion page, with id and status only. The query never includes a code or a token. Until every required side has consented, GET /v1/{id} stays awaiting_authorization. The job is not claimable until then. A password-only job is queued at create.

Register each https origin on the API Keys panel before you send returnUrl. The origin is scheme, host, and port. A path is ignored. A URL with a username or password in it is rejected. An origin that is not on the list returns 400.

Mailbox

Gmail — provider gmail

{ "provider": "gmail", "username": "alice@example.com" }
https://accounts.google.com/o/oauth2/v2/auth?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://mail.google.com/%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&access_type=offline&prompt=consent

Outlook — provider outlook

Mailbox consent stays on Outlook IMAP. Files, calendars, and contacts use a separate Microsoft Graph consent, because one Microsoft authorization cannot mix those scopes.

{ "provider": "outlook", "username": "alice@contoso.com" }
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://outlook.office.com/IMAP.AccessAsUser.All%20offline_access%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&response_mode=query&prompt=select_account

Files

Google Drive — googledrive

{ "provider": "googledrive", "username": "alice@example.com" }
https://accounts.google.com/o/oauth2/v2/auth?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://www.googleapis.com/auth/drive%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&access_type=offline&prompt=consent

OneDrive — onedrive

{ "provider": "onedrive", "username": "alice@contoso.com" }
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://graph.microsoft.com/Files.ReadWrite%20https://graph.microsoft.com/User.Read%20offline_access%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&response_mode=query&prompt=select_account

SharePoint — sharepoint

SharePoint adds the library scopes and asks for consent again.

{ "provider": "sharepoint", "username": "alice@contoso.com" }
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://graph.microsoft.com/Files.ReadWrite%20https://graph.microsoft.com/User.Read%20offline_access%20openid%20email%20https://graph.microsoft.com/Files.ReadWrite.All%20https://graph.microsoft.com/Sites.Read.All&code_challenge=example-challenge&code_challenge_method=S256&response_mode=query&prompt=consent

Dropbox — dropbox

{ "provider": "dropbox", "username": "alice@example.com" }
https://www.dropbox.com/oauth2/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=files.metadata.read%20files.metadata.write%20files.content.read%20files.content.write%20account_info.read&code_challenge=example-challenge&code_challenge_method=S256&token_access_type=offline

Box — box

{ "provider": "box", "username": "alice@example.com" }
https://account.box.com/api/oauth2/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=root_readwrite&code_challenge=example-challenge&code_challenge_method=S256

Zoho WorkDrive — zoho

Set dataCenter to eu, in, au, or cn when the account is not in the United States. Omit dataCenter to use com.

{ "provider": "zoho", "username": "alice@example.com", "dataCenter": "eu" }
https://accounts.zoho.eu/oauth/v2/auth?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=WorkDrive.files.ALL,WorkDrive.teamfolders.ALL,ZohoFiles.files.READ,ZohoFiles.files.CREATE&code_challenge=example-challenge&code_challenge_method=S256&access_type=offline&prompt=consent

pCloud — pcloud

hostname is api.pcloud.com or eapi.pcloud.com. Omit it to use api.pcloud.com. Any other hostname is 400. The authorize host stays https://my.pcloud.com and the provider URL omits scope.

{ "provider": "pcloud", "username": "alice@example.com", "hostname": "eapi.pcloud.com" }
https://my.pcloud.com/oauth2/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&code_challenge=example-challenge&code_challenge_method=S256

Calendars

Zoho is not a calendar provider. Any other name returns 400.

Google Workspace

{ "provider": "Google Workspace", "username": "alice@example.com" }
https://accounts.google.com/o/oauth2/v2/auth?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://www.googleapis.com/auth/calendar%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&access_type=offline&prompt=consent

Microsoft 365

{ "provider": "Microsoft 365", "username": "alice@contoso.com" }
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://graph.microsoft.com/Calendars.ReadWrite%20https://graph.microsoft.com/User.Read%20offline_access%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&response_mode=query&prompt=select_account

Contacts

Google Workspace

{ "provider": "Google Workspace", "username": "alice@example.com" }
https://accounts.google.com/o/oauth2/v2/auth?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://www.googleapis.com/auth/contacts%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&access_type=offline&prompt=consent

Microsoft 365

{ "provider": "Microsoft 365", "username": "alice@contoso.com" }
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=https://graph.microsoft.com/Contacts.ReadWrite%20https://graph.microsoft.com/User.Read%20offline_access%20openid%20email&code_challenge=example-challenge&code_challenge_method=S256&response_mode=query&prompt=select_account

Zoho

Omit dataCenter to use com. This example uses eu.

{ "provider": "Zoho", "username": "alice@example.com", "dataCenter": "eu" }
https://accounts.zoho.eu/oauth/v2/auth?client_id=migrata-application&redirect_uri=https://api.migrata.systems/api/oauth/callback&response_type=code&state=state-id.state-secret&scope=ZohoContacts.contactapi.ALL&code_challenge=example-challenge&code_challenge_method=S256&access_type=offline&prompt=consent

Your own OAuth app

An approved MSP can register the OAuth application the user consents to. The dashboard panel is OAuth apps. The same operations are on this API. Another organization's app id is 404. These routes require an MSP key.

MethodPathScopeResult
POST/v1/oauth-appsmigrations:create201 with id and status only.
GET/v1/oauth-apps/{id}migrations:readProvider, client id, mode, status, account email, granted scopes, and the last error. The secret is not returned.
DELETE/v1/oauth-apps/{id}migrations:create204. Stored grants for that app are removed.
POST/v1/oauth-apps/{id}/authorizemigrations:createMode A. Returns authorizationUrl.
GET/v1/oauth-apps/{id}/authorizenoneBrowser hop. Do not send the API key. Redirects to the provider.
POST/v1/oauth-apps/{id}/tokenmigrations:createMode B only. The response is id and status.
POST/v1/oauth-apps/{id}/testmigrations:createRead-only profile or organization check. This does not send mail.

The client secret is sent once and is not returned. A certificate is accepted for a Microsoft application-mode app only, as base64, and is not returned. Hosted and token apps start as pending_consent. Application mode starts as active.

Mode A — hosted redirect

Use Migrata's redirect URI. This API does not accept a different redirect URI. The consent screen shows your app name and your client id. Pass the returned id as oauthAppId on the migration.

POST /v1/oauth-apps HTTP/1.1
Host: api.migrata.systems
X-Api-Key: mm_live_…
Content-Type: application/json

{
  "provider": "gmail",
  "clientId": "msp-application",
  "mode": "hosted"
}
{ "id": 17, "status": "pending_consent" }
POST /v1 HTTP/1.1
Host: api.migrata.systems
X-Api-Key: mm_live_…
Content-Type: application/json

{
  "name": "Alice Gmail",
  "oauthAppId": 17,
  "source": { "provider": "gmail", "username": "alice@example.com" },
  "destination": { "provider": "gmail", "username": "alice@contoso.com" }
}

POST /v1/oauth-apps/17/authorize returns authorizationUrl. That URL points at GET /v1/oauth-apps/17/authorize?state=state-id.state-secret and carries no API key. The provider then sees your client id and Migrata's redirect URI.

Mode B — supply a refresh token

Only an app created with mode token accepts this call. A hosted app and an application-mode app reject it. The body field is refreshToken. Optional vault is outlook or msgraph for Microsoft. Omit vault to use Microsoft Graph. The response has no token.

POST /v1/oauth-apps/17/token HTTP/1.1
Host: api.migrata.systems
X-Api-Key: mm_live_…
Content-Type: application/json

{
  "refreshToken": "paste-the-refresh-token",
  "accountEmail": "alice@example.com"
}
{ "id": 17, "status": "active" }

Microsoft application mode

Set provider to microsoft and mode to application. Send the client secret once, or a certificate, and an optional tenantId. There is no end-user redirect. Mailbox IMAP stays a delegated consent. The test calls Microsoft Graph and reads the organization. It does not send mail. Google domain-wide delegation is not offered.

Provider checklist

Google

  • Create a web application OAuth client in Google Cloud.
  • Set the authorized redirect URI to Migrata's redirect URI. Do not register a different one for Mode A.
  • The consent screen name and the client id are yours.
  • Enable Gmail, Drive, Calendar, and People for the products you migrate.

Microsoft

  • Register an app in Microsoft Entra and add Migrata's redirect URI as a web redirect.
  • Mailbox jobs stay delegated IMAP. File, calendar, and contact jobs use Microsoft Graph.
  • Application mode is Microsoft only. It needs a client secret or a certificate and does not redirect an end user.
  • One Microsoft app covers mailbox and Graph consent. tenantId defaults to common.

Dropbox, Box, pCloud, and Zoho

  • Create a web app at the provider and set the redirect URI to Migrata's redirect URI.
  • Dropbox consent requests offline access.
  • Zoho dataCenter is eu, in, au, or cn. Omit it for com.
  • pCloud hostname is api.pcloud.com or eapi.pcloud.com. Omit it for api.pcloud.com.
  • The consent screen shows your app name and your client id.

POST /v1/oauth-apps/{id}/test returns id, status, verified, and message. A failed check is stored on the app. The call does not send mail.


Webhooks — Overview

Instead of polling, you can receive HTTP POST callbacks to a URL of your choice whenever a migration or bulk migration changes state. Each API key is associated with at most one webhook URL.

Configuration

Webhook destination is stored alongside your API key. It is configured by setting two fields on the key record:

FieldTypeNotes
clientWebhookUrlstringHTTPS URL that will receive events. http:// is rejected in production.
clientWebhookApiKeystring?Optional shared secret. When set, MailMigrata sends it in the X-MailMigrata-Client-Key header so your endpoint can authenticate the caller. Also used to compute the signature in X-MailMigrata-Signature.
Set these via the dashboard or your account API. A single key may emit events for many migrations; all of them are delivered to the same URL.

Event Types

EventWhen
migration.scheduledA migration was created and queued.
migration.startedThe worker began processing the migration.
migration.progressPeriodic progress update (throttled; not every message).
migration.completedMigration finished successfully.
migration.failedMigration failed terminally.
bulk.progressA bulk migration aggregate counter changed.
bulk.completedAll child jobs reached a terminal state.

Payload & Headers

Headers sent on every delivery

HeaderNotes
Content-Type: application/jsonBody is UTF-8 JSON.
User-Agent: MailMigrata-Webhook/1.0Identifies the sender.
X-MailMigrata-EventEvent type, e.g. migration.completed.
X-MailMigrata-DeliveryUnique delivery id. Use to de-duplicate retries.
X-MailMigrata-TimestampUnix seconds (UTC) when the payload was signed.
X-MailMigrata-Signaturesha256=… HMAC of {timestamp}.{body}. See below.
X-MailMigrata-Client-KeyEchoes clientWebhookApiKey if you set one. Useful for trivial auth.

Example payload — migration.progress

{
  "event": "migration.progress",
  "deliveryId": "evt_01J6Z9K…",
  "occurredAt": "2025-01-15T12:34:56Z",
  "data": {
	"id": "mig_8f3c1d2b5a",
	"name": "Alice → Contoso",
	"status": "Running",
	"totalMessages": 12450,
	"messagesCopied": 3120,
	"totalSizeBytes": 9876543210,
	"sizeBytesCopied": 2517394621,
	"createdAt": "2025-01-15T12:04:08Z",
	"startedAt": "2025-01-15T12:05:11Z",
	"completedAt": null,
	"error": null
  }
}

Example payload — migration.failed

{
  "event": "migration.failed",
  "deliveryId": "evt_01J6ZA2…",
  "occurredAt": "2025-01-15T13:01:22Z",
  "data": {
	"id": "mig_8f3c1d2b5a",
	"name": "Alice → Contoso",
	"status": "Failed",
	"error": "Source authentication failed after 3 attempts."
  }
}

Signature Verification

If you configured clientWebhookApiKey, MailMigrata signs every payload so you can confirm it came from us and was not modified.

  1. Read X-MailMigrata-Timestamp (Unix seconds) and the raw request body.
  2. Reject if the timestamp is more than 5 minutes from your server clock (protects against replays).
  3. Compute HMAC_SHA256(secret = clientWebhookApiKey, message = "{timestamp}.{body}") and hex-encode.
  4. Compare to the value after sha256= in X-MailMigrata-Signature using a constant-time comparison.

Node.js verification

import crypto from "node:crypto";

export function verifyMailMigrataSignature(req, secret) {
  const ts  = req.header("X-MailMigrata-Timestamp");
  const sig = req.header("X-MailMigrata-Signature") || "";
  const raw = req.rawBody; // Buffer — capture before JSON parsing
  if (!ts || !raw) return false;
  if (Math.abs(Date.now()/1000 - Number(ts)) > 300) return false;

  const expected = "sha256=" + crypto
	.createHmac("sha256", secret)
	.update(`${ts}.`).update(raw)
	.digest("hex");

  const a = Buffer.from(sig);
  const b = Buffer.from(expected);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

C# verification

using System.Security.Cryptography;
using System.Text;

public static bool VerifyMailMigrataSignature(
	string timestamp, string signatureHeader, byte[] body, string secret)
{
	if (!long.TryParse(timestamp, out var ts)) return false;
	var skew = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - ts;
	if (Math.Abs(skew) > 300) return false;

	using var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret));
	hmac.TransformBlock(Encoding.UTF8.GetBytes(timestamp + "."), 0,
		timestamp.Length + 1, null, 0);
	hmac.TransformFinalBlock(body, 0, body.Length);
	var expected = "sha256=" + Convert.ToHexString(hmac.Hash!).ToLowerInvariant();

	return CryptographicOperations.FixedTimeEquals(
		Encoding.ASCII.GetBytes(expected),
		Encoding.ASCII.GetBytes(signatureHeader ?? ""));
}

Retry Policy

  • Success: any 2xx response within 10 seconds.
  • Retries: up to 8 attempts with exponential backoff (≈ 30s, 1m, 2m, 5m, 10m, 30m, 1h, 6h).
  • After the final attempt, the delivery is marked failed. The underlying migration state is unaffected.
  • De-duplicate using X-MailMigrata-Delivery — the same event may be delivered more than once.
  • Respond fast: process asynchronously after returning 200.

Quickstart — cURL

# 1. Validate credentials
curl -sS https://api.migrata.systems/v1/validate-credentials \
  -H "X-Api-Key: $MM_KEY" \
  -H "Content-Type: application/json" \
  -d '{
	"source":      {"server":"imap.gmail.com","username":"alice@example.com","password":"app-pwd"},
	"destination": {"server":"outlook.office365.com","username":"alice@contoso.com","password":"s3cret"}
  }'

# 2. Create migration
curl -sS https://api.migrata.systems/v1 \
  -H "X-Api-Key: $MM_KEY" \
  -H "Content-Type: application/json" \
  -d '{
	"name":"Alice → Contoso",
	"source":      {"server":"imap.gmail.com","username":"alice@example.com","password":"app-pwd"},
	"destination": {"server":"outlook.office365.com","username":"alice@contoso.com","password":"s3cret"}
  }'

# 3. Poll status (or rely on webhooks)
curl -sS https://api.migrata.systems/v1/mig_8f3c1d2b5a \
  -H "X-Api-Key: $MM_KEY"

Node.js

import fetch from "node-fetch";

const BASE = "https://api.migrata.systems";
const KEY  = process.env.MM_KEY;

async function mm(path, init = {}) {
  const res = await fetch(`${BASE}${path}`, {
	...init,
	headers: { "X-Api-Key": KEY, "Content-Type": "application/json", ...(init.headers||{}) },
  });
  if (!res.ok) throw Object.assign(new Error(`MM ${res.status}`), { body: await res.json().catch(()=>null) });
  return res.json();
}

const job = await mm("/v1", {
  method: "POST",
  body: JSON.stringify({
	name: "Alice → Contoso",
	source:      { server:"imap.gmail.com",        username:"alice@example.com", password:"app-pwd" },
	destination: { server:"outlook.office365.com", username:"alice@contoso.com", password:"s3cret"  },
  }),
});
console.log("Migration id:", job.id);

C#

using System.Net.Http.Json;

var http = new HttpClient { BaseAddress = new Uri("https://api.migrata.systems") };
http.DefaultRequestHeaders.Add("X-Api-Key", Environment.GetEnvironmentVariable("MM_KEY"));

var resp = await http.PostAsJsonAsync("/v1", new {
	name = "Alice \u2192 Contoso",
	source      = new { server="imap.gmail.com",        username="alice@example.com", password="app-pwd" },
	destination = new { server="outlook.office365.com", username="alice@contoso.com", password="s3cret"  }
});
resp.EnsureSuccessStatusCode();
var status = await resp.Content.ReadFromJsonAsync<Dictionary<string,object>>();
Console.WriteLine($"Migration id: {status!["id"]}");

Python

import os, requests

BASE = "https://api.migrata.systems"
H = {"X-Api-Key": os.environ["MM_KEY"], "Content-Type": "application/json"}

r = requests.post(f"{BASE}/v1", headers=H, json={
	"name": "Alice → Contoso",
	"source":      {"server":"imap.gmail.com","username":"alice@example.com","password":"app-pwd"},
	"destination": {"server":"outlook.office365.com","username":"alice@contoso.com","password":"s3cret"},
})
r.raise_for_status()
print("Migration id:", r.json()["id"])

Authorize with Migrata

These recipes use Migrata's OAuth application. The user consents to Mailmigrata. You receive the job id and status. Open the authorization URLs in a browser and do not send the API key. The return query is id and status only. Each language then registers your own app (Mode A). The create response is id and status, and the secret is not in that response. Mode B is the single request above under Your own OAuth app.

cURL

# Gmail mailbox. Do not send a password.
curl -sS https://api.migrata.systems/v1 \
  -H "X-Api-Key: $MM_KEY" \
  -H "Content-Type: application/json" \
  -d '{
	"name": "Alice Gmail",
	"source": { "provider": "gmail", "username": "alice@example.com" },
	"destination": { "provider": "gmail", "username": "alice@contoso.com" }
  }'
# {"id":"mig_8f3c1d2b5a","kind":"mail","status":"awaiting_authorization",
#  "sourceAuthorizationUrl":"https://api.migrata.systems/v1/authorize/mig_8f3c1d2b5a/source",
#  "destinationAuthorizationUrl":"https://api.migrata.systems/v1/authorize/mig_8f3c1d2b5a/destination"}
# Open both URLs in the browser. The return query is id and status only:
# ?id=mig_8f3c1d2b5a&status=authorized

curl -sS https://api.migrata.systems/v1/mig_8f3c1d2b5a \
  -H "X-Api-Key: $MM_KEY"

curl -sS https://api.migrata.systems/v1/files \
  -H "X-Api-Key: $MM_KEY" \
  -H "Content-Type: application/json" \
  -d '{
	"name": "Alice files",
	"source": { "provider": "dropbox", "username": "alice@example.com" },
	"destination": { "provider": "dropbox", "username": "alice@contoso.com" }
  }'

# Mode A. Send the client secret once. This response has id and status only.
curl -sS https://api.migrata.systems/v1/oauth-apps \
  -H "X-Api-Key: $MM_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "provider": "gmail", "clientId": "msp-application", "mode": "hosted" }'
# {"id":17,"status":"pending_consent"}

curl -sS https://api.migrata.systems/v1 \
  -H "X-Api-Key: $MM_KEY" \
  -H "Content-Type: application/json" \
  -d '{
	"name": "Alice Gmail",
	"oauthAppId": 17,
	"source": { "provider": "gmail", "username": "alice@example.com" },
	"destination": { "provider": "gmail", "username": "alice@contoso.com" }
  }'

Node.js

const created = await mm("/v1", {
  method: "POST",
  body: JSON.stringify({
	name: "Alice Gmail",
	source: { provider: "gmail", username: "alice@example.com" },
	destination: { provider: "gmail", username: "alice@contoso.com" },
  }),
});
// created.status === "awaiting_authorization"
// Open created.sourceAuthorizationUrl and created.destinationAuthorizationUrl
// in the browser. Do not send the API key.
// The return query is id and status only.
const polled = await mm("/v1/" + created.id);
console.log(polled.status);

await mm("/v1/files", {
  method: "POST",
  body: JSON.stringify({
	name: "Alice files",
	source: { provider: "dropbox", username: "alice@example.com" },
	destination: { provider: "dropbox", username: "alice@contoso.com" },
  }),
});

const app = await mm("/v1/oauth-apps", {
  method: "POST",
  body: JSON.stringify({ provider: "gmail", clientId: "msp-application", mode: "hosted" }),
});
// app is { id, status } and does not include the secret
await mm("/v1", {
  method: "POST",
  body: JSON.stringify({
	name: "Alice Gmail",
	oauthAppId: app.id,
	source: { provider: "gmail", username: "alice@example.com" },
	destination: { provider: "gmail", username: "alice@contoso.com" },
  }),
});

C#

var created = await http.PostAsJsonAsync("/v1", new {
	name = "Alice Gmail",
	source = new { provider = "gmail", username = "alice@example.com" },
	destination = new { provider = "gmail", username = "alice@contoso.com" }
});
var job = await created.Content.ReadFromJsonAsync<Dictionary<string, object>>();
Console.WriteLine(job!["status"]); // awaiting_authorization
Console.WriteLine(job["sourceAuthorizationUrl"]);
Console.WriteLine(job["destinationAuthorizationUrl"]);
// Open both URLs in the browser. Do not send the API key.
// The return query is id and status only.

var polled = await http.GetAsync("/v1/" + job["id"]);
polled.EnsureSuccessStatusCode();

await http.PostAsJsonAsync("/v1/files", new {
	name = "Alice files",
	source = new { provider = "dropbox", username = "alice@example.com" },
	destination = new { provider = "dropbox", username = "alice@contoso.com" }
});

var appResp = await http.PostAsJsonAsync("/v1/oauth-apps", new {
	provider = "gmail", clientId = "msp-application", mode = "hosted"
});
var app = await appResp.Content.ReadFromJsonAsync<Dictionary<string, object>>();
// app has id and status. The secret is not in this response.
await http.PostAsJsonAsync("/v1", new {
	name = "Alice Gmail",
	oauthAppId = app!["id"],
	source = new { provider = "gmail", username = "alice@example.com" },
	destination = new { provider = "gmail", username = "alice@contoso.com" }
});

Python

created = requests.post(f"{BASE}/v1", headers=H, json={
	"name": "Alice Gmail",
	"source": {"provider": "gmail", "username": "alice@example.com"},
	"destination": {"provider": "gmail", "username": "alice@contoso.com"},
}).json()
# created["status"] == "awaiting_authorization"
# Open created["sourceAuthorizationUrl"] and created["destinationAuthorizationUrl"]
# in the browser. Do not send the API key.
# The return query is id and status only.
polled = requests.get(f"{BASE}/v1/{created['id']}", headers=H)
polled.raise_for_status()

requests.post(f"{BASE}/v1/files", headers=H, json={
	"name": "Alice files",
	"source": {"provider": "dropbox", "username": "alice@example.com"},
	"destination": {"provider": "dropbox", "username": "alice@contoso.com"},
}).raise_for_status()

app = requests.post(f"{BASE}/v1/oauth-apps", headers=H, json={
	"provider": "gmail", "clientId": "msp-application", "mode": "hosted",
}).json()
# app is id and status. The secret is not in this response.
requests.post(f"{BASE}/v1", headers=H, json={
	"name": "Alice Gmail",
	"oauthAppId": app["id"],
	"source": {"provider": "gmail", "username": "alice@example.com"},
	"destination": {"provider": "gmail", "username": "alice@contoso.com"},
}).raise_for_status()

mailmigrata.com

© Migrata Systems — Public API v1 — Documentation served from the API host. For questions, contact support@mailmigrata.com.

Move the book. Add the account.

Free cloud-to-cloud contacts with groups, photos and cleanup. The phone fills itself.

Start free