Create Message Template

Create Message Template

POST https://api.ocamba.com/v1/hood/message-templates
Creates a message template. Requires the templates feature. A push template that includes push.adex requires the adex-push feature.

Note
The object matching type is required. For push, title and landing_url are required unless push.adex is set.
Warning
Creating a push template with adex returns 403 when the workspace plan does not include the adex-push feature.

Rate limits:

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

Request schema

body

Response schemas

curl -X POST \
 "https://api.ocamba.com/v1/hood/message-templates" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Adex push template",
  "description": "Push template that loads messages from an ad exchange zone.",
  "type": "push",
  "labels": [
    "promo"
  ],
  "push": {
    "adex": {
      "zone_id": "1000321",
      "account_id": [
        "123456",
        "654321"
      ],
      "number_of_messages": 1,
      "repeat_on_click": 0
    }
  }
}'
const url = 'https://api.ocamba.com/v1/hood/message-templates';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "Adex push template",
      "description": "Push template that loads messages from an ad exchange zone.",
      "type": "push",
      "labels": [
        "promo"
      ],
      "push": {
        "adex": {
          "zone_id": "1000321",
          "account_id": [
            "123456",
            "654321"
          ],
          "number_of_messages": 1,
          "repeat_on_click": 0
        }
      }
    }
  )
};

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/v1/hood/message-templates");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "Adex push template",
    "description" => "Push template that loads messages from an ad exchange zone.",
    "type" => "push",
    "labels" => [
      "promo"
    ],
    "push" => [
      "adex" => [
        "zone_id" => "1000321",
        "account_id" => [
          "123456",
          "654321"
        ],
        "number_of_messages" => 1,
        "repeat_on_click" => 0
      ]
    ]
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

Responses

201 Created

{
  "id": "1001",
  "company_id": "123456",
  "creator_id": "1000223",
  "system": 0,
  "name": "Adex push template",
  "description": "Push template that loads messages from an ad exchange zone.",
  "version": 1,
  "type": "push",
  "labels": [
    "promo"
  ],
  "push": {
    "adex": {
      "zone_id": "1000321",
      "account_id": [
        "123456",
        "654321"
      ],
      "number_of_messages": 1,
      "repeat_on_click": 0
    }
  },
  "create_time": "2024-07-03 11:32:40",
  "update_time": "2024-07-03 11:32:40"
}

400 Bad Request

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

403 Forbidden

{
  "code": 403,
  "title": "Forbidden",
  "message": "You are not allowed to perform this action.",
  "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