Create Template

Create Template

POST https://api.ocamba.com/v1/hood/templates
Creates a Template

Rate limits:

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

Request schema

body

Response schemas

curl -X POST \
 "https://api.ocamba.com/v1/hood/templates" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Template example",
  "push": {
    "title": {
      "en": "first title"
    },
    "landing_url": "https://example.com",
    "actions": [
      {
        "title": {
          "en": "first title"
        }
      }
    ]
  },
  "adex": {
    "zone_id": "30303030",
    "account_id": [
      "1001001",
      "2002002",
      "3003003"
    ],
    "number_of_messages": 3,
    "repeat_on_click": 0
  }
}'
const url = 'https://api.ocamba.com/v1/hood/templates';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "Template example",
      "push": {
        "title": {
          "en": "first title"
        },
        "landing_url": "https://example.com",
        "actions": [
          {
            "title": {
              "en": "first title"
            }
          }
        ]
      },
      "adex": {
        "zone_id": "30303030",
        "account_id": [
          "1001001",
          "2002002",
          "3003003"
        ],
        "number_of_messages": 3,
        "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/templates");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "Template example",
    "push" => [
      "title" => [
        "en" => "first title"
      ],
      "landing_url" => "https://example.com",
      "actions" => [
        [
          "title" => [
            "en" => "first title"
          ]
        ]
      ]
    ],
    "adex" => [
      "zone_id" => "30303030",
      "account_id" => [
        "1001001",
        "2002002",
        "3003003"
      ],
      "number_of_messages" => 3,
      "repeat_on_click" => 0
    ]
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl -X POST \
 "https://api.ocamba.com/v1/hood/templates" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "all",
  "description": "description",
  "push": {
    "title": {
      "en": "title",
      "ar": "ar title",
      "bg": "bg title"
    },
    "body": {
      "en": "body",
      "ar": "ar body",
      "bg": "bg body"
    },
    "icon": "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
    "landing_url": "https://example",
    "tag": "tag",
    "require_interaction": 1,
    "renotify": 1,
    "silent": 1,
    "vibration": "100,100,100",
    "badge": "https://www.ocamba.com/baddge",
    "actions": [
      {
        "title": {
          "ar": "ar example",
          "bg": "bg example",
          "en": "ca example"
        },
        "icon": "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
        "url": "https://www.011shop.rs/uploads/store/products/images/majica.jpg"
      }
    ]
  },
  "adex": {
    "zone_id": "3000651",
    "account_id": [
      "6197120",
      "77957571",
      "26544179",
      "90921878",
      "24097548",
      "11117473",
      "98884220",
      "15881112",
      "86446726",
      "39578887",
      "98482244",
      "90653569",
      "52129304",
      "25005510",
      "42084773",
      "45945959",
      "44498263",
      "62464120",
      "47699893",
      "18140335"
    ],
    "campaign_id": [
      "1014025",
      "1013160",
      "1011958",
      "1011222",
      "1013027",
      "1012490",
      "1013688",
      "1013134",
      "1011619",
      "1011612",
      "1011591",
      "1014086",
      "1012320",
      "1013036",
      "1012985",
      "1012863",
      "1013376",
      "1012158",
      "1012055"
    ],
    "group_id": [
      "1747"
    ],
    "default_campaign_id": "1011222",
    "number_of_messages": 1,
    "repeat_on_click": 0
  },
  "sms": {
    "content": {
      "en": "en title${URL_0}",
      "vi": "vi title",
      "zh": "zh title"
    },
    "shorten_links": [
      {
        "placeholder": "URL_0",
        "url": "https://ocamba.com",
        "expires_in": 7
      }
    ]
  },
  "email": {
    "subject": "some subject",
    "preheader": "sale!",
    "content": "sale, 60%. Click here!"
  }
}'
const url = 'https://api.ocamba.com/v1/hood/templates';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "all",
      "description": "description",
      "push": {
        "title": {
          "en": "title",
          "ar": "ar title",
          "bg": "bg title"
        },
        "body": {
          "en": "body",
          "ar": "ar body",
          "bg": "bg body"
        },
        "icon": "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
        "landing_url": "https://example",
        "tag": "tag",
        "require_interaction": 1,
        "renotify": 1,
        "silent": 1,
        "vibration": "100,100,100",
        "badge": "https://www.ocamba.com/baddge",
        "actions": [
          {
            "title": {
              "ar": "ar example",
              "bg": "bg example",
              "en": "ca example"
            },
            "icon": "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
            "url": "https://www.011shop.rs/uploads/store/products/images/majica.jpg"
          }
        ]
      },
      "adex": {
        "zone_id": "3000651",
        "account_id": [
          "6197120",
          "77957571",
          "26544179",
          "90921878",
          "24097548",
          "11117473",
          "98884220",
          "15881112",
          "86446726",
          "39578887",
          "98482244",
          "90653569",
          "52129304",
          "25005510",
          "42084773",
          "45945959",
          "44498263",
          "62464120",
          "47699893",
          "18140335"
        ],
        "campaign_id": [
          "1014025",
          "1013160",
          "1011958",
          "1011222",
          "1013027",
          "1012490",
          "1013688",
          "1013134",
          "1011619",
          "1011612",
          "1011591",
          "1014086",
          "1012320",
          "1013036",
          "1012985",
          "1012863",
          "1013376",
          "1012158",
          "1012055"
        ],
        "group_id": [
          "1747"
        ],
        "default_campaign_id": "1011222",
        "number_of_messages": 1,
        "repeat_on_click": 0
      },
      "sms": {
        "content": {
          "en": "en title${URL_0}",
          "vi": "vi title",
          "zh": "zh title"
        },
        "shorten_links": [
          {
            "placeholder": "URL_0",
            "url": "https://ocamba.com",
            "expires_in": 7
          }
        ]
      },
      "email": {
        "subject": "some subject",
        "preheader": "sale!",
        "content": "sale, 60%. Click here!"
      }
    }
  )
};

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/templates");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "all",
    "description" => "description",
    "push" => [
      "title" => [
        "en" => "title",
        "ar" => "ar title",
        "bg" => "bg title"
      ],
      "body" => [
        "en" => "body",
        "ar" => "ar body",
        "bg" => "bg body"
      ],
      "icon" => "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
      "landing_url" => "https://example",
      "tag" => "tag",
      "require_interaction" => 1,
      "renotify" => 1,
      "silent" => 1,
      "vibration" => "100,100,100",
      "badge" => "https://www.ocamba.com/baddge",
      "actions" => [
        [
          "title" => [
            "ar" => "ar example",
            "bg" => "bg example",
            "en" => "ca example"
          ],
          "icon" => "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
          "url" => "https://www.011shop.rs/uploads/store/products/images/majica.jpg"
        ]
      ]
    ],
    "adex" => [
      "zone_id" => "3000651",
      "account_id" => [
        "6197120",
        "77957571",
        "26544179",
        "90921878",
        "24097548",
        "11117473",
        "98884220",
        "15881112",
        "86446726",
        "39578887",
        "98482244",
        "90653569",
        "52129304",
        "25005510",
        "42084773",
        "45945959",
        "44498263",
        "62464120",
        "47699893",
        "18140335"
      ],
      "campaign_id" => [
        "1014025",
        "1013160",
        "1011958",
        "1011222",
        "1013027",
        "1012490",
        "1013688",
        "1013134",
        "1011619",
        "1011612",
        "1011591",
        "1014086",
        "1012320",
        "1013036",
        "1012985",
        "1012863",
        "1013376",
        "1012158",
        "1012055"
      ],
      "group_id" => [
        "1747"
      ],
      "default_campaign_id" => "1011222",
      "number_of_messages" => 1,
      "repeat_on_click" => 0
    ],
    "sms" => [
      "content" => [
        "en" => "en title$[URL_0]",
        "vi" => "vi title",
        "zh" => "zh title"
      ],
      "shorten_links" => [
        [
          "placeholder" => "URL_0",
          "url" => "https://ocamba.com",
          "expires_in" => 7
        ]
      ]
    ],
    "email" => [
      "subject" => "some subject",
      "preheader" => "sale!",
      "content" => "sale, 60%. Click here!"
    ]
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

