CLI commands

Creatives commands

The 5 koast CLI commands for the Creatives operations.

Every command is one API operation, named by its operationId. Global flags such as --output and --api-url work on all of them, see CLI commands.

generate-creatives

Generate creatives. POST /v1/brands/{brandId}/creatives/generate, API reference.

koast generate-creatives --brand <brand> --ads <ads> [--json <file|->] [flags]
FlagTypeRequiredDescription
--brandintegerYesThe brand the request acts on. Every brand-scoped resource lives under its brand.
--round-sizeintegerNoWrite this first, before every other field. How many ads you are making in this round across all your calls; send the same number on every call of the round. The user sees that many placeholders as soon as it is written. It does not change what this call makes. Minimum 1, maximum 60.
--round-groupsJSON object, repeatableNoWrite this second, right after roundSize, when the ads of the round have sources: each source and how many ads of the round it has, in the order you will write them, such as [{"source":"references","ads":10},{"source":"own-winners","ads":10}]. The user sees one row per source as soon as it is written. It does not change what is made. At least 1 item, at most 4 items.
--adsJSON object, repeatableYesThe ads to make, each with its own prompt and references. Put every ad of a round in this one call: they are all made at the same time. One ad, an edit or a resize is a list of one. At most 40 ads and 40 images per call. At least 1 item, at most 40 items.
--usestringNoad (the default): finished ads, stored in the creative library. asset: objects or elements to place inside render-creative html, on a transparent background when possible; they are stored with the brand assets, not in the library, and each returns an assetId and url. One of ad, asset.

Required scope: write. Accepts --idempotency-key. The CLI sends a key only when you give one. --json <file|-> supplies the whole body. Body flags are applied over it.

Example:

koast generate-creatives --brand 123 --json body.json

With body.json:

{
  "roundSize": 1,
  "roundGroups": [
    {
      "source": "references",
      "ads": 1
    }
  ],
  "ads": [
    {
      "prompt": "string",
      "references": [
        {
          "creativeId": 1,
          "imageUrl": "https://hooks.example.com/koast"
        }
      ],
      "editCreativeId": 1,
      "aspectRatios": [
        "1:1"
      ],
      "variations": 1,
      "logo": true,
      "name": "string",
      "people": true,
      "source": "references",
      "policyRisk": "string"
    }
  ],
  "use": "ad"
}

list-creatives

List creatives. GET /v1/brands/{brandId}/creatives, API reference.

koast list-creatives --brand <brand> [flags]
FlagTypeRequiredDescription
--brandintegerYesThe brand the request acts on. Every brand-scoped resource lives under its brand.
--searchstringNoFilter by creative or file name. Omit to list everything, newest first. At most 200 characters.
--kindstringNoNarrow to images or to videos. Defaults to ALL. One of ALL, IMAGES, VIDEOS.
--creative-idsinteger, repeatableNoLook up an explicit set of creative ids instead of browsing. This is also what the gallery sends when a user picks creatives in it, so the ids reach you. At most 60 items.
--pageintegerNo1-based page. Defaults to 1. Minimum 1.
--limitintegerNoPage size. Default 50. Minimum 1, maximum 100.
--cursorstringNoOpaque cursor from the previous page's nextCursor. Omit for the first page.

Required scope: read. Paged. --all follows nextCursor to the end and prints one JSON line per item.

Example:

koast list-creatives --brand 123

render-creative

Render creative. POST /v1/brands/{brandId}/creatives/render, API reference.

koast render-creative --brand <brand> --aspect-ratio <aspect-ratio> [--json <file|->] [flags]
FlagTypeRequiredDescription
--brandintegerYesThe brand the request acts on. Every brand-scoped resource lives under its brand.
--round-sizeintegerNoWrite this first, before every other field. How many ads you are making in this round across all your calls; send the same number on every call of the round. The user sees that many placeholders as soon as it is written. It does not change what this call makes. Minimum 1, maximum 60.
--htmlstringNoA complete html page for the ad, laid out at the size of the aspect ratio. Page scripts do not run. Only inline data: urls, Koast storage urls and Google Fonts load; every other request is blocked. At most 200000 characters.
--template-idintegerNoRender a saved template from list-creative-templates instead of html.
--valuesJSON objectNoWith templateId: the text for each {{slot}} of the template, by slot name. Values go in as plain text.
--aspect-ratiostringYes1:1 renders at 1080x1080, 4:5 at 1080x1350, 9:16 at 1080x1920. One of 1:1, 4:5, 9:16.
--namestringNoName for the stored creative. At most 120 characters.
--sourcestringNoWhere this ad's idea came from: references (images the user attached or references they picked), meta-winners (other advertisers' winning ads from the Meta Ad Library), own-winners (the brand's own best ads from its ad account), ideas (none of these: the brief and the website). The user sees the round grouped by it. One of references, meta-winners, own-winners, ideas.
--policy-riskstringNoSet this only when the ad could be rejected: why, in a few plain words the user understands ("promises a guaranteed result", "won't run on your agency ad account: crypto"). The ad is still made exactly as asked, and the user sees this as a warning on the ad. Leave it out when there is no real risk. At most 140 characters.

Required scope: write. Accepts --idempotency-key. The CLI sends a key only when you give one. --json <file|-> supplies the whole body. Body flags are applied over it.

Example:

koast render-creative --brand 123 --aspect-ratio 1:1

save-generated-creatives

Save generated creatives. POST /v1/brands/{brandId}/creatives/save, API reference.

koast save-generated-creatives --brand <brand> --creative-ids <creative-ids> [--json <file|->] [flags]
FlagTypeRequiredDescription
--brandintegerYesThe brand the request acts on. Every brand-scoped resource lives under its brand.
--creative-idsinteger, repeatableYesThe creativeIds from generate-creatives that the user wants to keep. At least 1 item, at most 100 items.
--folder-namestringNoA short name for what this round is (brand and idea), for the folder the chat's ads are saved into. Used only when the chat has no folder yet; the date is added to it. At most 120 characters.

Required scope: write. Accepts --idempotency-key. The CLI sends a key only when you give one. --json <file|-> supplies the whole body. Body flags are applied over it.

Example:

koast save-generated-creatives --brand 123 --creative-ids 1

upload-creative

Upload creative. POST /v1/brands/{brandId}/creatives, API reference.

koast upload-creative --brand <brand> [--json <file|->] [flags]
FlagTypeRequiredDescription
--brandintegerYesThe brand the request acts on. Every brand-scoped resource lives under its brand.
--image-urlstringNoPublic https url of the image to store. Koast downloads it and re-hosts it, so a link that later expires does not rot the ad. Use this whenever the user gives you a link.
--file-datastringNoStandard base64 of the image bytes, with NO data-url prefix. Intended for the Koast creative gallery, which reads a dropped file and sends it here. Do not attempt to write this yourself, if the user attached an image to the chat, say you cannot read its bytes and ask for a link or for them to drop it in the gallery. At most 13333338 characters.
--content-typestringNoMedia type of fileData. Required with fileData, ignored with imageUrl. One of image/jpeg, image/png, image/webp, image/gif.
--file-namestringNoFile name to store it under. Required with fileData; defaults to the url's own name otherwise. At most 200 characters.
--namestringNoDisplay name for the creative. Defaults to the file name. At most 200 characters.

Required scope: write. Accepts --idempotency-key. The CLI sends a key only when you give one. --json <file|-> supplies the whole body. Body flags are applied over it.

Example:

koast upload-creative --brand 123

On this page