> ## Documentation Index
> Fetch the complete documentation index at: https://docs.manypi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Draft an email with AI

> AI-draft a cold email (`mode: "email"`) or a whole follow-up sequence (`mode: "sequence"`) from a plain-language brief, written against your brand context.

This only drafts: nothing is saved and nothing is sent. Feed the result into `POST /api/outreach/sequences` or `POST /api/outreach/send`.

Requires the `read` permission.



## OpenAPI

````yaml POST /api/outreach/generate
openapi: 3.1.0
info:
  title: ManyPI API
  description: >-
    The REST API behind ManyPI — AI lead generation, email validation,
    cold-email outreach, agent runs and web scraping. Every endpoint is
    authenticated with a ManyPI API key (`mpi_...`) or an OAuth 2.1 access
    token, and honours the permissions granted to that credential.
  version: 2.0.0
  contact:
    name: ManyPI Support
    email: support@manypi.com
    url: https://manypi.com
servers:
  - url: https://app.manypi.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Leads
    description: Find, store, enrich and manage leads.
  - name: Email validation
    description: Verify that lead addresses can receive mail.
  - name: Outreach
    description: Inboxes, sequences, campaigns, sending and replies.
  - name: Agent
    description: Agent runs, replies and skills.
  - name: Scraping
    description: Scrapers, runs and extracted data.
  - name: Endpoints
    description: Publish scrapers as typed REST endpoints.
  - name: Account
    description: Key validation and account information.
paths:
  /api/outreach/generate:
    post:
      tags:
        - Outreach
      summary: Draft an email with AI
      description: >-
        AI-draft a cold email (`mode: "email"`) or a whole follow-up sequence
        (`mode: "sequence"`) from a plain-language brief, written against your
        brand context.


        This only drafts: nothing is saved and nothing is sent. Feed the result
        into `POST /api/outreach/sequences` or `POST /api/outreach/send`.


        Requires the `read` permission.
      operationId: generateEmail
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - instructions
              properties:
                instructions:
                  type: string
                  maxLength: 2000
                mode:
                  type: string
                  enum:
                    - email
                    - sequence
                  default: email
                steps:
                  type: integer
                  minimum: 2
                  maximum: 5
                  default: 3
                lead_id:
                  type: string
                  format: uuid
                  description: An example lead to tailor the tone toward.
            example:
              instructions: >-
                We help e-commerce agencies find new client leads without
                cold-calling. Ask for a 15-minute call.
              mode: sequence
              steps: 3
      responses:
        '200':
          description: The draft.
          content:
            application/json:
              schema:
                type: object
                properties:
                  subject:
                    type: string
                  html:
                    type: string
                  steps:
                    type: array
                    items:
                      type: object
                      properties:
                        subject:
                          type: string
                        html:
                          type: string
                        wait_days:
                          type: integer
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          description: AI generation is not configured.
components:
  responses:
    Unauthorized:
      description: >-
        Missing, invalid or expired credential — or a key that lacks the
        permission this route requires.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable message.
        code:
          type: string
          description: >-
            A machine-readable code on gated failures: `lead_limit`,
            `outreach_locked`, `validation_credits_exhausted`.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A ManyPI API key (`mpi_...`) from Settings → API keys, or an OAuth 2.1
        access token obtained through the MCP consent flow.

````