{
  "slug": "new-device-login-alert",
  "title": "New device login alert: template and code",
  "url": "https://www.courier.com/recipes/new-device-login-alert",
  "markdown": "https://www.courier.com/recipes/new-device-login-alert.md",
  "stage": "Account and security",
  "purpose": "Tell people right away when their account is used from a new device.",
  "summary": "A new device login alert warns users when their account signs in from a device you haven't seen before. It sends an email and an Inbox message at the same time, showing the device, location, and time, with a button to secure the account. Each new sign-in sends one alert, so there's nothing to stop.",
  "channels": [
    "email",
    "inbox"
  ],
  "shape": "send",
  "shows": [
    "Email and Inbox from one send call",
    "Device, location, and time filled from your data",
    "An Inbox copy that still goes out when there's no email address"
  ],
  "data": [
    {
      "name": "device",
      "type": "string",
      "example": "Chrome on macOS"
    },
    {
      "name": "location",
      "type": "string",
      "example": "Austin, Texas, US",
      "note": "An approximate place is enough"
    },
    {
      "name": "signed_in_at",
      "type": "string",
      "example": "2026-10-15T14:42:00Z",
      "note": "An ISO timestamp. The template formats it as a date and time in the recipient's timezone"
    }
  ],
  "steps": [
    {
      "step": "1",
      "when": "When an account signs in from a new device",
      "channels": "Email, Inbox",
      "templates": [
        "templates/new-device-alert.json"
      ]
    }
  ],
  "files": {
    "templates": [
      "templates/new-device-alert.json"
    ],
    "setup": [
      "setup.ts"
    ],
    "start": [
      "start.ts",
      "start.py"
    ]
  },
  "docs": [
    "https://www.courier.com/docs/send/routing",
    "https://www.courier.com/docs/in-app/send-to-the-inbox",
    "https://www.courier.com/docs/send/overview"
  ],
  "related_recipes": [
    "https://www.courier.com/recipes/password-reset-email",
    "https://www.courier.com/recipes/otp-sms-email-fallback",
    "https://www.courier.com/recipes/magic-link-email"
  ],
  "agent_prompt": "Add new device login alerts to this app, sent through Courier: an email and an Inbox message at the same time, with the device, location, and time and a Wasn't you? Secure your account button. Follow the steps at https://www.courier.com/recipes/new-device-login-alert.md and use the Courier skill for SDK details.\n\n1. Create the template in my Courier workspace by running setup.ts from that page with COURIER_API_KEY from our environment. Save the template ID it prints as COURIER_NEW_DEVICE_TEMPLATE_ID.\n2. Find where this codebase signs a user in and decides whether the device is new, and send the alert there with the recipe's send code. Pass device, location, and signed_in_at (an ISO timestamp) from our own data. Replace the placeholder product name (Acme) and the Secure your account link (https://app.acme.com/security) in the template with ours.\n3. Match this codebase's language, file layout, and error handling. Never hardcode the API key.\n4. When you're done, send one alert to a test user and show me both deliveries, email and Inbox.",
  "status": {
    "state": "passing",
    "last_tested": "2026-10-19"
  }
}
