POST
https://www.app.ocoya.com/api/_public/v1/email/ai
Create an AI-generated draft email
curl --request POST \
  --url https://www.app.ocoya.com/api/_public/v1/email/ai \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "prompt": "Our autumn sale: 20% off everything until Sunday, code AUTUMN20.",
  "templateId": "<string>",
  "withImages": true,
  "name": "<string>",
  "subject": "<string>",
  "preheader": "<string>",
  "audience": {
    "groupIds": [
      "cmwdke1w70043y0k4ffzsa6om"
    ],
    "excludeGroupIds": []
  }
}
'
{
  "emailId": "cmwdkjtfh005gy0k4ggzzg1bs",
  "status": "generating",
  "scheduledAt": {}
}

Authorizations

X-API-Keystringheaderrequired

Your API key. Create one in Ocoya. Authorization: Bearer <key> works too.

Query Parameters

brandIdstringrequired

Ocoya brand ID. Get one from GET /brands.

Example:"cmayvq3hk00017apshay5qezu"

Body

application/json
promptstringrequired

What the email is about: the offer, news or message, with any facts, dates and links.

Minimum string length: 10
Example:
"Our autumn sale: 20% off everything until Sunday, code AUTUMN20."
templateIdstring

Template ID from GET /email/templates to write it into.

withImagesboolean

Draw AI pictures for it. Defaults to true.

namestring
subjectstring

Use this subject instead of the one AI writes.

preheaderstring
audienceobject

Who gets it: subscribed contacts only, ever. Group IDs from GET /contacts/groups.

Show child attributesHide child attributes
audience.groupIdsstring[]

Send to contacts in any of these groups. Empty or left out: every subscribed contact.

Example:
[
  "cmwdke1w70043y0k4ffzsa6om"
]
audience.excludeGroupIdsstring[]

Leave out anyone in these groups.

Example:[]

Response

application/json

Queued. Returns immediately with status generating.

emailIdstring

ID of the email. Fetch it with GET /email/{emailId} until its status is draft.

Example:"cmwdkjtfh005gy0k4ggzzg1bs"
statusstring

generating until the words and pictures are ready.

Example:"generating"
scheduledAtnull