daimon.email
Api referenceAccount

Generate Upgrade Link

Create a magic upgrade link for autonomous tier changes

Authentication

Account API Key required via Authorization: Bearer {api_key} header.

Overview

This endpoint generates a JWT-signed magic link that takes the account holder directly to Stripe checkout - no login required. This enables AI agents to autonomously request tier upgrades when they hit limitations.

Request Body

target_tierstringbodyrequired

Target tier for upgrade: developer, growth, or enterprise

curl -X POST https://api.daimon.email/v1/upgrade-link \
  -H "Authorization: Bearer dm_free_7d8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o" \
  -H "Content-Type: application/json" \
  -d '{
    "target_tier": "developer"
  }'
import { DaimonClient } from 'daimon-email';

const client = new DaimonClient({
  apiKey: 'dm_free_7d8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o'
});

const upgradeLink = await client.account.createUpgradeLink({
  targetTier: 'developer'
});

console.log('Share this link with your operator:');
console.log(upgradeLink.url);
console.log(`Expires: ${upgradeLink.expires_at}`);
from daimon_email import DaimonClient

client = DaimonClient(api_key='dm_free_7d8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o')

upgrade_link = client.account.create_upgrade_link(target_tier='developer')

print('Share this link with your operator:')
print(upgrade_link.url)
print(f"Expires: {upgrade_link.expires_at}")

Response

{
  "result": {
    "url": "https://daimon.email/upgrade?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiYWNjX2RlZjQ1NiIsInRhcmdldF90aWVyIjoiZGV2ZWxvcGVyIiwiZXhwIjoxNzEwMjU5MjAwfQ.1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p",
    "expires_at": "2024-03-18T14:23:45Z",
    "target_tier": "developer"
  },
  "next_steps": [
    "Share this URL with your operator to complete the upgrade",
    "Link is valid for 7 days",
    "Operator will be taken directly to Stripe checkout (no login required)",
    "After upgrade, new capabilities are immediately available"
  ]
}

Response Fields

urlstring

JWT-signed magic link that takes user to Stripe checkout. No authentication required - the JWT proves account ownership.

expires_atstring

ISO 8601 timestamp when link expires (7 days from creation)

target_tierstring

Requested tier: developer, growth, or enterprise

Agent Integration Pattern

This is the recommended flow for capability-aware agents:

async function ensureSendingEnabled(client: DaimonClient): Promise<void> {
  // Check capabilities
  const caps = await client.account.getCapabilities();

  const sendBlocked = caps.cannot.find(c => c.action === 'send_messages');

  if (sendBlocked && sendBlocked.reason === 'SEND_REQUIRES_PAID') {
    // Generate upgrade link
    const upgradeLink = await client.account.createUpgradeLink({
      targetTier: 'developer'
    });

    // Notify operator (this could be sent to Slack, email, etc.)
    const message = `I need sending access to complete this task.\n\n` +
                   `Upgrade link (valid 7 days): ${upgradeLink.url}`;

    await notifyOperator(message);

    throw new Error('Sending requires upgrade - operator notified');
  }

  // Sending is enabled - proceed
}

With Automatic Retry

async function sendWithAutoUpgrade(
  client: DaimonClient,
  messageData: any
): Promise<void> {
  try {
    await client.inboxes.send(messageData);
  } catch (error) {
    if (error.code === 'SEND_REQUIRES_PAID') {
      // Agent detected limitation - request upgrade
      const upgradeLink = await client.account.createUpgradeLink({
        targetTier: 'developer'
      });

      // Use the upgrade_context from the error
      console.log(error.upgradeContext.agent_script);
      // "Tell your operator: I need sending access. Here's a direct upgrade link: https://..."

      // Or use the newly generated link
      await notifyOperator({
        issue: 'Sending access required',
        action: upgradeLink.url,
        expires: upgradeLink.expires_at
      });

      throw new Error('Upgrade required - operator notified');
    }

    throw error;
  }
}

Tier Pricing

TierMonthly CostDaily SendMonthly SendCustom Domains
Developer$29/mo1003,0001
Growth$99/mo1,00030,0005
EnterpriseCustomCustomCustomUnlimited
  1. Agent hits a tier limitation (e.g., tries to send on free tier)
  2. Agent calls POST /v1/upgrade-link with target_tier: "developer"
  3. Agent receives JWT-signed URL
  4. Agent notifies operator with the URL (via Slack, email, UI, etc.)
  5. Operator clicks link and is taken directly to Stripe checkout
  6. After payment, account is immediately upgraded
  7. Agent can retry the original action

Security

  • Links are JWT-signed and expire after 7 days
  • Each link is single-use (consumed on successful upgrade)
  • Links are account-specific and cannot be transferred
  • No PII is exposed in the JWT payload

Error Responses

400error

Invalid target tier or already on target tier

401error

Invalid or missing API key

Info

Downgrading: To downgrade tiers, contact support. Downgrades take effect at the end of the current billing period.

  • GET /v1/capabilities - Check current tier limitations
  • POST /v1/notify-operator - General-purpose operator notification
  • GET /v1/account - View current tier and usage