IM
EN
Docs Home
Menu
Guides

IMAP Sync Mailboxes And Messages

Enqueue IMAP sync jobs and persist message metadata for search and read flows.

inbox-manager client-flow

IMAP Sync Mailboxes And Messages

Purpose: enqueue IMAP sync jobs and persist message metadata for search and read flows.

UI Flow

  1. User picks credential and folder.
  2. UI enqueues mailbox sync or message sync.
  3. UI polls jobs/tasks for terminal state.
  4. UI refreshes /api/accounts/:account_id/emails.

Client Library Flow

const mailboxTask = await api.provider.imap.syncMailboxes(accountId, {
  credential_id: imapCredentialId,
});
const messageTask = await api.provider.imap.syncMessages(accountId, {
  credential_id: imapCredentialId,
  folder: "INBOX",
});
await api.jobs.waitForTask(accountId, messageTask.data.task_id);
const emails = await api.emails.list(accountId, { limit: 20, offset: 0 });

HTTP/curl Flow

API_BASE_URL="https://api.inbox-manager.com"

curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/imap/sync-mailboxes" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"credential_id\":\"${IMAP_CREDENTIAL_ID}\"}"

curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/imap/sync-messages" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"credential_id\":\"${IMAP_CREDENTIAL_ID}\",\"folder\":\"INBOX\"}"

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/jobs?limit=20" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/emails?limit=20&offset=0" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

Validation Script

  • scripts/provider_job_flow.sh