Create Macro

Create Macro

POST https://api.ocamba.com/v2/adex/macros
Creates a new Macro object

Rate limits:

  • Burst: 10/s
  • Steady: 150/m

Request schema

body

Response schemas

curl -X POST \
 "https://api.ocamba.com/v2/adex/macros" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "MY_FIRST_MACRO",
  "description": "A simple macro without records",
  "value": "default_value"
}'
const url = 'https://api.ocamba.com/v2/adex/macros';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "MY_FIRST_MACRO",
      "description": "A simple macro without records",
      "value": "default_value"
    }
  )
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
$ch = curl_init("https://api.ocamba.com/v2/adex/macros");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "MY_FIRST_MACRO",
    "description" => "A simple macro without records",
    "value" => "default_value"
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl -X POST \
 "https://api.ocamba.com/v2/adex/macros" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "LOCALIZED_MACRO",
  "description": "Macro with records using built-in fields",
  "value": "default_value",
  "fields": [
    "country_code",
    "language_code"
  ],
  "records": [
    {
      "fields": {
        "country_code": "RS",
        "language_code": "sr"
      },
      "value": "value_for_serbia_serbian"
    },
    {
      "fields": {
        "country_code": "DE",
        "language_code": "en"
      },
      "value": "value_for_germany_english"
    }
  ]
}'
const url = 'https://api.ocamba.com/v2/adex/macros';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "LOCALIZED_MACRO",
      "description": "Macro with records using built-in fields",
      "value": "default_value",
      "fields": [
        "country_code",
        "language_code"
      ],
      "records": [
        {
          "fields": {
            "country_code": "RS",
            "language_code": "sr"
          },
          "value": "value_for_serbia_serbian"
        },
        {
          "fields": {
            "country_code": "DE",
            "language_code": "en"
          },
          "value": "value_for_germany_english"
        }
      ]
    }
  )
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
$ch = curl_init("https://api.ocamba.com/v2/adex/macros");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "LOCALIZED_MACRO",
    "description" => "Macro with records using built-in fields",
    "value" => "default_value",
    "fields" => [
      "country_code",
      "language_code"
    ],
    "records" => [
      [
        "fields" => [
          "country_code" => "RS",
          "language_code" => "sr"
        ],
        "value" => "value_for_serbia_serbian"
      ],
      [
        "fields" => [
          "country_code" => "DE",
          "language_code" => "en"
        ],
        "value" => "value_for_germany_english"
      ]
    ]
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl -X POST \
 "https://api.ocamba.com/v2/adex/macros" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "ADVANCED_MACRO",
  "description": "Macro with records using add-on fields",
  "value": "default_value",
  "fields": [
    "country_code",
    "creative_id",
    "campaign_id"
  ],
  "records": [
    {
      "fields": {
        "country_code": "RS",
        "creative_id": "1330685",
        "campaign_id": "1000001"
      },
      "value": "value_for_serbia_creative_campaign"
    },
    {
      "fields": {
        "country_code": "DE",
        "creative_id": "1330686",
        "campaign_id": "1000002"
      },
      "value": "value_for_germany_creative_campaign"
    }
  ]
}'
const url = 'https://api.ocamba.com/v2/adex/macros';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "ADVANCED_MACRO",
      "description": "Macro with records using add-on fields",
      "value": "default_value",
      "fields": [
        "country_code",
        "creative_id",
        "campaign_id"
      ],
      "records": [
        {
          "fields": {
            "country_code": "RS",
            "creative_id": "1330685",
            "campaign_id": "1000001"
          },
          "value": "value_for_serbia_creative_campaign"
        },
        {
          "fields": {
            "country_code": "DE",
            "creative_id": "1330686",
            "campaign_id": "1000002"
          },
          "value": "value_for_germany_creative_campaign"
        }
      ]
    }
  )
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
$ch = curl_init("https://api.ocamba.com/v2/adex/macros");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "ADVANCED_MACRO",
    "description" => "Macro with records using add-on fields",
    "value" => "default_value",
    "fields" => [
      "country_code",
      "creative_id",
      "campaign_id"
    ],
    "records" => [
      [
        "fields" => [
          "country_code" => "RS",
          "creative_id" => "1330685",
          "campaign_id" => "1000001"
        ],
        "value" => "value_for_serbia_creative_campaign"
      ],
      [
        "fields" => [
          "country_code" => "DE",
          "creative_id" => "1330686",
          "campaign_id" => "1000002"
        ],
        "value" => "value_for_germany_creative_campaign"
      ]
    ]
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

Responses

201 Created

{
  "id": "1000000",
  "company_id": "1000001",
  "name": "MY_FIRST_MACRO",
  "type": "dynamic",
  "value": "value",
  "fields": [
    [
      "language_code",
      "country_code"
    ]
  ],
  "records": [
    {
      "id": "1000000",
      "fields": {
        "country_code": "DE",
        "language_code": "en"
      },
      "value": "value"
    }
  ]
}

400 Bad Request

{
  "code": 400,
  "title": "Bad request.",
  "message": "The request is not valid.",
  "trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}

500 Internal Server Error

{
  "code": 500,
  "title": "Internal server error.",
  "trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}
Responses