Add Catalog Attributes
curl --request PATCH \
--url https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"attributes": [
{
"name": "color",
"type": "string"
},
{
"name": "weight_kg",
"type": "double"
}
]
}
'import requests
url = "https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes"
payload = { "attributes": [
{
"name": "color",
"type": "string"
},
{
"name": "weight_kg",
"type": "double"
}
] }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
attributes: [{name: 'color', type: 'string'}, {name: 'weight_kg', type: 'double'}]
})
};
fetch('https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
[
'name' => 'color',
'type' => 'string'
],
[
'name' => 'weight_kg',
'type' => 'double'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes"
payload := strings.NewReader("{\n \"attributes\": [\n {\n \"name\": \"color\",\n \"type\": \"string\"\n },\n {\n \"name\": \"weight_kg\",\n \"type\": \"double\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": [\n {\n \"name\": \"color\",\n \"type\": \"string\"\n },\n {\n \"name\": \"weight_kg\",\n \"type\": \"double\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": [\n {\n \"name\": \"color\",\n \"type\": \"string\"\n },\n {\n \"name\": \"weight_kg\",\n \"type\": \"double\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"duplicate-item-attributes": [
"colour",
"weight"
]
}{
"error-code": "attribute-exists",
"message": "Attribute already exists in the catalog"
}{
"error-code": "request-unauthenticated",
"message": "Your request is unauthorized. Please verify your credentials and try again."
}{
"error-code": "request-denied",
"message": "Your account does not have access to the Catalog APIs."
}{
"error-code": "catalog-not-found",
"message": "We could not find any API based catalog for the provided catalog id."
}{
"error-code": "too-many-attributes",
"message": "Maximum allowed attributes is 50"
}Catalog
Add Catalog Attributes
You can use this API to add new attributes to the catalog. If the API request contains attributes that already exist, they will not be added again.
PATCH
/
catalog
/
{catalog_id}
/
attributes
Add Catalog Attributes
curl --request PATCH \
--url https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"attributes": [
{
"name": "color",
"type": "string"
},
{
"name": "weight_kg",
"type": "double"
}
]
}
'import requests
url = "https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes"
payload = { "attributes": [
{
"name": "color",
"type": "string"
},
{
"name": "weight_kg",
"type": "double"
}
] }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
attributes: [{name: 'color', type: 'string'}, {name: 'weight_kg', type: 'double'}]
})
};
fetch('https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
[
'name' => 'color',
'type' => 'string'
],
[
'name' => 'weight_kg',
'type' => 'double'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes"
payload := strings.NewReader("{\n \"attributes\": [\n {\n \"name\": \"color\",\n \"type\": \"string\"\n },\n {\n \"name\": \"weight_kg\",\n \"type\": \"double\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": [\n {\n \"name\": \"color\",\n \"type\": \"string\"\n },\n {\n \"name\": \"weight_kg\",\n \"type\": \"double\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-{dc}.moengage.com/v1/catalog/{catalog_id}/attributes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": [\n {\n \"name\": \"color\",\n \"type\": \"string\"\n },\n {\n \"name\": \"weight_kg\",\n \"type\": \"double\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"duplicate-item-attributes": [
"colour",
"weight"
]
}{
"error-code": "attribute-exists",
"message": "Attribute already exists in the catalog"
}{
"error-code": "request-unauthenticated",
"message": "Your request is unauthorized. Please verify your credentials and try again."
}{
"error-code": "request-denied",
"message": "Your account does not have access to the Catalog APIs."
}{
"error-code": "catalog-not-found",
"message": "We could not find any API based catalog for the provided catalog id."
}{
"error-code": "too-many-attributes",
"message": "Maximum allowed attributes is 50"
}Rate Limit Information
Request limit - 100/min OR 1000/hr. Payload size limit - 5MB only when Content-Length header is provided.Authorizations
Basic Authentication sends a Base64-encoded string containing your username and password.
You can obtain the username and password from the MoEngage Dashboard:
- Navigate to Settings > Account > APIs.
- Username: Copy the Workspace ID.
- Password: Copy the Catalog API key.
Path Parameters
The unique identifier for the catalog, obtained during catalog creation.
Body
application/json
A list of new attributes to add to the catalog schema.
Show child attributes
Show child attributes
Was this page helpful?
⌘I