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

# Preview an AI-written step

> Writes one message or email from the brief for a real lead in the campaign, the same way Bavlio writes it when the lead reaches the step, and returns it without saving or sending anything. Send after_lead_id to write the next preview for the lead after that one. Previews are free and limited per workspace; past the limit the answer is 429 with the seconds to wait.

## OpenAPI

```json
{
  "openapi": "3.2.0",
  "info": {
    "title": "Bavlio API",
    "version": "1.0.0"
  },
  "paths": {
    "/campaigns/{id}/sequence/preview": {
      "post": {
        "tags": [
          "Sequences"
        ],
        "operationId": "sequences.previewSequenceStep",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "schema": {
              "type": "string",
              "description": "Campaign id."
            },
            "required": true
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "StepPreview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StepPreview"
                }
              }
            }
          },
          "400": {
            "description": "SequenceInvalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceInvalidEncoded"
                }
              }
            }
          },
          "401": {
            "description": "AuthMissing | AuthInvalid",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/AuthMissingEncoded"
                    },
                    {
                      "$ref": "#/components/schemas/AuthInvalidEncoded"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "ProviderCreditsExhausted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderCreditsExhaustedEncoded"
                }
              }
            }
          },
          "404": {
            "description": "WorkspaceNotFound | CampaignNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/WorkspaceNotFoundEncoded"
                    },
                    {
                      "$ref": "#/components/schemas/CampaignNotFoundEncoded"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "SequencePreviewNoLead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequencePreviewNoLeadEncoded"
                }
              }
            }
          },
          "429": {
            "description": "RequestRateLimited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestRateLimitedEncoded"
                }
              }
            }
          },
          "502": {
            "description": "ProviderFailed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderFailedEncoded"
                }
              }
            }
          },
          "503": {
            "description": "ProviderUnavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderUnavailableEncoded"
                }
              }
            }
          }
        },
        "description": "Writes one message or email from the brief for a real lead in the campaign, the same way Bavlio writes it when the lead reaches the step, and returns it without saving or sending anything. Send after_lead_id to write the next preview for the lead after that one. Previews are free and limited per workspace; past the limit the answer is 429 with the seconds to wait.",
        "summary": "Preview an AI-written step",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewStepPayload"
              }
            }
          },
          "required": true
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AuthInvalidEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "AuthInvalid"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              401
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "auth_invalid"
            ]
          },
          "message": {
            "type": "string",
            "enum": [
              "Bearer credential rejected"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "AuthMissingEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "AuthMissing"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              401
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "auth_missing"
            ]
          },
          "message": {
            "type": "string",
            "enum": [
              "Bearer credential required"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "WorkspaceNotFoundEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "WorkspaceNotFound"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              404
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "workspace_not_found"
            ]
          },
          "message": {
            "type": "string",
            "enum": [
              "No such workspace for this account: save a company profile or pick a workspace you belong to"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "RequestRateLimitedEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "RequestRateLimited"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              429
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "rate_limited"
            ]
          },
          "message": {
            "type": "string"
          },
          "retryAfterSeconds": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message",
          "retryAfterSeconds"
        ],
        "additionalProperties": false
      },
      "SequenceInvalidEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "SequenceInvalid"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              400
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "sequence_invalid"
            ]
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "ProviderUnavailableEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "ProviderUnavailable"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              503
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "provider_unavailable"
            ]
          },
          "message": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "reacher",
              "millionverifier",
              "crustdata",
              "openrouter",
              "voyage",
              "web",
              "harvestapi",
              "serper",
              "treg",
              "monid"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message",
          "provider"
        ],
        "additionalProperties": false
      },
      "ProviderFailedEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "ProviderFailed"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              502
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "provider_failed"
            ]
          },
          "message": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "reacher",
              "millionverifier",
              "crustdata",
              "openrouter",
              "voyage",
              "web",
              "harvestapi",
              "serper",
              "treg",
              "monid"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message",
          "provider"
        ],
        "additionalProperties": false
      },
      "ProviderCreditsExhaustedEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "ProviderCreditsExhausted"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              402
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "provider_credits_exhausted"
            ]
          },
          "message": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "reacher",
              "millionverifier",
              "crustdata",
              "openrouter",
              "voyage",
              "web",
              "harvestapi",
              "serper",
              "treg",
              "monid"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message",
          "provider"
        ],
        "additionalProperties": false
      },
      "SequencePreviewNoLeadEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "SequencePreviewNoLead"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              409
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "sequence_preview_no_lead"
            ]
          },
          "message": {
            "type": "string",
            "enum": [
              "The campaign has no leads to write a preview for yet"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "CampaignNotFoundEncoded": {
        "type": "object",
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "CampaignNotFound"
            ]
          },
          "statusCode": {
            "type": "number",
            "enum": [
              404
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "campaign_not_found"
            ]
          },
          "message": {
            "type": "string",
            "enum": [
              "No campaign with this id belongs to the workspace"
            ]
          }
        },
        "required": [
          "_tag",
          "statusCode",
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "StepPreview": {
        "type": "object",
        "properties": {
          "lead": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "title": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "company": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "id",
              "name",
              "title",
              "company"
            ],
            "additionalProperties": false,
            "description": "The campaign lead the preview was written for."
          },
          "text": {
            "type": "string",
            "description": "The message or email body Bavlio wrote for this lead from the brief."
          }
        },
        "required": [
          "lead",
          "text"
        ],
        "additionalProperties": false
      },
      "PreviewStepPayload": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "message"
                ]
              },
              "brief": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1000,
                "description": "The step's brief: what Bavlio should write, in the sender's words."
              },
              "after_lead_id": {
                "type": "string",
                "description": "The lead the previous preview was written for. Bavlio writes the next preview for the lead after it, so the same brief can be tried on someone else."
              }
            },
            "required": [
              "kind",
              "brief"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "email"
                ]
              },
              "brief": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1000,
                "description": "The step's brief: what Bavlio should write, in the sender's words."
              },
              "opens_thread": {
                "type": "boolean",
                "description": "Whether the email starts its own thread (true) or replies in an earlier one."
              },
              "after_lead_id": {
                "type": "string",
                "description": "The lead the previous preview was written for. Bavlio writes the next preview for the lead after it, so the same brief can be tried on someone else."
              }
            },
            "required": [
              "kind",
              "brief",
              "opens_thread"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "securitySchemes": {
      "bearer": {
        "description": "Send `Authorization: Bearer <token>`. The token is an API key, which starts with `bav_` and comes from creating an API key or starting a registration, or the access token of a Bavlio sign-in.",
        "type": "http",
        "scheme": "Bearer"
      }
    }
  },
  "security": [],
  "tags": [
    {
      "name": "Registration",
      "description": "Open a Bavlio account without signing in. Starting a registration returns an API key for a new ephemeral account, which becomes permanent once its email address is verified."
    },
    {
      "name": "Authentication",
      "description": "Identify the calling account, finish a registration and manage the account's API keys."
    },
    {
      "name": "Account",
      "description": "The account behind your sign-in, and deleting it."
    },
    {
      "name": "Workspaces",
      "description": "A workspace holds the company profile, outreach schedule, team, campaigns and billing Bavlio works with. Calls that act in a workspace use the one whose id is in the bavlio-workspace header, or the account's default workspace when the header is absent."
    },
    {
      "name": "Teams",
      "description": "Manage who belongs to a workspace: its members, their roles and the invitations to join it. Each workspace's plan sets how many team seats it has."
    },
    {
      "name": "Campaigns",
      "description": "A campaign finds leads that match an ideal customer profile (ICP) and buying signals, and reaches out to them through its sequence of LinkedIn and email steps."
    },
    {
      "name": "Companies",
      "description": "Companies on LinkedIn, to pick as the competitors whose engaged audience a campaign watches."
    },
    {
      "name": "Lead imports",
      "description": "Bring your own leads: preview a CSV, confirm which column holds what, then import it into a campaign, where the leads go through the same sequence as the ones Bavlio finds."
    },
    {
      "name": "Sequences",
      "description": "A campaign's sequence is the steps Bavlio runs for each lead: profile visits, likes, invites, LinkedIn messages, emails, waits, conditions and A/B tests. Every message and email waits in the review queue for approval before it is sent."
    },
    {
      "name": "Inbox",
      "description": "Conversations with the people your campaigns reached and, for accounts that opt in, your other LinkedIn and email conversations: read them, reply to them and follow changes live."
    },
    {
      "name": "Reviews",
      "description": "Messages and emails go to a lead only after someone approves them. The review queue holds the replies Bavlio drafted for people who answered and the messages and emails it drafted for campaign sequences."
    },
    {
      "name": "Billing",
      "description": "The plans on offer and the workspace's subscription and usage. Plan changes, cancellation and the billing portal need the workspace owner or an admin."
    },
    {
      "name": "LinkedIn",
      "description": "Connect the LinkedIn accounts your campaigns send from, confirm their sign-ins, choose the country LinkedIn sees them from, and disconnect them."
    },
    {
      "name": "Meetings",
      "description": "Meetings booked through the workspace's calendar tool (Google Calendar, Calendly or Cal.com), and the calendar connection that imports them."
    },
    {
      "name": "Email",
      "description": "Connect a Bavimail account, add sending domains and tracking domains, and create the inboxes campaigns send email from."
    },
    {
      "name": "Locations",
      "description": "Places to aim a campaign at, from a continent down to a city. Country, state and city names come from the Countries States Cities Database (https://github.com/dr5hn/countries-states-cities-database), made available under the Open Database License (ODbL) 1.0; continents from countries-list."
    }
  ],
  "servers": [
    {
      "url": "https://api.bavlio.com"
    }
  ]
}
```
