API ReferenceAIGenerate email
POST/v2/ai/generate-email

Generate email

Generates a full email from a prompt, no template needed. Charged at gpt-6-sol's rate (the fixed email-generation default) — model isn't selectable on this endpoint.

Stablescope: write API KeyLearn about API scopes →

Credits are refunded on failure

Same non-fatal-charge behavior as Generate preview — a failed generation refunds the deducted credits automatically.

Request

AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Parameters

FieldTypeRequiredDescription
promptstringRequired1–10,000 characters.
tonestringOptionalUp to 100 characters. Defaults to "Professional".
formatenumOptionalvisual | plain | html. Defaults to visual.
availableVariablesstring[]OptionalMerge-field names the AI is allowed to use (e.g. firstName, company), up to 100.
curl -X POST "https://api.stynar.com/v2/ai/generate-email" \
  -H "Authorization: Bearer esk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"Cold email introducing our SOC 2 compliance product to security leads.","tone":"casual","availableVariables":["firstName","company"]}'

Response

✓ 200 OK
200 response
{
  "content": "Hi {{firstName}},\n\nQuick one — is {{company}} SOC 2 compliant yet?...",
  "format": "visual",
  "creditsCharged": 0.8
}

Response fields

Errors

StatusCodeMeaning
✕ 402 QUOTA_EXCEEDEDNot enough credits.
✕ 401 UnauthorizedUNAUTHORIZEDMissing, malformed, unknown, revoked, or expired key.
✕ 403 ForbiddenAPI_ACCESS_DISABLEDAPI access is turned off for your account.
✕ 403 ForbiddenINSUFFICIENT_SCOPEThe key doesn't have the scope this endpoint requires.
✕ 404 Not FoundNOT_FOUNDUnknown route, or a resource that doesn't exist / isn't yours.
✕ 409 ConflictCONFLICTThe action can't be applied to the resource's current state.
✕ 429 Too Many RequestsRATE_LIMIT_EXCEEDEDPer-minute or per-second limit hit.
✕ 429 Too Many RequestsQUOTA_EXCEEDEDMonthly quota exhausted.
✕ 500 Internal Server ErrorINTERNAL_ERRORSomething broke on Stynar's end.
Full error reference →