Skip to main content
POST
https://app.ocoya.com/api/_public/v1
/
campaigns
Create an AI-generated campaign
curl --request POST \
  --url https://app.ocoya.com/api/_public/v1/campaigns \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "prompt": "Summer launch campaign for our ecommerce analytics dashboard."
}
'
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({prompt: 'Summer launch campaign for our ecommerce analytics dashboard.'})
};

fetch('https://app.ocoya.com/api/_public/v1/campaigns', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://app.ocoya.com/api/_public/v1/campaigns"

payload = { "prompt": "Summer launch campaign for our ecommerce analytics dashboard." }
headers = {
    "X-API-Key": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://app.ocoya.com/api/_public/v1/campaigns",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'prompt' => 'Summer launch campaign for our ecommerce analytics dashboard.'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "X-API-Key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
require 'uri'
require 'net/http'

url = URI("https://app.ocoya.com/api/_public/v1/campaigns")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"prompt\": \"Summer launch campaign for our ecommerce analytics dashboard.\"\n}"

response = http.request(request)
puts response.read_body
{
  "campaignId": "cmayxcmpn00087aps2m7hjs9z",
  "status": "GENERATING",
  "queued": true,
  "generation": {}
}

Authorizations

X-API-Key
string
header
required

Query Parameters

workspaceId
string
required

Ocoya workspace ID. Get one from GET /workspaces.

Example:

"cmayvq3hk00017apshay5qezu"

Body

application/json
prompt
string
required

Campaign prompt or brief.

Minimum string length: 3
Example:

"Summer launch campaign for our ecommerce analytics dashboard."

goal
enum<string>

Campaign objective.

Available options:
awareness,
leads,
launch,
offer,
education,
event
Example:

"launch"

audience
enum<string>

Primary campaign audience.

Available options:
business_owners,
founders_executives,
marketing_teams,
buyers_customers,
local_community,
investors,
first_time_buyers,
existing_customers
Example:

"marketing_teams"

duration
integer

Campaign duration in days, from 1 to 30. Defaults to 7.

Required range: 1 <= x <= 30
Example:

10

count
integer

Number of posts to generate, from 3 to 30. Defaults to 5.

Required range: 3 <= x <= 30
Example:

6

postLength
enum<string>

Target caption length for each generated campaign post.

Available options:
short,
medium,
long,
extra_long
Example:

"medium"

tone
enum<string>

Caption tone for campaign posts.

Available options:
professional,
friendly,
educational,
bold,
founder_led
Example:

"professional"

brandId
string

Brand kit ID used for brand context. When campaign media is generated, brand kit logos and icons are treated as protected reference assets. Get IDs from GET /brand-kits.

Example:

"cmayw38dz00047apsue9nw4tf"

hashtagLibraryId
string

Hashtag library ID used for hashtag context. Get IDs from GET /hashtag-libraries.

Example:

"cmayw7l5200067apsmz2tv7e8"

socialProfileIds
string[]

Connected social profile IDs to attach when generated campaign posts are saved. Get IDs from GET /social-profiles.

Example:
["clh49poxf008x8kov4ncbjty9"]
generateMedia
boolean

Whether to generate images for campaign posts.

Example:

true

imageCount
integer

Number of images to generate for each campaign post, from 1 to 5. Values above 1 create carousel-style post creatives. Defaults to 1.

Required range: 1 <= x <= 5
Example:

3

referenceUrls
string[]

Optional image URLs to use as visual references when generateMedia is true. Maximum 3.

Example:
["https://example.com/reference.png"]
referenceDesignIds
string[]

Optional Studio design IDs to use as visual references when generateMedia is true. Get IDs from GET /studio-templates. Maximum 3.

Example:
["design_123"]

Response

Campaign generation queued

campaignId
string
Example:

"cmayxcmpn00087aps2m7hjs9z"

status
string
Example:

"GENERATING"

queued
boolean
Example:

true

generation
object

Campaign generation progress metadata.