Responses

201 Created

{
  "id": "1002",
  "company_id": "123456",
  "name": "all",
  "description": "description",
  "channels": [
      "push",
      "sms",
      "adex",
      "email"
  ],
  "push": {
      "title": {
          "en": "title",
          "ar": "ar title",
          "bg": "bg title",  
      },
      "body": {
          "en": "body",
          "ar": "ar body",
          "bg": "bg body",  
      },   
      "icon": "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
      "landing_url": "https://example",
      "tag": "tag",
      "require_interaction": 1,
      "renotify": 1,
      "silent": 1,
      "vibration": "100,100,100",
      "badge": "https://www.ocamba.com/baddge",
      "actions": [
          {
              "title": {
                  "ar": "ar example",
                  "bg": "bg example",
                  "en": "ca example"
              },
              "icon": "https://www.011shop.rs/uploads/store/products/images/majica.jpg",
              "url": "https://www.011shop.rs/uploads/store/products/images/majica.jpg"
          }
      ]
  },
  "adex": {
      "zone_id": "3000651",
      "account_id": [
          "6197120",
          "77957571",
          "26544179",
          "90921878",
          "24097548",
          "11117473",
          "98884220",
          "15881112",
          "86446726",
          "39578887",
          "98482244",
          "90653569",
          "52129304",
          "25005510",
          "42084773",
          "45945959",
          "44498263",
          "62464120",
          "47699893",
          "18140335"
      ],
      "campaign_id": [
          "1014025",
          "1013160",
          "1011958",
          "1011222",
          "1013027",
          "1012490",
          "1013688",
          "1013134",
          "1011619",
          "1011612",
          "1011591",
          "1014086",
          "1012320",
          "1013036",
          "1012985",
          "1012863",
          "1013376",
          "1012158",
          "1012055"
      ],
      "group_id": [
          "1747"
      ],
      "default_campaign_id": "1011222",
      "number_of_messages": 1,
      "repeat_on_click": 0
  },
  "sms": {
      "content": {
          "en": "en title${URL_0}",
          "vi": "vi title",
          "zh": "zh title"
      },
      "shorten_links": [
          {
              "placeholder": "URL_0",
              "url": "https://ocamba.com",
              "expires_in": 7
          }
      ]
  },
  "email": {
      "subject": "some subject",
      "preheader": "sale!",
      "content": "sale, 60%. Click here!"
  },
  "create_time": "2024-07-03 06:42:30",
  "update_time": "2024-07-03 06:42:30"
}

400 Bad Request

{
  "code": 400,
  "title": "Bad request.",
  "message": "The request body 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
Tip
It is required to set at least one channel type.